Hardware Reference
In-Depth Information
FIGURE 3-24
Health-point-stealing flower sprite script
Don't forget to add the script to hide the lower sprite after the Adventurer sprite
enters the cave. After you have added this script, you can duplicate the lower
to cover the stage with more obstacles, making the game more interesting.
To duplicate the lower sprite, right-click on it in the Sprites palette and click
Duplicate. You can do this as many times as you like to make multiple copies.
Improving the Movement of the
Adventurer Sprite Using “if” Blocks
he player controls the Adventurer sprite by using the keys on the keyboard. his
works well when the sprite is on the stage using the
Outside
background, as there are
no walls. However, when it enters the cave, the sprite will appear to be walking over
the walls. You can use another
if
condition to help stop this from happening.
1.
Click the Adventurer sprite and locate the four scripts that control movement
using the arrow keys on the keyboard (refer to Figure 3-17).
2.
On one of the scripts, add a control block
if
inside the
forever if
loop, above
the
point in direction 90
block that is already there.
3.
Add the sensing block
touching color
into the blank hexagon on the
if
loop
you have just added. Select the colour of the walls by clicking the coloured square
box; this action will turn the mouse cursor icon into a droplet icon, and you can
select the walls with your mouse, getting the exact colour match required.
4.
Next, add the motion block
move 0 steps
inside the
if
loop and set the value
to -20 steps. Figure 3-25 shows the new script.
5.
Add the same extra piece of script to the three remaining control scripts for each
key. Don't forget to save the ile and test that your script works.