Game Development Reference
In-Depth Information
Figure 14-2. Our game map.
In our example game, there are eight rooms numbered room_1 through to room_8 , which we
want to form the world above. As you can see, most rooms consist of a border of blocks, in which
we've left gaps. The gaps can be any size, but there are two important rules:
For two adjacent rooms, the gaps must be of equal size.
The gaps must fit together exactly; in other words, vertical gaps must be at the same
vertical position, while horizontal gaps must be at the same horizontal position.
If you do not take these rules into account, you will at some point get the player stuck in a
wall when trying to move from one room to another.
Creating Room Movement
1.
In this game, we want the player to collect amulets. If they return to a room they have
previously visited, then the amulets that were already collected should no longer be
there. Normally, all the instances are reset every time you jump to a room in Game
Maker, but you can let the room preserve the state it was left in by making the room
Persistent . Open room_1 , select the settings tab, and mark the Persistent check box.
2.
Repeat the first step for room_2 , room_3 , room_4 , room_5 , room_6 , room_7 , and room_8 .
Note that persistent rooms are reset by restarting the game, which is what we will do
when the player is killed.
Now open obj_explorer and check the Persistent option for this object. Persistence for
objects does something different: as long as the instance is not destroyed, it makes
obj_explorer move to any room we jump to. It doesn't execute the Create event when
it is moved to the new room, and it keeps all its variables in the same state, placing it
exactly where we last left it. That's why we will have only one instance of obj_explorer
in the game. We've put it in room_1 .
3.
 
Search WWH ::




Custom Search