Legacy GM [SOLVED] Delayed Shots and Shooting based on Faced Direction?

M

MintyPretzel126

Guest
I believe I have the first part of the code right, but I'm not sure what to put next.

if(instance_number(OBJ_Bullet) == 0){
;
}

I think there's a can_shoot function or something like that, but I'm not sure how it goes. As for shooting based on the direction you are turned, I'm not sure how you do that either. Thank you for at least taking the time to read this.
 
V

vidokas

Guest
for delayed shots you can alarm event. when alarm reaches zero, then you can shoot.
while it's not zero you can't shoot

space key event
Code:
if can_shoot = 1
{
shoot bullet
can_shoot =0;
alarm[0] = 10;
}
alarm[0] event
Code:
can_shoot = 1;

for shooting to specific direction. make variable shooting_direction.
and when you move right, then shooting_direction = 2
if you move left then variable will be changed to shooting_direction = 1

press A event.
Code:
move left
shooting_direction = 1;

press D event.
Code:
move right
shooting_direction = 2;

press space event. //shooting
Code:
if can_shoot = 1
{
if shooting direction = 1
{
create bullet that flies to left
}
else
{
create bullet that flies to right
}
}
else
{
exit;
}
 
M

MintyPretzel126

Guest
for delayed shots you can alarm event. when alarm reaches zero, then you can shoot.
while it's not zero you can't shoot

space key event
Code:
if can_shoot = 1
{
shoot bullet
can_shoot =0;
alarm[0] = 10;
}
alarm[0] event
Code:
can_shoot = 1;

for shooting to specific direction. make variable shooting_direction.
and when you move right, then shooting_direction = 2
if you move left then variable will be changed to shooting_direction = 1

press A event.
Code:
move left
shooting_direction = 1;

press D event.
Code:
move right
shooting_direction = 2;

press space event. //shooting
Code:
if can_shoot = 1
{
if shooting direction = 1
{
create bullet that flies to left
}
else
{
create bullet that flies to right
}
}
else
{
exit;
}
So I tried your code. When I booted up the game, it gave me a compile error. I checked to see, and some of the lines were red. I think it's because they don't exist, but I'm not sure. I tried replacing every "bullet" with OBJ_Bullet, but it didn't work.
 
V

vidokas

Guest
there can be some problems.
I just wrote it like idea.

btw.
you should create variables first in create event.

shooting_direction = 1;
can_shoot = 1;


and of course replace these lines with actual code

move right
shoot bullet
 
M

MintyPretzel126

Guest
there can be some problems.
I just wrote it like idea.

btw.
you should create variables first in create event.

shooting_direction = 1;
can_shoot = 1;


and of course replace these lines with actual code

move right
shoot bullet
Ah, gotcha. That's okay, I'm a newbie, so I could learn something anyway. Thanks! :)
 
Top