- Learnt28 min · a button, a medal, a best score
- Basic25 min · finish your show
- Challenge 1–327 min · a title screen, play again, the cold test
- Extrabonus · the record holder’s name
Review — where we got to 5 min
Your show has questions, lives, cards, sounds and points. It starts as soon as you press the flag. It ends with a number. Both of those change today.
<() > ()>and an if inside an else, from Lesson 26.hideandshow, from Topic 1.4.
Quick-fire
You give your project to someone who was not in the room. What goes wrong first?
Reveal the answer
They press the flag, and question 1 asks them something straight away. Nobody said what the show was. Nobody said it was about to start.
Today’s Topic 3 min
when this sprite clicked. This makes a button that starts the show.- An if inside an else. It gives three different endings.
- A
bestvariable. The green flag sets it. A round does not. - A play-again button. It resets everything that belongs to a round.
Learning outcome
By the end of this lesson you will be able to:
- Start a project by clicking a sprite instead of the flag.
- Turn a score into a medal.
- Keep a best score across several players.
Learnt — button, medal, best 28 min
1 · A button is a sprite with a hat on it
One hat block runs when someone clicks a sprite. Any sprite. It is in Events, under the flag and the key blocks.
- Add a sprite. Button1 is a round green one. You do not need to draw it.
- Name it
Start. Put it near the bottom of the Stage. - Give it
when this sprite clicked. - Under that, put
hideand thenbroadcast [start v]. - Press the green flag. Then click the button.
when this sprite clicked
hide
broadcast [start v]
The host now has two jobs. The green flag gets things ready. The start message begins the show.
when flag clicked
switch backdrop to [Theater v]
say [Press the green button to play.] for (3) seconds
when I receive [start v]
set [score v] to (0)
set [lives v] to (3)
broadcast [question 1 v]
How to use this: Click the green flag, then click the start button on the stage.
2 · A medal instead of a number
“You scored 6” does not tell you much on its own. Gold, Silver and Bronze tell you straight away.
when I receive [result v]
if <(score) > [8]> then
say [GOLD!] for (4) seconds
else
if <(score) > [5]> then
say [Silver.] for (4) seconds
else
say [Bronze. Play again!] for (4) seconds
end
end
How to use this: Click the green flag to start it. Nothing else to press — watch it through, then use ↺ Reset to run it again.
3 · A best score
score belongs to one player. best belongs to the whole class. The only difference is where you set them.
- Make a variable called
best. - Put
set [best v] to (0)on the GREEN FLAG stack. Put it nowhere else. - Do NOT put it in the
startscript. - At the top of the result script, compare this score with the best score.
when I receive [result v]
if <(score) > (best)> then
set [best v] to (score)
say [A new best score!] for (2) seconds
end
How to use this: Click the green flag to start it. Nothing else to press — watch it through, then use ↺ Reset to run it again.
How to use this: Click the green flag, then click the start button on the stage. When it asks you a question, type your answer in the box and press Enter.
Basic — finish your show 25 min
Use your quiz. You will change it four times. Test after each one.
Step 1 — move the setting-up
- Find your green-flag stack. It probably sets the score, the lives and the backdrop. Then it broadcasts question 1.
- Drag everything from
set [score v] to (0)down off the flag. Drop it on an empty part of the canvas. - Put a
when I receive [start v]hat on top of it. - Leave the backdrop block and a welcome message on the flag.
Step 2 — the button
- Add a button sprite. Name it
Start. - Give it a green-flag stack. The stack puts it in place and shows it.
- Give it a clicked stack. Use
hide, thenbroadcast [start v]. - Test. The flag should only say hello.
Step 3 — the medal
- Work out the highest score your show can give.
- Choose two numbers. One is for gold. One is for silver.
- Build the if inside the else in your result script.
- Test all three medals. Answer well, then so-so, then badly.
Step 4 — the best score
- Make
best. Set it to 0 on the green flag only. - Add the comparison at the top of the result script.
- Play twice. Do not press the flag in between. The best should stay.
- Press the flag. The best should go back to 0.
Step 5 — play again
- On the button, add
when I receive [result v], thenwait (4) seconds, thenshow. - Play a whole round. Wait for the button. Then play another.
- Check the score really did go back to 0 for the second round.
The show starts on its own when I press the flag.
A broadcast [question 1 v] is still on the green-flag stack. It belongs on the start script now.
Everybody gets Silver, even with a perfect score.
The tests are the wrong way round. Test the biggest number first.
The best score is always the same as the last score.
set [best v] to (0) is in the start script. Move it to the green flag.
My second round starts with the first round’s score.
The set-score-to-0 block did not move when you built the start script. It has to be in the script that runs every round.
A front page
Give your show a name and a proper welcome. Do this before any question.
- The name of your show is on the screen before anyone presses the button.
- It says what the quiz is about.
- It tells the player what to press.
Play again, properly
One press should give the next player a fresh show. Nothing should be left over from yours.
- The score starts at 0.
- The lives start at 3.
- The card goes back to the front page.
- The best score does NOT reset.
Teacher note — the checklist that makes this easy
Get them to list, on paper, everything the show changes: score, lives, backdrop, which sprites are hidden. Anything on the list has to be put back by the start script. Anything NOT on the list — best, the questions themselves — belongs to the flag. That two-column list is the whole idea of game state, and it costs two minutes.
The cold test
It is hard to test your project while you still remember building it. So take a break. Then come back like a stranger would.
- Save it and close the project.
- Do something else for at least ten minutes. The next challenge is fine.
- Open it again with every script window shut. Only the Stage should show.
- Play it from start to finish. Follow ONLY what is on the screen.
- Write down every moment you had to stop and think.
- You start it without opening a single script.
- You finish the whole show without guessing.
- You have written down every moment you had to stop.
- You fix the worst one.
Teacher note — the rule that makes this mission work
The author is not allowed to speak. Every word they want to say out loud is a word that should have been on the screen. Enforcing the silence is the whole exercise, and it is worth being strict about for ten minutes.
Who holds the record?
A best score with no name is not a leaderboard. Ask every player their name. Keep the name of the player with the best score.
- Every player is asked their name before question 1.
- A player who beats the best score puts their name there too.
- If they do not beat it, the name stays.
- The front page shows both. Then the next player knows what to beat.
Teacher notes — two variables that must move together
when I receive [start v]
ask [What is your name?] and wait
set [player v] to (answer)
set [score v] to (0)
set [lives v] to (3)
broadcast [question 1 v]
And at the end, both are set inside the same if or neither of them is:
when I receive [result v]
if <(score) > (best)> then
set [best v] to (score)
set [champion v] to (player)
end
say (join [Best so far: ] (join (champion) (join [ with ] (best)))) for (4) seconds
A pupil who sets the name outside the if ends up with the LATEST player’s name beside the HIGHEST player’s score, which is a wrong answer that looks right until somebody loses. That is a lovely bug to let them find by playing it three times.
Going further: a real leaderboard needs a list, and lists are Level 3.
Summary 4 min
The Quiz Show is finished. It is the first project you can leave running for someone else.
when this sprite clickedturns any sprite into a button.- The flag gets things ready. A start message runs the round.
- An if inside an else gives three endings. Test from the highest down.
- A best score is set on the flag and nowhere else.
- Button
- A sprite with a clicked hat on it. That is all a button is.
- Title screen
- What the player sees before anything starts. It says what the project is and what to press.
- Grade
- A word for a range of scores, like Gold, Silver or Bronze.
- Best score
- The highest score anyone has got. It stays after a round ends.
Next lesson: a new arc. You look after a pet. It gets hungry even when you are not watching.