Game Development Reference
In-Depth Information
The steps to build the shooing code are as follows:
1. Start with the
when <space> key pressed
block.
2. To prevent the game from hanging up when the user hits the Space bar too many
imes, we will add a imeout between each round of iring. Let's wait for
0.05
seconds by using the
wait () secs
block.
3. Now add the code to fire the ammo by using
create clone of <Spaceship Ammo>
.
Note that we sill cannot shoot the Spaceship Ammo. This is not possible unil we
add the scripts to the Spaceship Ammo sprite later in the project.
The finished script should look like the following screenshot:
For the sake of game responsiveness, the Spaceship sprite does not coninue to check
whether it has collided with the enemy sprites or their ammo. Instead, the checking is
done by the enemy sprites and their ammo. When noiied, the Spaceship reacts to the
collision by simply changing its costume.
The steps to build the script are as follows:
1. Start with the
when I receive <ship_collided>
block.
2. Then, use the
switch costume to <hit>
block.
3. Wait for
0.5
seconds for the user to see the Spaceship explode (using the
wait () secs
block).
The following screenshot shows the final script:
The Spaceship sprite terminates when it receives the
game_over
message.
The steps to write the code are as follows:
1.
Start with the
when I received <game_over>
block.
2.
Then, add the
hide
block.
3.
Finally, add the
stop all
block.