Game Development Reference
In-Depth Information
7.
Reopen
obj_zool_land
and select the
Create
event. At the start of the actions list,
include a
Test Variable
action (
control
tab) that tests if the
Variable
state
is
NOT
equal to
ZSTATE_SLIP
. We're going to include a sound effect for landing on the ground
here, but we don't want it to be played if Zool has slid into the land state rather than
fallen into it.
8.
Immediately follow this with a
Play Sound
action (
main1
tab) to play the
Sound
snd_land
with
Loop
set to
false
.
9.
Select the
Key Press, Space
event and include a
Play Sound
action to play the
Sound
snd_jump
with
Loop
set to
false
.
10.
Select the
End Step
event. At the start of the list of actions, include a
Test Variable
action (
control
tab) that checks if the
Variable
state
is
equal to
ZSTATE_WALK
.
11.
Follow this with a
Start Block
action and place the following actions within that block.
12.
Include a
Test Variable
action that checks if the
Variable
step_count
mod
8
is
equal to
0
.
The
mod
operator takes the value on its left, divides it by the number on the right, and
returns the remainder. So
10
mod
8
equals 2 because 10 divided by 8 is 1 with 2 left over.
Likewise
18
mod
8
,
26
mod
8
, and
2
mod
8
are all equal to 2 because their remainders are all
2 as well. So using
step_count
mod
8
means that the remainder will increase by one each
frame, until it reaches 8 and then it will go back down to 0. It will only be equal to 0
once every 8 frames, so the following action to play a footstep sound effect will only be
executed once every 8 frames—that's all we're trying to do here.
13.
Immediately follow this with a
Play Sound
action (
main1
tab) to play the
Sound
snd_footstep
with
Loop
set to
false
.
14.
Include an
End Block
action (
control
tab). There should now be 16 actions in the
End
Step
event of
obj_zool_land
, as shown in Figure 4-20.
15.
Reopen
obj_zool_wall
and select the
Create
event. Include a
Play Sound
action
(
main1
tab) to play the
Sound
snd_grab
with
Loop
set to
false
.
16.
Now select the
Keyboard, Up
event. We're going to add a sound effect for when Zool
automatically leaps up from the top of a wall. This needs to be included within the
second block of actions: directly before the
Change Instance
action will do. Include a
Play Sound
action here to play the
Sound
snd_hiya
with
Loop
set to
false
.
Now that the easy ones are out of the way, run the game and see what difference it already
makes to the way the game feels to play. Next, we're going to add a skidding state and sound
effect to go with it. It will make no difference to the actual movement handling, but will add a
significant amount of “cool” factor to running about the level.
Search WWH ::
Custom Search