The_Official_Raspberry_Pi_-_Beginner’s_Book_Vol1,_2018 (1)

(singke) #1
Chapter 4 Programming with Scratch^91

THE OFFICIAL RASPBERRY PI BEGINNER’S GUIDE


So that the player knows they have scored, add a play sound cheer block and a
say 200 points for 2 secs block inside the if then block. Finally, add a broadcast new arrow
block to the very bottom of the block stack, below and outside the if then block, to give the
player another arrow each time they fire one. Click the green flag to start your game, and try
to hit the yellow bull’s-eye: when you do, you’ll be rewarded with a cheer from the crowd and a
200-point score!


when clicked
broadcast new arrow

whenIreceive new arrow
gotox: -150y: -150
setsizeto 400 %
forever
glide pickrandom -150to^150 y: pickrandom -150 to^150

when space keypressed
stop other scripts in sprite
repeat^50
changesizeby -10

if touching color then
playsound cheer
say 200 pointsfor^2 secs

broadcast new arrow

0.5secstox:

The game works, but is a little challenging. Using what you’ve learnt in this chapter, try extending
it to add scores for hitting parts of the target other than the bull’s-eye: 100 points for red, 50 points
for blue, and so on.


For more Scratch
projects to try, see
Appendix D:
Further reading

CHALLENGE: CAN YOU IMPROVE IT?
How would you make the game easier? How would you
make it more difficult? Can you use variables to have the
player’s score increase as they fire more arrows? Can you
add a countdown timer to put more pressure on the player?
Free download pdf