- Learnt28 min · a name, two lists, an ending card
- Basic25 min · finish your Pet Pal
- Challenge 1–327 min · a front page, adopt again, the cold test
- Extrabonus · a pet that asks for what it wants
Review — where we got to 5 min
Your pet has three needs, three buttons, a mood and an ending. Two blocks from three weeks ago come back.
ask [] and waitand(answer), from the Quiz Show.- The start button:
when this sprite clicked,hide,broadcast [start v].
Quick-fire
Two people play your pet, one after the other, without pressing the green flag. What goes wrong?
Reveal the answer
The second player starts with whatever the first one left behind — and everything is set on the green flag, so they have to press it, which wipes the record too.
Today’s Topic 3 min
- An adopt button, and a pet that waits to be adopted
ask [] and waitused for something that is not a question- Two lists: what the green flag owns, and what a run owns
- An ending card with a name and a number in one sentence
Learning outcome
By the end of this lesson you will be able to:
- Let the player name something, and use that name later.
- Say which variables belong to a run and which belong to the whole project.
- Hand a finished project to somebody who was not in the room.
Learnt — a name, two lists, an ending 28 min
1 · Whose pet is it?
The same pet for everybody is a demo. A pet the player names is theirs. The block for it is the one you built the Quiz Show out of.
- Make a variable called
pet name. Untick its box — it does not belong on the Stage. - On the pet, add
ask [What will you call me?] and wait. - Under it,
set [pet name v] to (answer). - Then
say (join [I am ] (pet name)) for (3) seconds. - Run it and give the pet a name.
ask [What will you call me?] and wait
set [pet name v] to (answer)
say (join [I am ] (pet name)) for (3) seconds
(answer) gets overwritten by the next ask anywhere in the project.How to use this: Click the green flag, then type your answer in the box and press Enter.
2 · Two lists
This is the idea worth taking out of the whole arc. Write two lists on paper before you move a single block.
| Belongs to the green flag | Belongs to one run |
|---|---|
best | food, fun, sleep |
| Where the buttons sit | days |
| Which backdrop we open on | pet name |
| The adopt button, shown | The pet’s costume |
Anything in the right-hand column goes into a when I receive [adopt v] script. Anything in the left-hand column stays on the flag.
when I receive [adopt v]
ask [What will you call me?] and wait
set [pet name v] to (answer)
set [food v] to (10)
set [fun v] to (10)
set [days v] to (0)
broadcast [live v]
live message is what starts the clocks.3 · The ending card
One sentence, with a name in the middle and a number at the end. That needs two joins, and the way to build them is inside out.
- Drag one
join [apple ] [banana]onto the empty canvas. - Type
lastedin its left half. - Drag
(days)into its right half. - Drag a second join out, and drop the first one into its RIGHT half.
- Drag
(pet name)into the second one’s left half. - Now drop the whole thing into a say block.
when I receive [live v]
wait until <(food) = (0)>
if <(days) > (best)> then
set [best v] to (days)
end
switch costume to [dog2-c v]
say (join (pet name) (join [ lasted ] (days))) for (4) seconds
stop [all v]
lasted needs one on each side or the words run together.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 Adopt to name your pet, and the bowl or the ball to look after it. When it asks you a question, type your answer in the box and press Enter.
Basic — finish your Pet Pal 25 min
Your project from last week. This is mostly moving blocks you already have onto a different hat.
Step 1 — the two lists
- On paper, list every variable your project has.
- Beside each one, write FLAG or RUN.
- Do the same for every sprite: where does it sit, is it hidden, which costume?
- Read your list back to yourself before you touch a block. Anything you cannot label is a bug waiting.
Step 2 — the adopt button
- Add a button sprite and put it in the middle of the Stage.
- Give it a flag stack that shows it and puts it in place.
- Give it a clicked stack:
hide, thenbroadcast [adopt v].
Step 3 — move the run onto adopt
- Find every
set [my variable v] to (0)block for something on your RUN list. - Drag them off the flag and build one
when I receive [adopt v]script out of them. - Put the name question at the top of it.
- Put
broadcast [live v]at the bottom.
Step 4 — move the clocks onto live
- Change every clock’s hat from
when flag clickedtowhen I receive [live v]. - Do the mood script and the ending script too.
- Press the flag. Nothing should happen except the pet asking to be adopted.
- Click the button. Everything should start.
Step 5 — the card
- Build the two joins on the empty canvas first.
- Read the sentence out loud before you drop it into the say block.
- Play a whole game and check the card says your pet’s name.
The pet starves while I am typing its name.
The clocks are still on the green flag, or on adopt instead of live. They must start after the ask, not before it.
The card says the name but not the days.
One of the two joins is missing. A say block only holds one thing, so both joins have to be nested inside each other, not sat side by side.
My best resets every time somebody adopts.
set [best v] to (0) came across with the RUN blocks. It goes back on the flag.
Two pets are running at once.
The adopt button did not hide, and it was clicked twice. Add hide as the first block of the clicked stack.
A front page
What a player sees before they press anything should tell them what this is.
- The name of your game is on screen.
- It says what the player has to do.
- The record is visible, so there is something to aim at.
Adopt again
When a pet dies, the button should come back so the next person can adopt a fresh one — with a fresh name.
- The button reappears after the ending card.
- A new run asks for a new name.
- Every need starts full again.
- The record does not move.
Teacher note — the list is the answer
Every bug in this mission is a line missing from the RUN list. Send anybody who is stuck back to their paper rather than into their blocks: “is the costume on your list?” finds a sad pet reborn sad much faster than reading scripts does.
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.
- Every button says what it does, without you remembering.
- You lose, and know exactly why you lost.
- You have written down every moment you hesitated, and fixed the worst one.
Teacher note — the silence is the mission
Same rule as the Quiz Show’s last challenge, and it is worth being just as strict about. Every sentence the author wants to say out loud is a sentence that should have been on the screen.
A pet that asks for what it wants
Instead of a general sad face, the pet should name the thing it is shortest of — and change its mind as the numbers move.
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.
- The pet names the need that is lowest, not the first one it checks.
- It changes what it asks for when a different need becomes the lowest.
- It says nothing while everything is comfortable.
- It does not talk over itself.
Teacher notes — comparing two variables that are both moving
when I receive [live v]
forever
wait (2) seconds
if <(food) < (fun)> then
say [I would like some food.] for (1.5) seconds
else
say [Play with me!] for (1.5) seconds
end
end
Every comparison in the course so far has had a typed number on one side. This one has a variable on both, and the answer changes as the game runs — which is a real step and worth naming out loud.
The wait (2) seconds at the top of the loop is what stops the pet talking over itself. Without it the loop runs as fast as the say block allows and the bubble never settles.
Going further: three needs needs a nested if, and a pupil who gets that far has built a small decision tree.
Summary 4 min
Pet Pal is finished. It is the second project you can leave running for somebody else, and the first one that keeps going while they think.
ask [] and waitis not only for questions. It is how a player names anything.- Every variable belongs either to the green flag or to one run. Write the two lists down.
- A second message lets the clocks start after the naming, not before.
- An ending card with a name in it makes the run feel like it was yours.
- Adopt screen
- The front page. What a player sees before a run starts.
- Run
- One game, from the start button to the ending card.
- Nested join
- A join inside another join, so a sentence can hold two things.
- Game state
- Everything a run changes, and therefore everything a new run has to put back.
Next lesson: the last arc of Level 1, and the first game two people play at the same keyboard.