Using Alarms

Alarms are something nearly every good game needs, anything that needs timing, needs an alarm (you can use timelines and the timer, you're half way to understanding them, once an alarm is called from an event, the countdown begins! Take the following call to an alarm for example: [0] = 90; What hacan be found in the Room Properties. (Each room can have a different speed if need be): To calculate the number of steps in the number of seconds you want, you must do the following: fps x Number of Seconds Therefore, taking the number of steps per second into account, the 90 in the above example translates to 3 seconds, like so: 30 x 3 = 90

How do you use them?
Hopefully, you have grasped the basic concept of alarms but how do you actually use them? Well, one example would be in a platform game where a cannon, on one side of the screen, fires a cannonball across to the other side after 5 seconds, but how?

In the for the cannon object, you could have something like: And here's the GML version: .cannonshots = 10; cannonangle = 270; [0] = 150 So as soon as the cannon object is created, it will do the various things then hit the alarm event: Set Alarm 0 to 150, starting the countdown in steps. [Remember it's SECONDS x ROOM SPEED: 5 x 30 = 150].

You would also create an alarm[0] event and place the things in there you wish to happen when it's called, in this case, after 5 seconds:

You'll notice in the alarm[0] event above, there is another alarm call at the end, and this alarm call is calling itself! This is useful for looping alarms and in the above example, a cannonball will shoot across the screen every 5 seconds as the alarm event is resetting the countdown to recall itself again.

Here's the GML version: // Create the cannonball and move it .. . // Call this alarm repeatedly alarm[0] = 150