08.11.2012 Views

Designing Games with Game Maker - YoYo Games

Designing Games with Game Maker - YoYo Games

Designing Games with Game Maker - YoYo Games

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

You might wonder what happens when the instance collides <strong>with</strong> another instance while it<br />

follows a path. Basically the same happens as when the instance moves <strong>with</strong> a speed. When<br />

there is a solid instance, the instance is placed back at its previous location. When both<br />

instances are not solid they are placed at their new positions Next the collision event(s) are<br />

executed and it is checked whether the collision has been resolved. If not and the other<br />

instance is solid the instance will stop, as it should (assuming there is a collision event<br />

defined). Also, the path_position variable is not increased. When the blocking instance<br />

disappears the instance will continue to follow its path. To handle collisions yourself the<br />

variable path_positionprevious can be useful. It holds the previous position for the path<br />

and you can set the path position to this variable to avoid advancing along the path.<br />

The path event<br />

As described above, you can indicate what must happen when the instance reaches the end of<br />

the path. At this moment also an End of Path event occurs. You can find it under the Other<br />

events. Here you can place actions. For example, you might want to destroy the instance, or<br />

let it start a new (different) path.<br />

Time Lines<br />

In many games certain things must happen at certain moments in time. You can try to<br />

achieve this by using alarm events but when things get too complicated this won't work any<br />

more. The time line resource is meant for this. In a time line you specify which actions must<br />

happen at certain moments in time. You can use all the actions that are also available for the<br />

different events. Once you create a time line you can assign it to an instance of an object. This<br />

instance will then execute the actions at the indicated moments of time. Let us explain this<br />

<strong>with</strong> an example. Assume you want to make a guard. This guard should move 20 time steps to<br />

the left, then 10 upwards, 20 to the right, 10 downwards and then stop. To achieve this you<br />

make a time line where you start <strong>with</strong> setting a motion to the left. At moment 20 you set a<br />

motion upward, at moment 30 a motion to the right, at moment 50 a motion downwards and<br />

at moment 60 you stop the motion. Now you can assign this time line to the guard and the<br />

guard will do exactly what you planned. You can also use a time line to control your game<br />

more globally. Create an invisible controller object, create a time line that at certain moments<br />

creates enemies, and assign it to the controller object. If you start to work <strong>with</strong> it you will find<br />

out it is a very powerful concept.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!