Game Development Reference
In-Depth Information
20. Add a Key Release, Down event and include a Set Friction action ( move tab) to set
Friction to 1 . This event restores the standard settings when the player releases the
skid.
21. Include a Set Variable action ( control tab) that sets state to ZSTATE_STAND .
22. Include a Set Variable action that sets hspeed to 0 .
23. Include a Set Variable action that sets attacking to false .
24. Select the Keyboard, Left event and include a Test Variable action at the start of the
actions list that tests if state is NOT equal to ZSTATE_KICK . We don't want the player to
be able to walk and kick at the same time.
25. Immediately follow this with a Start Block action.
26. Include an End Block action at the end of the actions list for this event.
27. Repeat steps 24-26 for the Keyboard, Right event.
And now you can slide your way through multiple enemies at once. You can actually kill
enemies both in front of and behind the skidding Zool (if they walk into you from behind, for
example). You could fix this by making some additional tests, but we're choosing to put that
down to the remarkable abilities of an inter-dimensional ninja.
Top Spinning
The cover artwork for Zool typically depicted him wielding some kind of glowing ninja swords in
each hand as he kicked his way through the front of the box. These swords actually only seem to
make an appearance in the spinning attack move, but it's pretty cool so we'll handle that next.
While he's spinning, Zool will demolish any enemy in his path, so it is a very advisable way to
travel. In fact, some versions of the game seemed to make Zool spin by default every time he
jumped. We're not going to do that, but we will make it possible for him to spin by holding either
the up or down arrow keys during a jump. This is actually quite intuitive and can work
particularly well with the down arrow key if you want to move straight into a slide kick at the end
of a spinning jump.
Adding Spinning Attack Behavior to Zool
1. Reopen obj_zool_air and change the Sprite to spr_zool_spin_right . It is not
immediately obvious why this is necessary, so we'll explain.
Game Maker automatically handles the animation of sprites based on the current sprite. It
cycles through all the frames of animation and then returns back to the first subimage again
when it reaches the end. You can easily set the current sprite using the sprite_index variable or
through a Change Sprite action, but actually we never do this for the Zool objects in our game.
Instead, we chose to use the Draw event of obj_zool to draw the correct sprite for ourselves.
Nonetheless, Game Maker still updates the animation frame according to the number of
subimages in the default sprite ( spr_zool_jump_right ), but this only had one subimage—so it
never actually changes. In order to make sure that the spinning sprite (which has four subimages)
can animate properly, we need to use this as the default sprite instead. Try setting the sprite back
to spr_zool_jump_right at the end of this sequence of steps if you need to prove it to yourself.
 
Search WWH ::




Custom Search