🎮 Phase 3 · Game Development 🔵 Intermediate MODULE 11

Quiz Game

⏱️ 35 min
📖 Theory + Build
🧩 5 Quiz Questions
🎮 Full Game Build
Your progress in Phase 375%
🎯 What you'll learn: The ask and answer blocks — how to get typed input from the player — and if/else statements to check if answers are right or wrong. Then build a full 5-question quiz game with scoring!

Ask and Answer Blocks

The ask block shows a question on screen and waits for the player to type a response. Whatever they type is stored in a special variable called answer — you can then check it!

HOW ASK AND ANSWER WORKS
🐱
What is 5 + 3? 🤔
Player types their answer here ↓
8 ▌
After pressing Enter, (answer) contains ↓
(answer) = "8"
Now you can check: if (answer) = "8" then say "Correct! ✅"
Ask and check one question
SCRATCH BLOCKS
ask [What is the capital of France?] and wait

if (answer) = [Paris] then
  say [Correct! ✅ Great job!] for (2) seconds
  change [score] by (1)
else
  say [Not quite! The answer is Paris.] for (2) seconds

Note: Scratch answers are NOT case-sensitive — "paris" and "Paris" both work!

If/Else — Two-Path Decisions

The if/else block is a two-way decision. If the condition is true, one set of blocks runs. If it's false, the else part runs instead. Perfect for right/wrong quiz answers!

IF/ELSE DECISION DIAGRAM
ask [question] and wait
Is answer
= correct?
↙ YES          NO ↘
✅ THEN
Say "Correct!"
change score by 1
play "pop" sound
❌ ELSE
Say "Wrong!"
show the right answer
play "boing" sound

Build: 5-Question Quiz Game 🎓

1
Set up the sprite and variables
Use a teacher or robot sprite. Create variables: score and question (to track which question we're on). Set both to 0 at the start.
2
Ask Question 1
Switch to a costume showing "Q1" or just use the say block to announce it. Then use ask [What is 5 x 6?] and wait.
3
Check the answer with if/else
If answer = "30" then say "Correct!" and change score by 1 · else say "The answer is 30!" — then move to Q2.
4
Repeat for Questions 2-5
Copy the same pattern for all 5 questions. Each one: ask → if correct: +1 score, else: show answer. Make the questions progressively harder!
5
Show the final score
After Q5: say "Quiz complete! Your score: " + score + " out of 5!" Use the "join" block to combine text and numbers together.
Complete Quiz Game Structure
SCRATCH BLOCKS
when 🚩 clicked
set [score] to (0)

-- Question 1 --
say [Question 1 of 5! 🎓] for (1) seconds
ask [What is 5 × 6?] and wait
if (answer) = [30] then
  say [✅ Correct! 5×6=30] for (1.5) seconds
  change [score] by (1)
else
  say [❌ It's 30! 5×6=30] for (1.5) seconds

-- Question 2 --
ask [What planet is closest to the Sun?] and wait
if (answer) = [Mercury] then
  say [✅ Mercury! Well done!] for (1.5) seconds
  change [score] by (1)
else
  say [❌ It's Mercury!] for (1.5) seconds

-- ... Questions 3, 4, 5 ... --

-- Final score --
say join [🏆 Score: ] join (score) [ / 5!] for (5) seconds
🎨
Use the JOIN block for dynamic messages!
The join block in Operators lets you combine text with variables. join [Your score: ] (score) creates "Your score: 4" — much better than a fixed message! You can even chain joins: join [Score: ] join (score) [ / 5!]
🧩 Knowledge Check — Lesson 11
5 questions on ask, answer, and if/else!
1. After using "ask [...] and wait", where is the player's typed answer stored?
2. What is the difference between "if" and "if/else"?
3. Is Scratch's "ask and answer" case sensitive? (Does "London" = "london"?)
4. What block combines text with a variable to make a sentence? (e.g., "Score: 4")
5. In a quiz game with 5 questions, where should you "set score to 0"?
💪
Quiz Challenge — Lesson 11
Ask & Answer mastery · Intermediate Level
Challenge: Topic Quiz with Lives! 🧠❤️

Build a quiz about your favourite topic with a lives system!

Requirements:
1. Create a 10-question quiz about any topic you love (animals, sport, space...)
2. Add a lives variable starting at 3 — lose a life for each wrong answer
3. If lives reach 0 → Game Over before finishing the quiz
4. Award a bonus if the player gets 8+ correct: "Amazing! 🌟 Bonus points!"
5. Change the backdrop based on performance: happy for 8+, sad for under 4
💡 Show hints if you're stuck
  • After each wrong answer: change lives by -1 → if lives = 0 → say "Game Over!" → stop all
  • After Q10: if score ≥ 8 then switch backdrop to happy else if score ≥ 4 then neutral else sad
  • Bonus: if score = 10 then say "PERFECT SCORE! 🏆"
  • Add a hint system: if answer is wrong, give a hint and let them try once more!
Finished this lesson?
Mark it complete to track your progress.
🧠

Lesson 11 Complete!

Ask & answer expert! Last Phase 3 lesson: Balloon Pop — learn to clone sprites!

Module 11 of 16Phase 3 — Game Development