- Learnt27 min · a speed variable, a star, a bat
- Basic25 min · build all three
- Challenge 1–327 min · a third lane, a fair speed, a star worth taking
- Extrabonus · a warning before it arrives
Review — where we got to 5 min
The run has a score and three lives. It ends by itself and tells you how you did.
- The clone scores by reaching the far edge, and costs a life by touching the runner.
if <(lives) = (0)> thenbroadcasts the ending.
Quick-fire
The rock steps -8 every time round the loop. What would make it faster without touching the loop?
Reveal the answer
Put a variable in the block instead of a number. Change the variable and every rock already flying changes with it.
Today’s Topic 3 min
- A variable inside a motion block, so one number steers the whole game
- A game that gets harder the longer you last
- Something worth collecting, at a height only a hop reaches
- Something to avoid at that same height, so hopping has a cost
Learning outcome
By the end of this lesson you will be able to:
- Drop a variable into a motion block and change the game by changing it.
- Reward a hop and punish a hop in the same game.
- Say why a game that speeds up for ever stops being fun.
Learnt — speed, a star, and a bat 27 min
1 · One number that steers everything
The -8 in the rock’s loop is the whole difficulty of the game. Take it out and put a variable in its place.
- Make a variable called
speed. - On the rock’s flag stack, add
set [speed v] to (-8). - In the clone stack, drag
speedinto thechange x by ( )block, on top of the −8. - In the factory loop, after the clone is made, add
change [speed v] by (-0.2). - Play for two minutes. It should feel different at the end.
when flag clicked
hide
set [speed v] to (-8)
forever
wait (1.6) seconds
create clone of [myself v]
change [speed v] by (-0.2)
end
How to use this: Click the green flag and watch the speed box rather than the rocks. The number is the difficulty.
2 · Something worth having
A star flies at hop height. You can only reach it in the air, so it turns a hop into a decision rather than a reflex.
- Add the Star sprite. Set its size to
60. - Give it the same factory shape as the rock, with a longer wait.
- In its clone stack, go to
go to x: (240) y: (15). - Walk it left the same way the rock walks.
- Inside that loop, ask
touching [Hare v]?and pay 5 points.
when I start as a clone
go to x: (240) y: (15)
show
repeat (60)
change x by (speed)
if <touching [Hare v]?> then
start sound [Collect v]
change [score v] by (5)
delete this clone
end
end
delete this clone
How to use this: Click the green flag, click the stage once, then press the space bar to hop up to the stars. Each one is worth 5.
3 · Something to avoid up there
If the air is always safe, the best player just stays in it. The bat flies at exactly hop height and makes that a bad plan.
- Add the Bat sprite, size
50. - Copy the star’s scripts by dragging them onto the bat in the sprite list.
- Open the bat and change what touching does: a life instead of five points.
- Give it its own wait so bats and stars do not always arrive together.
- Play it. Try surviving by hopping all the time and see how far you get.
when I start as a clone
go to x: (240) y: (10)
show
repeat (60)
change x by (speed)
next costume
if <touching [Hare v]?> then
start sound [Boing v]
change [lives v] by (-1)
delete this clone
end
end
delete this clone
next costume inside the loop is what makes its wings beat. The Bat sprite comes with four.How to use this: Click the green flag, click the stage once, then press the space bar. Hop the rocks and the stars — but stay down for the bats.
Basic — build all three 25 min
Open last week’s game. Test after every step, not at the end.
Step 1 — the speed variable
- Make it, set it on the flag, and put it in the rock’s change x block.
- Play. Nothing should have changed yet.
- Add the change of −0.2 and play for two minutes.
Step 2 — the star
- Add the sprite and build its factory.
- Build the clone stack at hop height.
- Check you cannot reach it standing still.
Step 3 — the bat
- Drag the star’s scripts onto the bat.
- Change the points into a life.
- Change its wait so it does not follow the star exactly.
- Add next costume so its wings move.
Step 4 — balance it
- Play five games and write down each score.
- If bats never catch you, they are too rare or too low.
- If stars are never worth the risk, move them or pay more.
Step 5 — read your own game
- Say out loud what a good player does. Then check your game rewards that.
Everything freezes after a minute.
Speed has gone past zero into positive numbers, so clones travel right and never leave the Stage. Clamp it — that is Challenge 2.
The bat gives me five points.
The dragged copy was never edited. Open the bat, not the star, and change the if.
The star is unreachable however I hop.
Its y is above the top of the hop. The hop reaches 12 × 10 above the ground line — work out that number and put the star under it.
Stars and bats always arrive together.
Their waits are identical. Give one 2 seconds and the other 2.7.
A third thing at a third height
The ground says hop. Hop height says think. Add one more, and it must not do either of those jobs again.
- A new sprite at a height nothing else uses.
- It does something the other three do not.
- A player can tell what it does the first time they meet it.
Fast enough, and no faster
Leave the game running long enough and it becomes impossible for anybody. Find the point where it stops being fun, and stop it there.
- The game still gets harder as you last longer.
- It never gets faster than a person can react to.
- You can say what number you chose, and why that one.
Teacher note — how to find the number
The honest method is to play badly on purpose: set the starting speed to the value you want to test and see whether you can clear five rocks. Most classes land between −14 and −18.
The block is if <(speed) < (-16)> then with a set inside it, and it belongs in the factory loop, not the clone stack.
Make the star a real choice
A star you can take for free is just a slow point. Make taking one cost the player something.
- Reaching a star sometimes puts you somewhere you did not want to be.
- Ignoring stars is a real way to play, and a safe one.
- Taking every star is possible, but only if you are good.
Teacher note — what makes a choice a choice
The usual answer is a bat close behind a star. The interesting answers are stars worth more the longer you last, or a star that costs a life if you miss it.
This mission is about game design and not about blocks. A pupil who explains why their choice is real, and shows two games to prove it, has done the work.
Warn me before it arrives
At high speed a bat crosses the Stage before your hand moves. That is not difficulty, it is luck. Give the player half a second of warning.
How to use this: Click the green flag and watch the right-hand edge. A mark appears before every bat — nothing to press.
- Something tells the player what is coming before it is on screen.
- The warning is at the right height for the thing that follows.
- It disappears once the thing arrives.
- The game is measurably easier with it than without.
Teacher notes — where the warning lives
The neat answer is a second clone stack on the same sprite: the factory shows a mark, waits, then makes the real clone. Most pupils will use a separate small sprite that shows and hides, which is fine and easier to debug.
The measurement is the point of the mission. Two games with the warning off and two with it on, scores written down — that is evidence, and it is the habit worth the hundred coins.
Going further: next lesson the game gets a front door — a title, a start button, and a best score it remembers.
Summary 4 min
Three things arrive now, and the player has to tell them apart in half a second.
- A variable in a motion block steers every clone at once.
- A game that speeds up needs a limit, or it plays itself into nonsense.
- A reward at hop height makes hopping a decision.
- A danger at hop height makes it a risky one.
- speed
- One variable that every obstacle reads. Change it and the whole game changes.
- Clamp
- Stopping a number going past a limit, however long the game runs.
- Reward
- Something worth points, placed where it is not free.
- Lane
- A height. Each one asks the player a different question.
Next lesson: a title screen, a start button, and a best score that survives the game ending.