How do you make your bullet patterns?

A place for people with an interest in developing new shmups.
EddyMRA
Posts: 798
Joined: Wed Jan 26, 2005 9:36 am
Location: San Diego, CA, USA

Re: How do you make your bullet patterns?

Post by EddyMRA »

Here's a demo of an aimed bullet spread script for Game Maker I made: http://www.sendspace.com/file/6u89ey

It is highly customizable and flexible. You can set the arc of the bullet spread in degrees (up to 360 degrees), the number of bullets in the arc, and the speed of the bullets. You can also set the bullet object to shoot, as well as the sound to play for shooting.

In the demo, the spread is aimed towards the mouse cursor's position.

Screenshot:
Image

Script code:

Code: Select all

//Variables from arguments
bullettype  = argument0
shootsound  = argument1
arc         = argument2
numbullets  = argument3
bulletspeed = argument4

//Get direction to shoot (from origin to player)
shootdir   = point_direction (x, y, [name of player object].x, [name of player object].y)

if numbullets > 1
    arcstart   = (shootdir - (arc / 2))
else
    arcstart   = shootdir
    
//play shoot sound
if sound_isplaying (shootsound)
    sound_stop (shootsound)
sound_play (shootsound)

//Shoot the bullets
for (i = 0; i < numbullets; i += 1)
{
    mybullet = instance_create (x, y, bullettype)
    mybullet.direction = arcstart
    mybullet.speed = bulletspeed
    if numbullets > 1
        arcstart += arc / (numbullets - 1)
}
Example usage:
To shoot an aimed bullet spread with an arc of 90 degrees with 10 bullets in the arc and 2 pixels per step speed, using obj_bullet as the bullet object and snd_shoot as the shooting sound:

Code: Select all

aimedbulletspread (obj_bullet, snd_shoot, 90, 10, 2)
You can easily modify this script so that you can shoot a spread at a given angle rather than towards the player's ship.
The age of Alluro and JudgeSpear is over.
Post Reply