The_Official_Raspberry_Pi_-_Beginner’s_Book_Vol1,_2018 (1)

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

THE OFFICIAL RASPBERRY PI BEGINNER’S GUIDE


Click on the green flag. At first, the program will work as before with the cat sprite counting
upwards from zero. When the number reaches 6, the first number which is greater than 5, the
if then block will begin to trigger and the cat sprite will comment on how high the numbers
are getting (Figure 4-9). Congratulations: you can now work with variables and conditionals!


5 Figure 4-9: The cat makes a comment when the number reaches 6


Project 1: Astronaut Reaction Timer
Now you understand how Scratch works, it’s time to make something a little more interactive:
a reaction timer, designed to honour British ESA astronaut Tim Peake and his time aboard the
International Space Station.


Save your existing program, if you want to keep it, then open a new project by clicking on
File and New. Before you begin, give it a name by clicking on File and Save Project: call it
‘Astronaut Reaction Timer’.


CHALLENGE: HIGH AND LOW
How could you change the program so the cat sprite
comments on how low the numbers below 5 are
instead? Can you change it so that the cat will comment
on both high and low numbers? Experiment with the
if then else block to make this easier!

ONLINE PROJECT
This project is also available online at rpf.io/astronaut-game
Free download pdf