Game Development Reference
In-Depth Information
Spiky Fright
Spikes are by far the simplest of the hazards, so we will begin by creating these and making Zool
react appropriately when he collides with them.
Creating Spike Hazards
1. Begin by creating a new object in the Misc group called obj_controller . You might
recognize this kind of object from The Game Maker's Apprentice . It is used to carry out
behaviors that affect the whole game.
2. Include a Create event with a Set Variable action ( control tab) that sets the Variable
global.step_count to 0 .
3. Include a Step, Step event with a Set Variable action that sets the Variable
global.step_count Relative to 1 . This creates a global counter that records the number
of steps performed in the game so far. This will prove useful later on.
4. Reopen obj_zool and select the Create event. Delete the first Set Variable action that
sets step_count to 0 . The Zool object had its own step count, but we would rather use
the global one from now on.
5. Likewise, select the Step event of obj_zool and delete the corresponding Set Variable
action that sets step_count Relative to 1 .
6. Reopen obj_zool_land and select the End Step event. Edit the Test Variable action that
checks if step_count mod 8 is equal to 0 . Change Variable to global.step_count mod 8 .
This now ties in the Zool object to our global step count instead.
7. Right-click on the Hazards group within the object resources and select Create Object
from the menu. You should create all the enemies and hazards within this group to
keep them organized. Call this one obj_hazard and close it again. This will be the
parent object for all hazards in the game.
8. Create a new object called obj_spike_left and give it the spr_spike_left sprite. Set its
parent to be obj_hazard and then close it. It does not need any actions.
9. Repeat the previous step to create two more spike objects called obj_spike_right and
obj_spike_up using the appropriate sprites.
10. Reopen obj_zool and select the Create event.
11. Directly above the final Change Instance action, include a Set Variable action ( control
tab) that sets the Variable hurt to false . We will use this to keep track of when Zool
gets hurt by a hazard and make him invulnerable to being hurt again for a short period
of time.
12. Add a Collision event with obj_hazard and include a Test Variable action that checks if
the Variable hurt is equal to false . In other words, the following events will only take
place if Zool is not already hurt.
13. Immediately follow this with a Start Block action. This following block of actions will
make Zool jump up and back from a hazard when he collides with it.
 
Search WWH ::




Custom Search