Game Development Reference
In-Depth Information
14. Add a Collision event with obj_ramp and include a Set Variable action ( control tab)
that sets the Variable y Relative to -2 (that is, moves it up a little).
15. Include an Execute Script action that sets Script to move_to_contact_with , Argument0
to 270 , Argument1 to -1 , and Argument2 to obj_solid . Together with the previous
action, this will move the Jelly up when climbing slopes.
So you now have your first enemy to obstruct Zool from completing his objective. Place a few
more around the level and make sure that they cope with ramps correctly and that you can
control their movement using the limiters. If in doubt, you can check your version against the file
zool9.gmk from the Chapter05/Games directory on the CD.
Note We're going to take you through the implementation of two more enemies in this chapter: the
Sweet Beastie and the Bee. However, there is nothing particularly new to learn here, so if you find yourself
suffering from drag-and-drop fatigue, then it probably won't hurt to just read through the steps and then
load zool10.gmk for the completed Beastie and zool11.gmk for the completed Bee.
Beastly Licorice
Next on our list of enemies is the Sweet Beastie. According to the Zool manual, these are “ the
meanest critters you will come across in the Sweet World. They not only get in your way, but launch
a whole load of projectiles at you at any given opportunity. ” This will be a more complicated
enemy that can face both left and right, so we will take a different approach from the Jelly and use
a state machine to control its different behaviors (see Figure 5-6). Nonetheless, it is a fairly basic
state machine, so we will only use a single object and handle all the states using a state variable.
This enemy simply wanders back and forth along platforms like the Jelly, but occasionally stops
in his tracks and shoots projectiles at Zool. In order to make him seem a little more “intelligent,”
we will only make him shoot when Zool is close by:
Figure 5-6. The Beastie state machine diagram
 
Search WWH ::




Custom Search