Game Development Reference
In-Depth Information
The modified spear is now ready for duty.
Engage thrusters
We will allow the player to ire a spear from the diver's posiion when pressing the
Space bar. When the spear hits an enemy, the enemy will be removed immediately
(and possibly the player will earn a point). But we will work on that later.
1. Switch to the
Scripts
tab and start a new script with a
when <green lag>
clicked
block.
2. We will use the cloning technique, so let's first click on
hide
to hide the spear.
3. We also set the size to
30%
in the
set size to ()%
block to make it to scale with the
diver and starfish.
4. Next, we add a
forever
loop that will contain the cloning process.
5. Inside the loop, we add a
go to <Diver2>
block so that the spear sprite will always
follow the diver sprite.
6. We also enter the value
90
in the
point in direcion ()
block to make the spear
always face right.
7. We add an
if () then
condiion to check for player input.
8. We will check when the key is pressed using the
key <space> pressed?
block.