Game Development Reference
In-Depth Information
23.
Add an
Alarm, Alarm 0
event and include a
Set Variable
action that sets the
Variable
hurt
to
false
. This alarm event will end Zool's period of invulnerability after three
seconds, as that's what it was set to previously.
24.
Reopen the
Draw
event and include a
Test Variable
action at the start of the list of
actions. Use it to check whether the
hurt
Variable
is
equal to
true
.
25.
Follow this with another
Test Variable
action with
Variable
set to
global.step_count
mod
6
,
Value
set to
0
,
and
Operation
set to
equal to
. Recall that the
mod
operator divides the left
value by the right value, and then provides the remainder. In other words, this will provide
a number from zero to five based on the global step counter that increases by one every
step. That means this condition will fire once every six steps.
26.
Immediately follow this with an
Exit Event
action. So Zool's sprite will periodically not
be drawn if he is hurt—making his sprite flash on and off in a way that is often used to
represent invulnerability in games.
Now return to the room editor and add a range of spikes in interesting places around the
level (it's usually best to hide the tiles again while you're doing this). You'll also need to add an
instance of
obj_controller
to the room. Play the game and check that it all works as intended
because we're going to tackle some more animated hazards next.
Bitter Sweets
Computer-controlled opponents often play a big part in the challenge of a video game, and we'll
be tackling these next. So what makes a good computer opponent? This might be the kind of
question that fires your imagination with thoughts of advanced artificial intelligence (AI) and
team-based tactics. Okay, let's imagine for a moment that all the computer opponents in Zool
had AI that allowed them to work together in order to stop the player from reaching the objective
(the exit). Would that create a fun game to play? It might be entertaining to find yourself suddenly
ambushed in all directions by 50 opponents the first time around, but it would quickly lose its
charm!
The reality of AI in games is that, more often than not, artificial stupidity is a more
appropriate term. A “good” opponent is often one that is predictable and has a clear vulnerability
for the player to exploit. Remember that the player is not your opponent, and a good game
balances a theatrical threat of failure with a true desire to assist the player in their mastery of the
game. So the minions of Krool we're about to implement may not be blessed with great
intelligence, but that's exactly the way we like them.
Jelly and I Scream
The first, and simplest, of Krool's dimwitted automatons is the Jelly. This blob-like creature
roams slowly back and forth regardless of Zool's approach, and can only hurt the player if he is
clumsy enough to bump into him.
Creating the Jelly Enemy
1.
Create three new objects called
obj_enemy
,
obj_enemy_die
and
obj_splat
(all in the
Hazards
group). Give
obj_splat
the
spr_splat
sprite and give all three a
Depth
of
-1001
so that they appear in front of all of the scenery. The other two don't need a sprite, as
one will just be a parent object and the second a general-purpose object used for dying
enemies (and its sprite will change).
2.
Reopen
obj_enemy
and
add a
Destroy
event. Include a
Play Sound
action (
main1
tab)
to play
snd_enemy_die
.
Search WWH ::
Custom Search