Game Development Reference
In-Depth Information
As a final step in this project, let's make the enemies an actual threat to the player. When an
enemy touches the player sprite, it should be
game over
for the player. Now that we have
created all enemies, we can easily check for collisions with them.
1. Go to the
Scripts
tab of the diver sprite.
2. We replace the
forever
block with a
repeat unil ()
condiion block. But make
sure to set aside the keyboard control script for reuse.
3. In the condiion slot, we check whether the diver is touching any of the starish
sprites. This requires two
or
operators, so we have three condiion slots; one for
each sprite.
4. Reset the keyboard controls inside the
repeat
loop.
5. To inish of, when the condiion is met, this script should stop all scripts by using
the
stop <all>
block.
When a starish touches the diver, the game will freeze immediately by efecively ending
the game.
Objective complete - mini debriefing
We now have three similar yet disinct enemies to challenge the player. Run the game with
the
<green lag>
buton to see all of them go at once.
This project shows that a few simple changes can have big results for your game. It's often
not necessary to invent a completely new script for each sprite. Clever copying and reusing
of what you already made can save you a lot of ime.