The_Official_Raspberry_Pi_-_Beginner’s_Book_Vol1,_2018 (1)

(singke) #1

(^88) THE OFFICIAL RASPBERRY PI BEGINNER'S GUIDE
Below your when I receive new arrow block, add a go to x: -150 y: -150 block and a
set size to 400 % block. Remember that these aren’t the default values for those blocks, so
you’ll need to change them once you’ve dragged them onto the scripts area. Click on the green
flag to see what you’ve done so far: the arrow sprite, which the player uses to aim at the target,
will jump to the bottom-left of the stage and quadruple in size.
when clicked
broadcast new arrow
when Ireceive new arrow
gotox: -150 y: -150
set sizeto^400 %
To give the player a challenge, add movement simulating swaying as the bow is drawn
and the archer takes aim. Drag a forever block, followed by a glide 1 secs to x: -150 y: -150
block. Edit the first white box to say ‘0.5’ instead of ‘1,’ then put a pick random -150 to 150
Operators block in each of the other two white boxes. This means the arrow will drift around
the stage in a random direction, for a random distance – making it far harder to hit the target!
when clicked
broadcast new arrow
whenIreceive new arrow
gotox: -150y: -150
setsizeto^400 %
forever
glide0.5secstox: pickrandom -150 to^150 y: pickrandom -150to^150
Click the green flag again, and you’ll see what that block does: your arrow sprite is now
drifting around the stage, covering different parts of the target. At the moment, though, you
have no way to loose the arrow at the target. Drag a when space key pressed block into your
scripts area, followed by a stop all Control block. Click the down arrow at the end of the block
and change it to a stop other scripts in sprite block.

Free download pdf