Game Development Reference
In-Depth Information
4.
Include a
Set Friction
action that sets
Friction
to
0
. Friction is not good either.
5.
Include a
Move Fixed
action with the middle
Directions
button selected and a
Speed
of
0
. This time we actually do want Zool to stop as soon as he grabs a wall.
6.
Add a
Step, Begin Step
event and include a
Set Variable
action (
control
tab) with
Variable
set to
state
and
Value
set to
ZSTATE_CLING
. The default state will be clinging,
but this will get overridden in the keyboard events if the player is moving up or down.
7.
Include a
Speed Vertical
action (
move
tab) with
Vert.
Speed
set to
0
. In doing so, we
will default the speed to zero as well.
8.
Add a
Keyboard, Up
event and include a
Check Object
action (
control
tab) that checks
for the
obj_wall
Object
at the
Relative
position
X
=
facing
,
Y
=
-4
. This is where the
facing variable comes in particularly useful, as
facing
will be -1 if Zool is facing left and
+1 if Zool is facing right. So this makes it easy to detect if Zool is facing a wall. We are
checking 4 pixels above because the climbing speed will be 4 pixels per step, so we
need to check that there will still be a wall facing Zool at the position we want to move
him to.
9.
Include a
Start Block
action.
10.
Include a
Speed Vertical
action (
move
tab) with
Vert. Speed
set to
-4
.
11.
Include a
Set Variable
action (
control
tab) with
Variable
set to
state
and
Value
set to
ZSTATE_CLIMB
.
12.
Include an
End Block
action. The
Keyboard, Up
event should now have the five
actions shown in Figure 4-8.
13.
Repeat steps 8-12 in order to create a
Keyboard, Down
event that checks that there will
be a wall facing Zool 4 pixels below him, before setting his
Vertical Speed
to
4
and his
state
to
ZSTATE_CLIMB
.
Search WWH ::
Custom Search