- 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. Then it tells you how you did.
- The clone scores a point if it reaches the far edge. It costs a life if it touches the runner.
if <(lives) = (0)> thenbroadcasts the ending.
Quick-fire
The rock steps -8 each time round the loop. How could you make it faster without changing the loop?
Reveal the answer
Put a variable in the block instead of a number. Change the variable. Every rock that is flying changes too.
Today’s Topic 3 min
- A variable inside a motion block. One number controls the whole game.
- A game that gets harder the longer you last.
- Something to collect, at a height only a hop reaches.
- Something to avoid at that same height. Now hopping has a cost.
Learning outcome
By the end of this lesson you will be able to:
- Drop a variable into a motion block. Change the game by changing the variable.
- Make a hop help you, and make a hop hurt you, 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 decides how hard the game is. Take it out. 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. Now you must choose when to hop.
- Add the Star sprite. Set its size to
60. - Give it the same factory 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 give 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 hop height. That makes staying up a bad plan.
- Add the Bat sprite, size
50. - Copy the star’s scripts. Drag them onto the bat in the sprite list.
- Open the bat. Change what touching does: it costs a life, not five points.
- Give it its own wait. Then bats and stars do not always come together.
- Play it. Try hopping all the time. How far do 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 makes its wings flap. The Bat sprite has four costumes.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 your game from last lesson. Test after every step, not at the end.
Step 1 — the speed variable
- Make it and set it on the flag. Put it in the rock’s change x block.
- Play. Nothing should have changed yet.
- Add the change of −0.2. 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 when you stand 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 always follow the star.
- Add next costume so its wings move.
Step 4 — balance it
- Play five games and write down each score.
- Do bats never catch you? Then they are too rare or too low.
- Are stars never worth the risk? Move them, or give more points.
Step 5 — read your own game
- Say out loud what a good player does. Check your game gives points for that.
Everything freezes after a minute.
Speed has gone past zero into positive numbers. So clones go right and never leave the Stage. Clamp it: that is Challenge 2.
The bat gives me five points.
You did not change the copy. 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 goes 12 × 10 above the ground line. Work out that number. Put the star under it.
Stars and bats always arrive together.
Their waits are the same. 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 lane. It needs a new job of its own.
- 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 see it.
Fast enough, and no faster
If the game runs long enough, nobody can play it. Find the speed where it stops being fun. Stop it there.
- The game still gets harder as you last longer.
- It never gets too fast for a person to react.
- You can say what number you chose, and why.
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 free star is just an easy point. Make taking a star cost the player something.
- Taking a star sometimes puts you in a bad place.
- You can play by ignoring stars. It is a safe way to play.
- You can take every star, 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 hard, 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 same height as the thing that follows.
- It goes away when the thing arrives.
- Your scores show the game is easier with it.
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 come at you now. You must tell them apart in half a second.
- A variable in a motion block controls every clone at once.
- A game that speeds up needs a limit. If not, it gets too fast to play.
- A reward at hop height makes you choose when to hop.
- A danger at hop height makes hopping risky.
- speed
- One variable that every obstacle reads. Change it, and the whole game changes.
- Clamp
- Stopping a number at a limit, however long the game runs.
- Reward
- Something worth points. It is 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 stays after the game ends.