S
SilentCipher
Guest
Hello everyone, i have a shooting mechanic i'm trying to get down for game, and i'm trying to use an alarm to do what i want. I'm having a hard time, was wondering if someone could maybe explain what i'm doing wrong, or explain how to fix what i'm doing.
Also, it is my first time posting, i read the guidelines, i am trying my best.
What i'm trying to do: Essentially what i'm trying to do is make it to where, the player can hold down space bar, and the game will keep shooting for them as long as they hold space bar, but in intervals. I don't want there to be a giant line of bullets, instead i want it, as example, fire a bullet, then 30 frames later, essentially half a second, another bullet goes out.(edited)
Here is a video of how this code is running in game, as you can see i'm also having this issue where, the alarm with run out, and create a new bullet along with the alarm bullet.
Version: Game Maker studio 2 vr 2.2.1.291
Code -
step event
alarm[0]
If I am missing any information that you would need please let me know, i'm still ongoing with attempting to solve this on my own. I've spent already 2 hours, and still haven't gotten what i'm aiming for lol.
Thus i resorted to coming here for the first time.
PS, im still pretty new to alarms, i feel like i understand the basic of what it is essentially.
Also, it is my first time posting, i read the guidelines, i am trying my best.
What i'm trying to do: Essentially what i'm trying to do is make it to where, the player can hold down space bar, and the game will keep shooting for them as long as they hold space bar, but in intervals. I don't want there to be a giant line of bullets, instead i want it, as example, fire a bullet, then 30 frames later, essentially half a second, another bullet goes out.(edited)
Here is a video of how this code is running in game, as you can see i'm also having this issue where, the alarm with run out, and create a new bullet along with the alarm bullet.
Version: Game Maker studio 2 vr 2.2.1.291
Code -
step event
Code:
if (keyboard_check(vk_space)) {
if (alarm_get(0) > 0) {
show_debug_message("Alarm Hasn't hit Zero");
exit;
} else {
var _bullet = instance_create_layer(x, y, "Instances", obj_friendly_bullet);
_bullet.speed = 10;
alarm_set(0, 30);
show_debug_message("Alarm Created");
}
}
Code:
var _bullet = instance_create_layer(x, y, "Instances", obj_friendly_bullet);
_bullet.speed = 10;
If I am missing any information that you would need please let me know, i'm still ongoing with attempting to solve this on my own. I've spent already 2 hours, and still haven't gotten what i'm aiming for lol.
Thus i resorted to coming here for the first time.
PS, im still pretty new to alarms, i feel like i understand the basic of what it is essentially.