Game Development Reference
In-Depth Information
Play the game again and see what you think. It works, but it doesn't provide that much
control in the air—particularly when changing direction. Being able to change direction mid-
flight in order avoid an inevitable collision is actually one of the most important reasons to have
drifting. We could increase all the speeds, but this provides a bit too much control (try it if you
like). So, instead we will reset the horizontal speed to zero whenever Zool changes direction in
the air. This will give him the ability to do an instant about-turn to avoid a moving enemy, but not
fly around the level like Superman.
Tweaking the Drifting Mechanic for the Zool Air State Object
1. Select the Keyboard, Left event for the obj_zool_air object and include a Test Variable
action ( control tab) at the start of the actions that checks if the Variable hspeed is
larger than the Value 0 .
2. Follow this with a Speed Horizontal action ( move tab) with Hor. Speed set to 0 . You
should now have five actions in the Keyboard, Left event that look like Figure 4-6.
3. Select the Keyboard, Right event and include a Test Variable action ( control tab) at the
start of the actions that checks if the Variable hspeed is smaller than the Value 0 .
4. Follow this with a Speed Horizontal action ( move tab) with Hor. Speed set to 0 .
Play the game one more time and hopefully you'll agree that we now have reasonably
polished walking and jumping mechanics. We've also already gone half way to solving our bug, as
the drifting controls now allow you to get out of the situation where Zool was stuck. You will find
this version of the game in the file Zool3.gmk in the Chapter04/Games directory on the CD.
Figure 4-6. The sequence of events for the Keyboard, Left event of the Zool air state object
 
Search WWH ::




Custom Search