Game Development Reference
In-Depth Information
13.
Now, edit the
Keyboard, Down
event of
obj_flynn_wall
. Again, we will just provide
the result of the changes required:
1:
{
2:
if( state == FSTATE_CLIMB_TOP )
3:
exit;
4:
5:
if( is_climbable( facing, 3 ) == true )
6:
{
7:
vspeed = 3;
8:
image_speed = -1;
9:
state = FSTATE_CLIMB;
10:
}
11:
else
12:
{
13:
instance_change( obj_flynn_air, true );
14:
}
15:
}
This event also exits without doing anything if Flynn is already in the climbing-on-top
state because aborting the animation half-way to climb down again would look odd.
Lines 5-10 cope with checking and moving downward from Flynn's current
position. However, note that
image_speed
is set to
-1
to make the animation play
backward when Flynn is climbing down, as this looks much more realistic.
Finally, line 13 makes Flynn fall down if he has reached the bottom of a wall and
there is nothing more to hold on to.
14.
Now, add an
Other,
Animation End
event to
obj_flynn_wall
and include an
Execute
Code
action that contains the following code:
1:
{
2:
if( state == FSTATE_CLIMB_TOP )
3:
{
4:
x += facing*60;
5:
y -= 130;
6:
move_on_top_of( 10, obj_solid );
7:
instance_change( obj_flynn_land, true );
8:
}
9:
}
Remember that despite appearances, Flynn's
x
and
y
position is actually still on the
side of the wall. So this event will trigger on the final subimage of the animation,
teleporting Flynn into a new position that matches the final frame of the animation. It
actually moves up a few more pixels than should be necessary in line 5 and then places
Flynn back on the surface of the new platform on line 6. This is because Flynn's
y
position relative to the top of the wall can vary a little according to where he started
climbing from and the speed at which he is moving up it.
Search WWH ::
Custom Search