Files
QtGameMaker/help/files/403_08_rooms.html
T

207 lines
6.6 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Rooms</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<body background="images/back.gif">
<!--START-->
<h3>Rooms</h3>
Games work in rooms. Each room has an index that is indicated by the name of the room.
The current room is stored in variable room. You cannot assume that rooms are
numbered in a consecutive order. So never add or subtract a number from the
room variable. Instead use the functions and variables indicated below. So
a typical piece of code you will use is:
<p>
<blockquote>
<pre>
{
<b>if</b> (room != room_last)
{
room_goto_next();
}
<b>else</b>
{
game_end();
}
}
</pre>
</blockquote>
<p>
The following variables and functions exist that deal with rooms.
<p>
<blockquote>
<tt><b>room</b></tt>
Index of the current room; can be changed to go to a different room,
but you had better use the routines below.<br>
<tt><b>room_first*</b></tt>
Index of the first room in the game.<br>
<tt><b>room_last*</b></tt>
Index of the last room in the game.<br>
<tt><b>room_goto(numb)</b></tt>
Goto the room with index numb.<br>
<tt><b>room_goto_previous()</b></tt>
Go to the previous room.<br>
<tt><b>room_goto_next()</b></tt>
Go to the next room.<br>
<tt><b>room_restart()</b></tt>
Restart the current room.<br>
<tt><b>room_previous(numb)</b></tt>
Return the index of the room before numb (-1 = none) but don't go there.<br>
<tt><b>room_next(numb)</b></tt>
Return the index of the room after numb (-1 = none).<br>
<tt><b>game_end()</b></tt>
End the game.<br>
<tt><b>game_restart()</b></tt>
Restart the game.<br>
</blockquote>
<p>
When calling one of the above functions to change the room or end or restart the game, please realize
that this change does actually not occur at that precise moment. It only happens after the current action is
fully executed. So the rest of the script will still be executed, and the same applies to possible
calling scripts. However, no events are executed anymore. As this can lead to unexpected behavior you are strongly
advised not to put any code anymore after the use of such functions.
<p>
Rooms have a number of additional properties:
<p>
<blockquote>
<tt><b>room_width*</b></tt>
Width of the room in pixels.<br>
<tt><b>room_height*</b></tt>
Height of the room in pixels.<br>
<tt><b>room_caption</b></tt>
Caption string for the room that is displayed in the caption of the window.<br>
<tt><b>room_persistent</b></tt>
Whether the current room is persistent.<br>
</blockquote>
<p>
Many games offer the player the possibility of saving the game and loading a saved game.
In <i>Game Maker</i> this happens automatically when the player press &lt;F5&gt;
for saving and &lt;F6&gt; for loading. You can also save and load games from
within a piece of code (note that loading only takes place at the end of the
current step).
<p>
<blockquote>
<tt><b>game_save(string)</b></tt>
Saves the game to the file with name string.<br>
<tt><b>game_load(string)</b></tt>
Loads the game from the file with name string.<br>
</blockquote>
<p>
Please realize that only the basic game data is being saved. If for example you play
a particular piece of music, the precise position in the music is not saved. Also changed
resources are not saved. Other things that are not saved are the contents of data structures,
particles, and multiplayer settings.
<h2>Transitions</h2>
<p>
When you move from one room to another you can select a transition.
To set the transition to the next frame you must set the
variable called <tt>transition_kind</tt>. If you assign a value larger than 0 to it the
corresponding transition is used for the next room transition. It only affect the next
transition. After this the value is reset to 0, which indicates no transition.
<p>
<blockquote>
<tt><b>transition_kind</b></tt>
Indicates the next room transition. You can use the following builtin values
<p>
<blockquote>
0 = no effect<br>
1 = Create from left<br>
2 = Create from right<br>
3 = Create from top<br>
4 = Create from bottom<br>
5 = Create from center<br>
6 = Shift from left<br>
7 = Shift from right<br>
8 = Shift from top<br>
9 = Shift from bottom<br>
10 = Interlaced from left<br>
11 = Interlaced from right<br>
12 = Interlaced from top<br>
13 = Interlaced from bottom<br>
14 = Push from left<br>
15 = Push from right<br>
16 = Push from top<br>
17 = Push from bottom<br>
18 = Rotate to the left<br>
19 = Rotate to the right<br>
20 = Blend the rooms<br>
21 = Fade out and in<br>
</blockquote>
<tt><b>transition_steps</b></tt>
Indicates the number of steps in the transition. The more steps, the longer the
transition takes. Default is 80.<br>
<tt><b>transition_define(kind,name)</b></tt>
You can actually create your own transitions. To this end you must define a script
(possibly in an extension package) to do the transition. With this function you can
then add the transition to the system. <tt>kind</tt> is
the index of the transition (either a new one or an existing transitions). <tt>name</tt> is the
name of the script. Note that the name of the script is a string!
So there must be quotes around it.
Note that this is really advanced stuff.
The script must take five arguments: a surface with the image
of the previous room, a surface with the image of the next room, the width of the
surfaces, the height of the surfaces, and the fraction
of the transition (between 0 and 1). It must then draw the image using the two
surfaces. <br>
<tt><b>transition_exists(kind)</b></tt>
This function returns whether a transition of the indicated kind exists.
</blockquote>
<p>
Please note that transitions do not work when using using 3d graphics. Also, room transitions in general
do not work correctly when the sizes of the rooms (or to be more precise of the region on the screen)
are not the same.
<!--END-->
</body>
</html>
<!-- KEYWORDS
room variables
saving games
loading games
room
room_first
room_last
room_width
room_height
room_caption
room_persistent
room_goto()
room_goto_previous()
room_goto_next()
room_previous()
room_next()
room_restart()
game_end()
game_restart()
game_load()
game_save()
transitions
room transitions
transition_kind
transition_color
transition_steps
transition_define()
transition_exists()
-->