• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Windows shooting in multiple directions

L

LivelyLayla

Guest
Quick notifier, I'm completely new to game maker and making games in general.

So I'm trying to make a sidescrolling space shooter and I want a power-up that lets you shoot in 3 different directions instead of just forwards (like bullet spread, one bullet goes 45 degrees up and another 45 degrees down while the third goes straight). Is there a way to achieve this with just one bullet object? I know I can do it if I create 3 seperate bullet objects but that just seems horribly inefficient to me.

the code for normal forwards fire is as follows:
//Create Bullet
if (firing = false) {
firing = true;
alarm[0] = firingSpeed
bullet = instance_create(x, y, obj_bullet);
}
 
N

nlolotte

Guest
I would create a variable for the power up and set it to true upon collision with the power up.

Then when the fire button is pressed perform a check to see if that variable is true.

If the variable is not true create the normal projectile.

Else if the variable is true, with the create event of object bullet set the direction relative to the 45 degrees. The code is something like this:

Code:
if has_3shot
{
    with instance_create_depth(x,y,depth,obj_bullet)
    {
        vspeed = -5
    }
    with instance_create_depth(x,y,depth,obj_bullet)
    {
        vspeed = -5
        hspeed = -5
    }
    with instance_create_depth(x,y,depth,obj_bullet)
    {
        vspeed = -5
        hspeed = 5
    }
}
else
{
    with instance_create_depth(x,y,depth,obj_bullet)
    {
        vspeed = -5
    }
}
Then simply remove all directional code from the bullet object.

Sorry I’m on my mobile, hope that helps.

EDIT: Tidied up code, just read this is a side scrolling shooter but the code still applies. just have to changed vspeed for hspeed in places.
 
L

LivelyLayla

Guest
It says that instance_create_depth isn't a function and the text is white as well
 
L

LivelyLayla

Guest
a'ight, I'll give that a go then, thanks for the help in advance, I'll let you know if I can get it working
 
Top