How to code a timer?

You can use Alarms to run code after some time or on a loop.

Let’s say you set Alarm 0 to 30, in the Create event of an object:

/// Create
alarm[0] = 30;

Since one second has 60 steps, the Alarm 0 event should run after half a second.

/// Alarm 0 event
speed += 1;

After half a second, the speed of the instance will be increased by 1.

If you set the alarm again inside the same Alarm event, it’ll create a loop:

speed += 1;

alarm[0] = 60;

From that point on, the alarm will run every 60 steps – which is one second. This creates a 1-second interval loop.