Game Development Reference
In-Depth Information
4. The compass works as an exit only, so nothing will bring the explorer back unless we
don't add compass instances to other rooms. Open room_2 and add an instance of
obj_compass again. This room has only one exit, so set its creation code to read:
1: {
2: west = room_1;
3: }
Don't forget to lock the instance. Notice that if you wanted to, it is actually quite easy
to make the explorer return to a completely different room. Some games apply this
“magic” trick to confuse the player.
Now, use the map as a guide and complete the process for room_3 , room_4 , room_5 ,
room_6 , room_7 , and room_8 .
5.
6.
Test your game to make sure that all exits lead to the correct room. Check all exits in
both directions! But don't touch the baddies on the way, or you can start your walk all
over….
Result: Reference/Result/room_movement.gmk
Tip The player is always immediately placed at the entrance of the room. Make sure to keep this area
free of dangers—it isn't fair on the player to enter a room and immediately end up in trouble.
Orbiting Objects
Whether it's for planets, for activated power-ups such as shields, or just for show, sometimes
you'll need one or more objects to orbit another object and follow it around wherever it goes. In
the next example, we'll make some stars circle our spaceship.
Start with: Reference/Framework/spaceship6.gmk
Creating Orbiting Objects
1. Create an object and call it obj_star . Set spr_star as its Sprite .
2. In the same object, add a Step , End Step event. Because this event will be responsible
for adjusting the star's position to the spaceship, we use the End Step event to make
sure that the ship's position has been updated first. Include an Execute Code action
and insert the following lines:
1: {
2: x = obj_spaceship.x+lengthdir_x(100,angle);
3: y = obj_spaceship.y+lengthdir_y(100,angle);
4: angle += 5;
5: }
 
 
Search WWH ::




Custom Search