Game Development Reference
In-Depth Information
the same issues. This ability to change animations means that the game-logic can drive the
animations. Unfortunately, this isn't an option for games like ours that use pre-rendered sprites,
so one alternative is to make the animations drive the game logic instead.
In this section, we're going to revert to a step-by-step approach, so make sure you have an
unaltered version of
shadows1.gmk
from the
Chapter12/Games
directory open and ready to go.
We're going to change the way that Flynn moves and animates, replacing the friction and
a cce l e r a ti on a ppr oa ch use d for
Zool
with a constant movement speed that is driven by the
animations (a little like
Fishpod
). We'll also provide a less ninja-like way of climbing up onto
the top of platforms, and introduce the double-jump feature, so be prepared for a bit of typing.
Best Foot Forward
The most significant way that the animations will be made to drive the game logic is in the
walking mechanic. We're going to replace the friction and acceleration approach used for
Zool
with a constant movement speed. To prevent Flynn's feet from sliding, his movement speed
needs to accurately match the frames in his animation. Changing his movement speed over
time would make that even harder. We'll also only stop his speed in an
Animation End
event,
which is what makes his movement dependant on the animation. We've made sure the
animation is fairly short (so it only includes a single step), but it still means Flynn can only
move fixed distances at a time. Nonetheless, bear in mind that the final levels that Flynn will
navigate will be far more open and spacious than the one we're using at the moment, and there
won't be pixel-perfect jumps to make, so it shouldn't impact the game play too severely.
Adjusting Flynn's Walking Mechanic
Reopen
obj_flynn_land
and edit the code of the
Create
event. Set the friction to
0
rather than
1
and include a line that sets
hspeed
to
0
as well. Unlike for
Zool
(where we
didn't want jumping to break his stride), we want
Shadows on Deck
to be a more
thoughtfully paced platform game, so coming to a halt between states is actually
desirable this time.
1.
2.
Select the
Begin Step
event and have a quick peek at its code. All it did was to default
the state to the standing state. We no longer need to do this, as Flynn should remain in
the walking state until the end of an animation cycle. Therefore, you can delete the
Begin Step
event entirely from the
obj_flynn_land
object.
Figure 12-1.
Looking at Flynn's walking animation in the Sprite Editor, we can see that his foot touches the
ground in subimage 7
Search WWH ::
Custom Search