On 15 December 2015, British astronaut Tim Peake set off on the Principia mission to the International Space Station which is in orbit around Earth. Tim set up Astro Pi computers running children’s code on the Space Station. This project was created for Tim’s mission. Tim returned safely to Earth on 18 June 2016.
You are going to create your own space quiz using interesting space facts.
Try the Quiz: Before you begin this project, have a go at the Space Quiz. If you are viewing this project online then you can try the project below. If you have a printed copy then you can go to: jumpto.cc/space-quiz to try it.
Hint: If you don’t know the answers then read the Introduction to this project!
Step 1: Add a Quiz Question
Let’s create your first space quiz question.
Open the ‘Space Quiz’ Scratch project. Your club leader will give you a copy of this project, or you can open it online at jumpto.cc/space-quiz-resources.
Your project should look like this:
Click on your ‘Alien’ sprite, and add the following code to ask the first question:
when gf clicked ask [Which planet does the International Space Station orbit?] and wait
Now you need to check the answer. An
if/elseblock allows you to do something different depending on whether the question is answered correctly or not.
Add the following code after the
if <(answer) = [Earth]> then say [Yes!] for (2) secs else say [Sorry, that's not right.] for (2) secs
Click the green flag to test your quiz question. Make sure you try the correct answer and an incorrect one.
Save your project
Step 2: Add a Score
Let’s add a score that goes up by one point when you get a question correct.
A variable is a place to store data. Let’s create a variable to store the score.
Dataand then click ‘Make a Variable’. Call this variable
The score variable will be displayed on the stage.
You will need to set the score to zero at the beginning of the quiz.
setblock to your Alien’s code:
When a question is answered correctly you need to increase the score.
changeblock to your quiz question:
And let’s have the Alien say the score at the end.
sayblock at the end of the Alien’s code:
You want the Alien to say “You scored:” followed by the score. To do this, firstly add a
joinblock into your Alien’s
sayblock and type “You scored:” (without the quotes, but with a space at the end.) in the first box of the
Now drag the
Datainto the second box of the
Now click the green flag and test your code. Make sure that the score goes up when you get the question correct and stays the same when you get it incorrect.
Save your project
Challenge: Add two more questions
Can you add these two questions to your quiz:
Question: Which British astronaut joined the International Space Station in 2015? Answer: Tim Peake
Question: Which computer ran children’s code on the International Space Station? Answer: Astro Pi
To save yourself some work you can duplicate the quiz question code you already have by right-clicking on the first block that you want to copy and selecting ‘duplicate’:
You don’t want to duplicate the
say block that shows the score so just drag that away before you duplicate and add it back in at the end after all of your questions.
You’ll need to change the question and the answer in the duplicated code for each new question.
Save your project
Step 3: Making the Spaceship Move
Next you’re going to make the spaceship move towards the planet and play a sound every time you get a question correct.
In Scratch you can broadcast a message to let other sprites know that something has happened. Let’s broadcast a message when you answer a quiz question correctly.
broadcastblock after the
changeblock where you increase the score in the first quiz question. Click on the down arrow and choose ‘new message’ and call the new message ‘correct’:
Also add the following code after the
changeblock in your other quiz questions:
broadcast [correct v]
Now you’re going to work on the ‘Spaceship’ instead of the Alien. Click on the ‘Spaceship’ sprite and add the following code to get the Spaceship in the right place at the beginning of the quiz:
when gf clicked go to x: [-160] y: [-55] point towards [Planet v]
Add the following code to the ‘Spaceship’ to play a sound and make it move towards the planet when a question is answered correctly:
when I receive [correct v] play sound [spiral v] move  steps
Test your project and make sure the Spaceship moves towards the planet and plays a sound when you get a question correct.
If you answer enough questions to reach the Planet then you’ve won the game. Scratch has a
touchingblock for detecting collisions.
Add the following code to the end of the Spaceship’s green flag script:
forever if (touching [Planet v] ?) say [You win!] for (5) secs stop [all v]
Test your project and answer all the questions correctly so that you reach the planet.
Challenge: More questions
Can you research your own questions to add to your Space Quiz?
Change the Spaceship code so that it only moves 50 steps when you get a question right.
Add three more questions so that you can reach the planet if you answer them all correctly.
You can use the Principia Mission website to research your questions: principia.org.uk.
Can you add code to the Meteoroid so that it moves towards the Spaceship everytime you get a question incorrect? If the Meteorite touches the Spaceship then tell the player they have lost.
You’ll need to make sure the Meteoroid points towards the Spaceship before it moves because the Spaceship will also be moving.