Game Development Reference
In-Depth Information
15. Finally, edit the Create events of obj_flynn_land and obj_flynn_dead and include an
extra line in each that sets image_speed to 1 . We've been setting this to -1 in
obj_flynn_wall to make animations play backward, but we wouldn't want this to affect
any other states, so this will make sure it is back to normal for other objects. The
obj_flynn_land and obj_flynn_ice objects already handle this for themselves so
there's no need to add anything for them.
And that's it for climbing. If you try out the game now, then you should find that Flynn
navigates around the test level quite convincingly now—despite it being a less-than-
appropriate level design for a larger character like this. If you have any problems with your
version, then compare it to the file shadows2.gmk in the Chapter12/Games directory on the CD.
One thing you will notice is that the screen position jumps at the end of the climbing on top
animation when Flynn is moved on top of the platform. Don't worry about that for the moment,
as we'll be fixing that later by adding our own code to control the view position.
Jump High, Fall Hard
The double jump is a key part of the design for Shadows on Deck . It will give Flynn the ability to
n i mbl y a v oi d hi s e n e mi e s a s we l l a s he l p hi m to n a v i g a te the mor e pr e ca r i ous he i g hts of the
level. It will be especially useful to be able to make a second leap in mid-air, as the result of
Flynn falling too far to the ground will be instant death (followed by a convenient restart, of
course). We will therefore consider both the double jump and death by falling next.
Adjusting Flynn's Jumping Mechanic
1.
We'll begin by creating four new constants. We need two new states: FSTATE_BEND set to
a value of 8 and FSTATE_RECOVER set to 9 , as well as two constants for controlling how far
Flynn can fall before he dies: FALL_DIST_RECOVER set to 300 and FALL_DIST_FATAL set to
600 . Also, rename the constant SKID_SPEED to JUMP_SPEED with a new value of -33 and
create a new constant called DRIFT_ACCEL (acceleration) with a value of 3 .
Create a new sprite resource called spr_flynn_bend_right using the appropriate file
from the Chapter12/Resources/Sprites/Flynn directory on the CD. Modify its mask to
use a Rectangle Shape and Manual Bounding Box set to Left = 48 , Right = 80 , Top = 32 ,
and Bottom = 186 and Center its Origin .
2.
Duplicate spr_flynn_bend_right to create a new sprite called spr_flynn_bend_left .
Click on Edit Sprite and use the Transform menu to Mirror/Flip the sprite horizontally
with the Apply to all images in sprite option checked (see Figure 12-4). This saves you
having to load and set up the collision mask of the opposite facing sprite.
3.
 
Search WWH ::




Custom Search