rookie asks for help part II

netoxinaa

Member
hey there, i´m working on a space shooter as my first game and i would like to know how to make an enemy shoot every x seconds. i tried to set an alarm in the enemy´s step event but it wont run it.
 

samspade

Member
You should post your code as that is helpful (often necessary) to answer the question. But most likely, you are resetting the alarm before it finishes. For example, if you are doing this:

Code:
///step event
alarm[0] = 60;
Then every single step the alarm gets set to 60, counts down to 59, and is reset again. There are many solutions to this problem, but the simplest one that uses the built in alarms is this:

Code:
if (alarm[0] == -1) {
    alarm[0] = 60;
}
This will only set the alarm if the alarm is equal to -1 which is what alarms are in GM when they are off.

Other options (which might be helpful just in general to understanding how this type of problem is dealt with) are:
 

netoxinaa

Member
You should post your code as that is helpful (often necessary) to answer the question. But most likely, you are resetting the alarm before it finishes. For example, if you are doing this:

Code:
///step event
alarm[0] = 60;
Then every single step the alarm gets set to 60, counts down to 59, and is reset again. There are many solutions to this problem, but the simplest one that uses the built in alarms is this:

Code:
if (alarm[0] == -1) {
    alarm[0] = 60;
}
This will only set the alarm if the alarm is equal to -1 which is what alarms are in GM when they are off.

Other options (which might be helpful just in general to understanding how this type of problem is dealt with) are:
thanks man, i managed to solved it just by moving my alarm setting into the create event, gonna check the info tho
 
Top