- 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 things from three weeks ago come back.
ask [] and waitand(answer), from the Quiz Show.- The start button. It uses
when this sprite clicked,hide,broadcast [start v].
Quick-fire
Two people play your pet, one after the other. Nobody presses the green flag. What goes wrong?
Reveal the answer
The next player starts with what the first one left behind. Everything is set on the green flag, so they have to press it. But that wipes the record too.
Today’s Topic 3 min
- An adopt button, and a pet that waits to be adopted.
ask [] and wait, used for something that is not a quiz question.- Two lists. One is for the green flag. One is for a run.
- 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. Use that name later.
- Say which variables belong to a run. Say which belong to the whole project.
- Give a finished project to someone who was not in the room.
Learnt — a name, two lists, an ending 28 min
1 · Whose pet is it?
The same pet for everyone is just a demo. A pet the player names is their own. You need the block you built the Quiz Show with.
- Make a variable called
pet name. Untick its box. It does not need to be on the Stage. - On the pet, add
ask [What will you call me?] and wait. - Under it, put
set [pet name v] to (answer). - Then put
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).How to use this: Click the green flag, then type your answer in the box and press Enter.
2 · Two lists
This is the big idea of the whole arc. Write two lists on paper. Do it 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 |
Things in the right-hand column go into a when I receive [adopt v] script. Things in the left-hand column stay 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 starts the clocks.3 · The ending card
One sentence has a name in the middle and a number at the end. That needs two joins. Build them from the 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. 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. If not, 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
Use your project from last week. Mostly you move 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 to yourself before you touch a block. Anything you cannot label will cause a bug.
Step 2 — the adopt button
- Add a button sprite. Put it in the middle of the Stage.
- Give it a flag stack. The stack shows it and puts it in place.
- Give it a clicked stack. Use
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. 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. Only one thing should happen. The pet asks 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. Then drop it into the say block.
- Play a whole game. Check that 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 they are on adopt, not 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 one join must go inside the other. They cannot sit side by side.
My best resets every time somebody adopts.
set [best v] to (0) moved with the RUN blocks. Put it back on the flag.
Two pets are running at once.
The adopt button did not hide, and someone clicked it twice. Add hide as the first block of the clicked stack.
A front page
A player sees the front page before they press anything. It should tell them what this is.
- The name of your game is on screen.
- It says what the player has to do.
- You can see the record. Then there is something to aim at.
Adopt again
When a pet dies, the button should come back. Then the next person can adopt a fresh one, with a fresh name.
- The button comes back 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
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.
- Every button shows what it does. You do not need to remember.
- You lose, and you know exactly why.
- You have written down every moment you had to stop. You 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
A sad face is not enough. The pet should name the thing it needs most. It should 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 lowest need, not the first one it checks.
- It asks for something new when a different need is the lowest.
- It says nothing while everything is fine.
- 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 someone else. It is the first one that keeps going while they think.
ask [] and waitis not only for quiz questions. A player can use it to name anything.- Every variable belongs to the green flag or to one run. Write the two lists down.
- A second message makes the clocks start after the naming, not before.
- An ending card with a name in it makes the run feel like your own.
- 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. Now a sentence can hold two things.
- Game state
- Everything a run changes. So a new run has to put all of it back.
Next lesson: the last arc of Level 1. It is the first game two people play at the same keyboard.