- Learnt28 min · home, speed up, a test key, two endings, best level
- Basic24 min · finish the game
- Challenge 1–327 min · score it, speed it, end it
- Extrabonus · the beetle on the lily pad
Review — the river 5 min
touching color [#2E86DE]?finds the water on the backdrop.- Logs are clones, built exactly like the cars.
- The log writes its speed into
(ride speed), and the frog reads it. - Log first, water second: an if / else.
Quick-fire
You want every car and every log to go faster. There are 15 of them on the road. How many numbers must you change?
Reveal the answer
One — if every clone multiplies its speed by the same shared number. That is today’s trick.
Today’s Topic 3 min
- Home: score and level
(speed up)— one number that speeds up every lane- A test key, for checking level 3 without playing to it
- A win screen and a lose screen
- A best level that is never reset
Learning outcome
By the end of this lesson you will be able to:
- Turn reaching a goal into points and a new level.
- Make one shared variable change the speed of every clone at once.
- Decide which variables reset on the flag — and keep one that does not.
Learnt — a game with an end 28 min
Home is worth something
Until now the far bank said “Made it!” and nothing else. Now it counts. Make two variables, both for all sprites: score and level.
when flag clicked
forever
wait until <(y position) > (140)>
change [score v] by (10)
change [level v] by (1)
go to x: (0) y: (-160)
end
The game-over stack now resets three numbers, not one:
when flag clicked
set [lives v] to (3)
set [score v] to (0)
set [level v] to (1)
wait until <(lives) < (1)>
stop [other scripts in sprite v]
say [Game over!] for (2) seconds
stop [all v]
How to use this: Click the green flag, then click the Stage once and tap ↑ ↓ ← → to hop the Frog to the far bank.
Faster every level
Each car has its own (my speed). To speed them all up, you do not touch those. You multiply them all by one shared number, (speed up).
change x by (my speed)
change x by ((my speed) * (speed up))
- Make
speed up, for all sprites. - From Operators, drag
(() * ())into thechange x by ()block. - Drop
(my speed)in the left hole and(speed up)in the right. - Do the same in the Log clone.
- In the Log, change
set [ride speed v] to (my speed)the same way. The frog must ride at the new speed too.
| Level | speed up | A truck at −1.5 moves |
|---|---|---|
| 1 | 1 | −1.5 |
| 2 | 1.5 | −2.25 |
| 3 | 2 | −3 |
A test key
Does level 3 feel right? You would have to cross twice to find out. Game makers add a test key that skips ahead. Put it on the Stage:
when flag clicked
set [level v] to (1)
set [speed up v] to (1)
when [space v] key pressed
change [level v] by (1)
change [speed up v] by (0.5)
How to use this: Click the green flag, then click the Stage once. Press the space bar to jump a level. Tap ↑ ↓ ← → to hop the Frog.
Two endings, one sprite
A new sprite, Banner, holds two costumes: You Lose and Winner. It resets the game and waits for the end.
when flag clicked
hide
set [lives v] to (3)
set [score v] to (0)
set [level v] to (1)
set [speed up v] to (1)
wait until <(lives) < (1)>
switch costume to [You Lose v]
show
stop [all v]
when I receive [You win v]
switch costume to [Winner v]
show
stop [all v]
The frog’s home stack decides between “next level” and “you win”:
when flag clicked
forever
wait until <(y position) > (140)>
change [score v] by (10)
go to x: (0) y: (-160)
if <(level) = (3)> then
broadcast [You win v]
else
change [level v] by (1)
change [speed up v] by (0.5)
end
if <(level) > (best level)> then
set [best level v] to (level)
end
end
The frog loses its own game-over stack. The Banner does that job now, so the frog’s old one must go — two stacks resetting the same numbers is asking for a race.
The one variable you never reset
(best level) is the highest level you ever reached. If the flag set it to 0, it would forget. So nothing resets it.
| Variable | Reset on the flag? |
|---|---|
(lives) | Yes — to 3 |
(score) | Yes — to 0 |
(level) | Yes — to 1 |
(speed up) | Yes — to 1 |
(best level) | Never |
Basic — finish the game 24 min
Open your game from last lesson. Test after every step.
Step 1 — the new variables
Make score, level, speed up and best level, all for all sprites. Tick all but speed up.
Step 2 — the home stack
- Find the “Made it!” stack on the frog.
- Replace it with the home stack from Learnt.
- Cross once. Score 10, level 2.
Step 3 — speed up
- Multiply by speed up in the Car clone, the Log clone, and the log’s ride speed.
- Add the test key to the Stage. Press space twice. Is level 3 fair?
Step 4 — the Banner
- Paint a new sprite with two costumes: the words
You LoseandWinner. Use the Text tool. - Name the costumes exactly that. The blocks pick them by name.
- Add its two stacks.
- Delete the frog’s old game-over stack.
Step 5 — both endings
- Lose three lives on purpose. You Lose.
- Use the test key to reach level 3, then cross. Winner.
- Click the flag. Everything is back to the start — except best level.
Step 6 — remove the test key
Delete the space-bar stack. Play the whole game once, properly.
How to use this: Click the green flag, then click the Stage once and tap ↑ ↓ ← → to hop the Frog home three times.
Level goes up to 4, 5, 6…
The home stack changes the level every time. Use the if / else: on level 3, broadcast instead of changing.
It says You Lose the moment I click the flag.
Some other stack resets lives too, or the Banner’s wait is in a different stack from its set. Keep all the resets in the Banner, above the wait.
The cars speed up but the frog slides off the logs.
The log still writes plain (my speed) into ride speed. Multiply that one by speed up too.
Best level is 0 after every flag.
A set block for best level is hiding in a flag stack. Delete it. Nothing resets it.
Home counts
- Reaching the far bank adds to the score.
- It moves you up a level.
- The frog starts again from the pavement.
- Score and level are back to 0 and 1 on every flag.
How to use this: Click the green flag, then click the Stage once and tap ↑ ↓ ← → to hop the Frog to the far bank.
Faster every level
- Every car and every log speeds up on each new level.
- The lanes keep their own speeds — slow lanes stay slower than fast lanes.
- The frog still rides a log at exactly the log’s speed.
How to use this: Click the green flag, then click the Stage once. Press the space bar to jump a level. Tap ↑ ↓ ← → to hop the Frog.
Teacher note — how much faster?
0.5 a level doubles the speed by level 3. Some pupils will try 1, which triples it — let them play it. Level 3 should be hard, not impossible. The test key is the only way most of them will ever tune it.
Win, lose, remember
- Home on level 3 shows a win screen and stops the game.
- Running out of lives shows a lose screen and stops the game.
- The best level ever reached is on screen, and the flag never wipes it.
How to use this: Click the green flag, then click the Stage once and tap ↑ ↓ ← → to hop the Frog home three times.
Teacher reveal — why the frog broadcasts
The obvious version is a second Banner stack: wait until <(level) > (3)>. It works once — then on the next flag it can see last game’s level 4 before anything resets it, and wins instantly. A broadcast only happens at the moment of winning, so it cannot misfire. It is the lives race from Lesson 2-34 again, and worth pointing out as the same bug.
The beetle on the lily pad
A beetle sits on one of the five lily pads. Land on it and you get fifty points on top of the usual ten. Then it moves to another pad.
- The beetle always sits on a lily pad, never between two.
- Landing on it adds 50 as well as the 10.
- It moves every time it is eaten.
How to use this: Click the green flag, then click the Stage once and tap ↑ ↓ ← → to hop the Frog to the beetle.
Teacher reveal
when flag clicked
set size to (35) %
go to x: ((pick random (-2) to (2)) * (80)) y: (160)
show
when I receive [Eaten v]
go to x: ((pick random (-2) to (2)) * (80)) y: (160)
And at the top of the frog’s home stack, straight after the wait:
if <touching [Beetle v]?> then
change [score v] by (50)
broadcast [Eaten v]
end
The frog checks, in the same moment it lands. A beetle running its own wait until <touching [Frog v]?> races the frog’s jump home and misses about half the time.
Summary 5 min
- A goal is worth something: score, level, then start again.
- Multiply every clone’s own speed by one shared
(speed up), and one number speeds up the whole road. - A test key skips ahead while you build. Delete it before you share.
- Reset everything on the flag in one stack — except the best level.
- A broadcast at the moment of winning cannot misfire on the next flag.
- Level
- How far through the game you are. Higher levels are harder.
- Speed up
- One shared number every clone multiplies its speed by.
- Test key
- A key only the game maker uses, to jump ahead while testing.
- Best level
- The highest level ever reached. The flag never resets it.
Ship it
Your Road Crossing is finished. Play it cold: save it, do something else for ten minutes, then play it with every script window shut. Then share it on the Scratch website and send the link to your teacher.
You used clones with their own numbers in four lessons. Next arc, Penalty Shootout, starts something new.