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:

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)
}
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)