Home | Customize | Blog | Extras | Log In | Info
Manual | D&D icons | GML Parser | Archive | Iso City
Username: Password:  
About | Features | Directory | Banners | Contact

Designing Games with GameMaker
Designing Games with GameMaker


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:

  if (room != room_last)

The following variables and functions exist that deal with rooms.

room Index of the current room; can be changed to go to a different room, but you had better use the routines below.
room_first* Index of the first room in the game.
room_last* Index of the last room in the game.
room_goto(numb) Goto the room with index numb.
room_goto_previous() Go to the previous room.
room_goto_next() Go to the next room.
room_restart() Restart the current room.
room_previous(numb) Return the index of the room before numb (-1 = none) but don't go there.
room_next(numb) Return the index of the room after numb (-1 = none).
game_end() End the game.
game_restart() Restart the game.

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.

Rooms have a number of additional properties:

room_width* Width of the room in pixels.
room_height* Height of the room in pixels.
room_caption Caption string for the room that is displayed in the caption of the window.
room_persistent Whether the current room is persistent.

Many games offer the player the possibility of saving the game and loading a saved game. In GameMaker this happens automatically when the player press <F5> for saving and <F6> 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).

game_save(string) Saves the game to the file with name string.
game_load(string) Loads the game from the file with name string.

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.


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 transition_kind. 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.

transition_kind Indicates the next room transition. You can use the following builtin values

0 = no effect
1 = Create from left
2 = Create from right
3 = Create from top
4 = Create from bottom
5 = Create from center
6 = Shift from left
7 = Shift from right
8 = Shift from top
9 = Shift from bottom
10 = Interlaced from left
11 = Interlaced from right
12 = Interlaced from top
13 = Interlaced from bottom
14 = Push from left
15 = Push from right
16 = Push from top
17 = Push from bottom
18 = Rotate to the left
19 = Rotate to the right
20 = Blend the rooms
21 = Fade out and in
transition_steps Indicates the number of steps in the transition. The more steps, the longer the transition takes. Default is 80.
transition_define(kind,name) 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. kind is the index of the transition (either a new one or an existing transitions). name 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.
transition_exists(kind) This function returns whether a transition of the indicated kind exists.

Please note that transitions do not work when 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.

« Timing | Score »

Search Search

Alternative versions Alternative versions

You can also read this manual on one single long page (± 1.5 mb)

Also available in: Dutch French German

ZIP Download helpfile

Advertisement Advertisement

GameMaker Manual