• 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!

Alarm stops working

R

rangers1001c

Guest
I have an alarm event that periodically generates an object that acts as a speed boost.

When the player touches that object, it increases their speed and is destroyed.

My problem is that no other objects are generated after any of the boost objects are destroyed.

To rephrase, the alarm event generates these boost objects, the player collides with one of the boost objects, and no more boost objects are generated until all the other boost objects have left the screen.

Suggestions?
 
L

Lars Karlsson

Guest
Unfortunately we can't really help you without you showing us your code. Preferably the alarm code and the code that starts the alarm.
 
R

rangers1001c

Guest
The boost generator object's alarm event:
alarm[0]=35; //sets the alarm

h=irandom_range(300,1850); //choose a random height
instance_create(room_width+200 , h , obj_rocket); //create the boost


The boost object's collision:
instance_destroy(); //destroy the boost

with(all) //increase speed of objects
{
hspeed=-7;
obj_player.hspeed=0;
alarm[0]=180 ; //use this to slow down later
}


The alarm directly above is used to slow down the objects:
with(all)
{
hspeed=-2;
obj_player.hspeed=0;
}
 

Tsa05

Member
with all alarm[0]=180

That's doing it to you!
Every time you hit a boost object, it sets the alarm[0] of ALL objects to 180. Including the generator object.

Easiest fix, use a different alarm number.

Edit:
I should also mention--you can also use parenting and stuff to make it with(thingsThatGetBoosted) alarm[0]=180. That would avoid resetting the generator's alarm too.
 
R

rangers1001c

Guest
with all alarm[0]=180

That's doing it to you!
Every time you hit a boost object, it sets the alarm[0] of ALL objects to 180. Including the generator object.

Easiest fix, use a different alarm number.

Edit:
I should also mention--you can also use parenting and stuff to make it with(thingsThatGetBoosted) alarm[0]=180. That would avoid resetting the generator's alarm too.
Oooh, I thought alarms of different objects didn't interfere with eachother. Whoops
 

Tsa05

Member
Yep, usually they do not! But the with(all) statement causes all objects to execute that code. So, while every object does have a unique, personal set of alarms, your with(all) is setting all alarm[0] values for all objects.

(Also, btw, it's adding speed and stuff to all object, too--the generator is technically moving with an hspeed of -7!!!! Probably is not harming anything, though.)
 
Top