Game Development Reference
In-Depth Information
14. Include a Test Variable action that sets Variable to abs(hspeed) , Value to 1 , and
Operation to larger than . Colliding with a hazard should make Zool jump back
diagonally, unless he falls straight down onto it (when a vertical jump would make
more sense). The abs() function returns the “absolute” value (or magnitude) of the
variable, turning any negative numbers into positive ones. That means that the next
action will trigger if Zool is moving horizontally (left or right) faster than 1 pixel per
step.
15. Include a Speed Horizontal action ( move tab) that sets Hor. Speed to -facing*4 . This
will make Zool's horizontal speed four times as large, but in the opposite direction.
16. Next, include a Speed Vertical action that sets Vert. Speed to -18 (upward). This is not
part of the previous condition, so the vertical jump will take place regardless of Zool's
horizontal speed.
17. Include a Play Sound action ( main1 tab) that plays snd_hurt . From now on, we'll
include sound effects as we go along.
18. Include a Set Variable action ( control tab) that sets the Variable hurt to true .
19. Include a Set Alarm action ( main2 tab) that sets Alarm 0 to 90 steps (3 seconds).
20. Include a Set Health action ( score tab) that takes 1 off the health Value ( Relative to -1 ).
21. Include a Change Instance ( main1 tab) action that changes to obj_zool_air with
Perform events .
22. Follow this with an End Block action ( control tab). There should now be 11 actions for
the Collision event with obj_hazard that look like Figure 5-3.
Figure 5-3. The obj_zool Collision event with obj_hazard
 
Search WWH ::




Custom Search