127 lines
4.2 KiB
HTML
127 lines
4.2 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
|
|
<html>
|
|
<head>
|
|
<title>Timing</title>
|
|
<link href="style.css" rel="stylesheet" type="text/css">
|
|
</head>
|
|
<body background="images/back.gif">
|
|
<!--START-->
|
|
|
|
<h3>Timing</h3>
|
|
|
|
Good games require careful timing of things happening. Fortunately
|
|
<i>Game Maker</i> 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):
|
|
|
|
<p>
|
|
<blockquote>
|
|
<tt><b>room_speed</b></tt>
|
|
Speed of the game in the current room (in steps per second).<br>
|
|
<tt><b>fps*</b></tt>
|
|
Number of frames that are actually drawn per second.<br>
|
|
<tt><b>current_time*</b></tt>
|
|
Number of milliseconds that have passed since the system was started.<br>
|
|
<tt><b>current_year*</b></tt>
|
|
The current year.<br>
|
|
<tt><b>current_month*</b></tt>
|
|
The current month.<br>
|
|
<tt><b>current_day*</b></tt>
|
|
The current day.<br>
|
|
<tt><b>current_weekday*</b></tt>
|
|
The current day of the week (1=sunday, ..., 7=saturday).<br>
|
|
<tt><b>current_hour*</b></tt>
|
|
The current hour.<br>
|
|
<tt><b>current_minute*</b></tt>
|
|
The current minute.<br>
|
|
<tt><b>current_second*</b></tt>
|
|
The current second.<br>
|
|
</blockquote>
|
|
|
|
<p>
|
|
Sometimes you might want to stop the game for a short while. For this, use the sleep function.
|
|
|
|
<p>
|
|
<blockquote>
|
|
<tt><b>sleep(numb)</b></tt>
|
|
Sleeps numb milliseconds.<br>
|
|
</blockquote>
|
|
|
|
<p>
|
|
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:
|
|
|
|
<p>
|
|
<blockquote>
|
|
<tt><b>alarm[0..11]</b></tt>
|
|
Value of the indicated alarm clock. (Note that alarm clocks only get
|
|
updated when the alarm event for the object contains actions!)<br>
|
|
</blockquote>
|
|
|
|
<p>
|
|
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:
|
|
|
|
<p>
|
|
<blockquote>
|
|
<tt><b>timeline_index</b></tt>
|
|
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. Note that this does not start the time
|
|
line. For this use the variable <tt>timeline_running</tt>.<br>
|
|
<tt><b>timeline_position</b></tt>
|
|
Current position within the time line. You can change this to skip certain
|
|
parts or to repeat parts.<br>
|
|
<tt><b>timeline_speed</b></tt>
|
|
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. You can also use a negative
|
|
value to let the time line play backwards.<br>
|
|
<tt><b>timeline_running</b></tt>
|
|
Indicates whether the time line is running (true) or paused or stopped (false).
|
|
You can change this variable to run or stop the time line.<br>
|
|
<tt><b>timeline_looping</b></tt>
|
|
Indicated whether the time line is looping (true) or not (false). You can change
|
|
this variable to switch looping on or off.
|
|
</blockquote>
|
|
|
|
|
|
<!--END-->
|
|
</body>
|
|
</html>
|
|
|
|
<!-- KEYWORDS
|
|
timing
|
|
frames per second
|
|
speed
|
|
|
|
room_speed
|
|
fps
|
|
current_time
|
|
current_year
|
|
current_month
|
|
current_day
|
|
current_weekday
|
|
current_hour
|
|
current_minute
|
|
current_second
|
|
sleep()
|
|
alarm[0..11]
|
|
timeline_index
|
|
timeline_position
|
|
timeline_speed
|
|
|
|
--> |