- 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 the moment the flag is pressed and finishes 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 somebody who was not in the room. What is the first thing that goes wrong?
Reveal the answer
They press the flag and question 1 is already asking them something. Nobody said what the show was, or that it was about to start.
Today’s Topic 3 min
when this sprite clicked— a button that starts the show- An if inside an else, giving three different endings
- A
bestvariable that the green flag sets and a round does not - A play-again button that resets everything a round owns
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
There is a hat block that runs when somebody 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 and needs no drawing.
- Name it
Startand 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 sets the table; 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” means nothing on its own. Gold, Silver and Bronze mean something instantly.
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 classroom. The difference is one line, and it is where they get set.
- Make a variable called
best. - Put
set [best v] to (0)on the GREEN FLAG stack, with nothing else. - Do NOT put it in the
startscript. - At the top of the result script, compare this score with the best so far.
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
Your quiz. Four passes, testing after every one.
Step 1 — move the setting-up
- Find your green-flag stack. It probably sets the score, the lives and the backdrop and then broadcasts question 1.
- Drag everything from
set [score v] to (0)downwards off the flag and onto 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 and name it
Start. - Give it a green-flag stack that puts it in place and shows it.
- Give it a clicked stack:
hide, thenbroadcast [start v]. - Test. The flag should do nothing but greet you.
Step 3 — the medal
- Work out the highest score your show can give.
- Choose two numbers: one for gold, one for silver.
- Build the if inside the else in your result script.
- Test all three medals, by answering well, mediumly and badly.
Step 4 — the best score
- Make
bestand set it to 0 on the green flag only. - Add the comparison at the top of the result script.
- Play twice without pressing the flag in between. The best should hold.
- 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, and 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 across when you built the start script. It has to be in the thing that runs on every round.
A front page
Give your show a name and a proper welcome, before anything is asked.
- The name of your show is on the screen before the button is pressed.
- 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 clean show — not yours with a few things left over.
- 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
You cannot see your own project properly while you still remember building it. So put time between you and it, and come back as a stranger would.
- Save it and close the project.
- Do something else for at least ten minutes — the next challenge will do.
- Open it again with every script window shut, so only the Stage is showing.
- Play it start to finish, following 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 hesitated.
- 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 on it is not a leaderboard. Ask every player their name, and keep the name of whoever holds the best score.
- Every player is asked their name before question 1.
- Beating the best score also takes over the name.
- Not beating it leaves the name alone.
- The front page shows both, so 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, and it is the first project you can leave running for somebody else.
when this sprite clickedturns any sprite into a button.- The flag sets the table. A start message runs the round.
- An if inside an else gives three endings, tested from the highest down.
- A best score is set on the flag and nowhere else.
- Button
- A sprite with a clicked hat on it. Nothing else makes it a button.
- Title screen
- What the player sees before anything starts. It says what this is and what to press.
- Grade
- A word given for a range of scores. Gold, Silver, Bronze.
- Best score
- The highest anybody has managed. It survives the end of a round.
Next lesson: a new arc, and something that needs looking after — a pet that gets hungry whether you are watching or not.