Timing

Good games require careful timing of things happening. Fortunately Game Maker does most of the timing for you. It makes sure things happen at a constant rate. This rate is defined when defining the rooms. But you can change it using the global variable room_speed. So for example, you can slowly increase the speed of the game, making it more difficult, by adding a very small amount (like 0.001) to room_speed in every step. If your machine is slow the game speed might not be achieved. This can be checked using the variable fps that constantly monitors the actual number of frames per second. Finally, for some advanced timing you can use the variable current_time that gives the number of milliseconds since the computer was started. Here is the total collection of variables available (only the first one can be changed):
room_speed Speed of the game in the current room (in steps per second).
fps* Number of frames that are actually drawn per second.
current_time* Number of milliseconds that have passed since the system was started.
current_year* The current year.
current_month* The current month.
current_day* The current day.
current_weekday* The current day of the week (1=sunday, ..., 7=saturday).
current_hour* The current hour.
current_minute* The current minute.
current_second* The current second.

Sometimes you might want to stop the game for a short while. For this, use the sleep function.

sleep(numb) Sleeps numb milliseconds.

As you should know, every instance has 12 different alarm clocks that you can set. To change the values (or get the values) of the different alarm clocks use the following variable:

alarm[0..11] Value of the indicated alarm clock. (Note that alarm clocks only get updated when the alarm event for the object contains actions!)

We have seen that for complex timing issues you can use the time line resource. Each instance can have a time line resource associated with it. The following variables deal with this:

timeline_index Index of the time line associated with the instance. You can set this to a particular time line to use that one. Set it to -1 to stop using a time line for the instance.
timeline_position Current position within the time line. You can change this to skip certain parts or to repeat parts.
timeline_speed Normally, in each step the position in the time line is increased by 1. You can change this amount by setting this variable to a different value. You can use real numbers like 0.5. If the value is larger than one, several moments can happen within the same time step. They will all be performed in the correct order, so no actions will be skipped.
Converted from CHM to HTML with chm2web Pro 2.85 (unicode)