Game Development Reference
In-Depth Information
During the play, these sprites process four broadcast messages:
shield_hit
,
shield_destroyed
,
life_power_up
, and
level_up
.
The following steps build the required scripts:
1. The first script starts with
when I receive <shield_hit>
and
change num_shield_hit
by ()
with the value
1
. Then, add
switch costume to (<num_shield_hit>+())
with
the value
1
. Add an
if () then
condiion block. Check whether the number of hits
the shield has taken is greater than the number of maximum hits it can, by using
the
<num_shield_hit> is greater than <num_max_hits> - 1
block, and then add the
broadcast <shield_destroyed>
block.
2.
The last script starts with
when I receive <life_power_up>
, restore the power grid
and add
set <num_shield_hit> to ()
with the value
0
. Then, update the look using
switch costume to <0 hit>
and
show
.
The finished script will look like the following screenshot:
Objective complete - mini debriefing
We added scripts to the Shield and Shield Life sprites. The Shield sprite makes the game
more dynamic and interesing, whereas the Shield Life sprite displays the life staisics
visually and in a more lively manner.