The_Official_Raspberry_Pi_-_Beginner’s_Book_Vol1,_2018 (1)

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

THE OFFICIAL RASPBERRY PI BEGINNER’S GUIDE


left-hand side of the window, then the ‘Downloads’ folder, and click on ArcheryResources.sb2
followed by the Open button. You’ll be asked if you want to replace the contents of your current
project: if you haven’t saved your changes, click Cancel and save them, otherwise click OK.


5 Figure 4-21: Resources project loaded for the archery game


The project you’ve just loaded contains a backdrop and a sprite (Figure 4-21), but
none of the actual code to make a game: adding that in is your job. Start by adding a
when clicked block, then a broadcast message1 block. Click on the down arrow at
the end of the block and then ‘New Message’, and type in ‘new arrow’ before clicking the OK
button. Your block now reads broadcast new arrow.


when clicked


broadcast new arrow


A broadcast is a message from one part of your program which can be received by any other
part of your program. To have it actually do something, add a when I receive message1 block,
and again change it to read when I receive new arrow. This time you can just click on the down
arrow and choose ‘new arrow’ from the list; you don’t have to create the message again.

Free download pdf