Game Maker Programming/Creating a room
A room is created simply by clicking on a create room button - this is the first step that you must do when creating a game.
The creation of the room will add an entry to the list of resources - the default name of your first room is "room0", with the number incrementing it for each step. To avoid confusion, it is recommended to rename the room as soon as possible - either giving an English-readable name or with your own naming convention.
On the left hand-side of the room design window, you have a set of 5 tabs available.
- Background, which allows you to assign 8 background/foreground elements on the screen.
- Views, which allows you to define up to 8 camera positions.
- Objects, which allows you to add objects that you have already defined.
- Settings, which allows you to adjust the size and framerate for a given room. (You can also add custom room creation options as well.)
- Tiles, which are images that are displayed but do not interact with other objects. You can have multiple layers of tiles, where lower depths are displayed on-top of higher depths. In some cases, you can display tiles in front of objects.
The settings of the room contain the basic information about the room. You can set the name, window title (or caption), the width, height, speed (in steps per second), and it's persistence flag.
By default, the background color of a room is a single black color. While you can modify it directly, you may want to use a picture as part of a background.
- Create a new background in the backgrounds folder. You should see the background properties of a blank background.
- Click on Load Background, and choose any background you want. You may want to rename the background.
- Return to the room properties, and open its background tab.
- Click on the background selection, and choose the background you created.
If you have a transparent or semi-transparent background, you can choose up to eight background slots - ones lower down the list are drawn in-front of higher ones.
You can also tag a certain background layer as a "foreground", which causes it to be rendered after the rest of the scene is created. This can be used to create HUDs or other possible decorations.
For advanced control over a room's display, you can open the tiles tab. While they use the background resource set, they can appear between objects. Tiles are slightly faster than using objects for display purposes, since they do not require collision checking.
Tiles are located on layers which have a given depth value. The highest depths are rendered first, and lower depths are drawn on-top of existing layers. They normally use images from the Backgrounds image set.
You can place an object in the room by selecting an object from the list of available objects, and clicking within the room. A left-click will create an object, while a right-click will delete it; you can also use the Shift, Ctrl, and Alt modifier keys to change what you want to do with an object.
A view allows you to control the camera on screen - to enable it, you first need to check Enable the use of Views at the top of the tab. If Enable the use of Views does not appear, you are likely not in advanced mode. Note that if this is checked, you need to ensure that at least one view is visible when the room starts or is otherwise made visible in-game.
In each of the seven views available, you can modify three different sets of options:
- View in Room - this indicates the coordinates of activity in the game itself.
- Port on Screen - this indicates the coordinates and size on the display screen.
- Object Following - if set to an object, the view will move the camera to keep the given object on screen.
To change a room, you need to create an object and assign an event to an object; you can create events by opening the object's properties. When it's created, find the room change actions (available by going through the tabs on the far right) and add one of the change room actions.
By default, rooms will reset once they are left; platforms return to their original position, items will reappear, etc. A persistent room will remain in the exact way as it was left, and will only reset if the game restarts. If you need to reset a persistent room, it may be done manually via scripting.
Persistent objects will not remain with the previous room; they will be transferred to the new room.