- Learnt28 min · a speed that grows, and landing on the grass
- Basic24 min · Pico on the meadow
- Challenge 1–327 min · three gravities, the slow climb, a bouncing ball
- Extrabonus · a shower of stars
Review — the Cheese Maze arc 5 min
- Walls are one flat colour, and a sprite asks whether it is touching it.
- Move, ask, undo — the check comes after the move, never before.
- A step bigger than the wall is thick steps straight over it.
Quick-fire
In the maze, the mouse moved 4 and undid exactly 4. When Pico falls onto the grass, how far does it need to go back up?
Reveal the answer
Nobody knows in advance — it depends how fast Pico was falling. So instead of undoing a number, Pico backs up one pixel at a time until it is clear of the grass. That is today’s landing.
Today’s Topic 3 min
y velocity— a speed kept in a variable- Gravity:
change [y velocity v] by (-1)every tick - Landing: pushing back out of the ground
- Why the landing lives in a My Block with screen refresh turned off
Learning outcome
By the end of this lesson you will be able to:
- Make a sprite fall faster and faster, the way real things do.
- Land it exactly on the ground — not in it, not above it.
- Explain why the push-out has to finish between two frames.
Learnt — falling 28 min
1 · A steady fall looks wrong
Here is the first fall most people build: move down 5 every tick until you touch the grass.
repeat until <touching color [#3FA34D]?>
change y by (-5)
end
How to use this: Click the green flag and watch Pico come down at one speed the whole way.
2 · A speed you can change
Things that fall start slowly and get faster. To copy that, the speed cannot be a number typed into a block — it has to live in a variable that changes every tick. We call it y velocity: how fast Pico is moving up right now.
set [y velocity v] to (0)
repeat until <touching color [#3FA34D]?>
change [y velocity v] by (-1)
change y by (y velocity)
end
| Tick | y velocity | Pico moves | Fallen so far |
|---|---|---|---|
| 1 | −1 | 1 down | 1 |
| 2 | −2 | 2 down | 3 |
| 3 | −3 | 3 down | 6 |
| 10 | −10 | 10 down | 55 |
| 22 | −22 | 22 down | 253 |
How to use this: Click the green flag. Watch the y velocity monitor count down while Pico speeds up.
3 · Landing: back out of the grass
Look closely at the end of that fall. The last tick moved Pico 22 pixels, but the grass was nearer than that — so Pico finished 9 pixels inside it. The fix is the maze’s undo, with a twist: we do not know how far to go back, so we go back one pixel at a time until Pico is clear.
define land
if <touching color [#3FA34D]?> then
repeat until <not <touching color [#3FA34D]?>>
change y by (1)
end
set [y velocity v] to (0)
end
land, made with Run without screen refresh ticked — Challenge 2 shows why that tick matters.How to use this: Click the green flag. Pico lands, stops for a moment inside the grass so you can see it, then pushes out.
Basic — Pico on the meadow 24 min
Start a new project. You are painting a meadow and dropping Pico into it — then walking it off a ledge to watch it fall again.
Step 1 — paint the meadow
- Paint a pale sky backdrop.
- With the rectangle tool, draw a strip of ground across the bottom in one green. Fill on, outline off.
- Draw a short, thin ledge high up on the right in the same green.
Step 2 — Pico
- Add the
Picosprite and set its size to 40. - Add
set rotation style [left-right v]so turning round never turns it upside down. - Make a variable called
y velocity.
Step 3 — the land block
- In My Blocks, click Make a Block and call it
land. - Tick Run without screen refresh before you press OK.
- Under the define hat, build the push-out from Learnt part 3.
Step 4 — the loop
- When the flag is clicked, go to
x: 150, y: 150— above the ledge — and sety velocityto 0. - In a
forever: gravity, thenchange y by (y velocity), thenland :: custom. - Test it. Pico should drop onto the ledge and stay there.
Step 5 — walking, and falling off
- Inside the loop, add the right and left arrow checks: point the right way and
change x by (4)orchange x by (-4). - Walk Pico off the end of the ledge. It should fall to the ground, speeding up.
- Add
when [space v] key pressed→go to x: (x position) y: (150)and sety velocityto 0, so you can drop it again.
when flag clicked
set rotation style [left-right v]
go to x: (150) y: (150)
set [y velocity v] to (0)
forever
change [y velocity v] by (-1)
change y by (y velocity)
land :: custom
if <key (right arrow v) pressed?> then
point in direction (90)
change x by (4)
end
if <key (left arrow v) pressed?> then
point in direction (-90)
change x by (-4)
end
end
when [space v] key pressed
go to x: (x position) y: (150)
set [y velocity v] to (0)
How to use this: Click the green flag. Walk with the left and right arrows, walk off the ledge, and press space to drop Pico from the sky again.
Pico sinks into the ground and then climbs slowly out.
Run without screen refresh is not ticked. Right-click the define hat, choose Edit, and tick it. Challenge 2 is all about this.
Pico falls straight through the ground.
The colour in touching color is not the ground’s. Click the swatch and pick the ground with the eyedropper from the Stage.
Pico shoots up out of the top of the Stage the moment it lands.
The push-out says change y by (-1), or the not is missing — so it keeps going while it is not touching.
Pico keeps sinking a little further each time.
y velocity is never set back to 0 inside land, so every tick starts from the speed it landed at.
If I stop right on the edge of the ledge, Pico hangs there by its head.
Well spotted — Pico’s head is much wider than its feet, and the head is still over the ledge. Keep walking and it drops. Lesson 3-31 fixes it properly.
Three gravities
Drop three Picos together from the same height — one on the Moon, one on Earth, one on a giant planet.
- Their gravities are 0.5, 1 and 2.
- Each one counts its ticks until it lands.
- Before you run it, guess the three numbers.
How to use this: Click the green flag. All three drop at once — watch which lands first, then read the monitors.
Teacher note
Nearly everyone guesses 44 and 11 — double and half of 22. The real answers are 31 and 16, because the distance fallen grows with the square of the time: 22 × 1.41 ≈ 31 and 22 ÷ 1.41 ≈ 16. Nobody needs the maths, but the gap between the guess and the result is the lesson: speed that builds up behaves differently from speed that is fixed.
The slow climb
Make two Picos. Give both the same land block, but tick Run without screen refresh on only one of them.
- Drop both from the same height.
- A second script on each counts every frame it sees Pico touching the grass.
- Compare the two counters.
How to use this: Click the green flag and watch the right-hand Pico closely as it lands.
Teacher reveal — the counting script
when flag clicked
wait (1) seconds
forever
if <touching color [#3FA34D]?> then
change [frames in the grass v] by (1)
end
end
Both Picos climb out the same number of pixels. The difference is when the Stage is drawn. Without the tick, Scratch redraws after every pass of the repeat until, so each pixel of the climb is a frame you can see. With it, the whole climb happens between two frames and the watcher never catches Pico in the grass. This is the Firework Show tickbox from Lesson 3-15, doing a job that actually matters.
A bouncing ball
Swap Pico for a ball. When it lands, instead of stopping, it should bounce — a little lower every time — and then settle.
- Landing turns the speed round and keeps seven tenths of it.
- A counter of bounces.
- When a bounce would be tiny, the ball stops for good.
How to use this: Click the green flag and count the bounces with the monitor.
Teacher reveal — the bounce block
define bounce
if <touching color [#3FA34D]?> then
repeat until <not <touching color [#3FA34D]?>>
change y by (1)
end
set [y velocity v] to (round ((y velocity) * (-0.7)))
change [bounces v] by (1)
if <(y velocity) < (3)> then
set [y velocity v] to (0)
set [resting v] to (1)
end
end
Two details that trip people up. The round is there because 0.7 of a whole number is rarely whole, and without it the speed never settles. The resting test is there because a bounce of 1 bounces for ever — the ball twitches on the grass until you stop the project.
A shower of stars
Ten stars drop from random heights at random places. Every one falls the way Pico does, and lands on whatever green is below it.
- One Star sprite, ten clones.
- Each clone keeps its own
y velocity— made for this sprite only, as in Bubble Popper. - All of them share one
landblock. - A
landedcounter, and Pico announcing when it reaches 10.
How to use this: Click the green flag and watch ten stars drop. Pico speaks when the last one lands.
Teacher note
The stars that land on the ledge are the best moment in the lesson: nobody wrote anything about the ledge. It is green, so it is ground. Next lesson the same idea turns into platforms you can jump onto.
Summary 5 min
- A fall that looks real needs a speed that changes, so the speed lives in a variable:
y velocity. - Gravity is
change [y velocity v] by (-1); moving ischange y by (y velocity). - Landing overshoots, so push back out one pixel at a time until clear.
- Then set
y velocityto 0, or the next tick punches straight back in. - The push-out goes in a My Block with Run without screen refresh ticked, so it finishes between two frames.
- Velocity
- How fast something is moving, and which way. Negative y velocity is downwards.
- Gravity
- The steady pull that takes a little off the velocity every tick.
- Tick
- One pass round the forever loop — one frame of the game.
- Push-out
- Moving a sprite back out of the ground after it has gone too far in.
Hand in
Save your meadow. Next lesson Pico jumps — and a jump turns out to be a single block.