Game Development Reference
In-Depth Information
Test the game briefly to see whether the spear behaves as we expect it to. The spear should
start from the player posiion and then move in a straight line to the right unil it reaches
the edge and is removed.
We can hold down the Space bar, but because of the wait block placed after the clone block,
a spear will only be created after every 0.5 seconds.
Now to make the enemies respond to being hit by the spears, we make an addiion to
their script. This addiion should be placed inside the repeat unil () block of the when
I start as a clone script since we will want to constantly check for a hit as long as the
enemy clone is around.
1. We add an if () then condiion.
2. We will check whether an enemy clone is touching the spear by using the
touching <Spear> block.
3.
If that is the case, then we will delete this clone immediately by using the
delete this clone block.
4.
This script is same for all the three enemy types, so we will add it to all the three
enemy clone scripts. Remember that you can drag-and-drop a piece of script on a
sprite to copy it.
The following screenshot shows the final script:
Objective complete - mini debriefing
When we try the game again, the enemies can now be destroyed by the spears.
Creating background images
To create a beter sense of movement, we will make a scrolling background. This requires
two idenical background images that will be sliding horizontally across the stage. As we
want to move these backgrounds around, we won't be creaing them as actual background
images but as sprites instead. Sprites can be moved with scripts, while background images
cannot be moved.
 
Search WWH ::




Custom Search