- Learnt28 min · steps, a hitbox, and walls
- Basic24 min · the climber
- Challenge 1–327 min · head bumps, thin air, can it be reached?
- Extrabonus · a lift
Review — the jump 5 min
- A jump is
set [y velocity v] to (12), and it rises 66. on groundis cleared every tick and set only by a real landing.- A running jump is 24 ticks in the air, so its length is the speed × 24.
Quick-fire
Last lesson the stars that fell over the ledge landed on it, though nobody wrote a line about the ledge. Why?
Reveal the answer
Because it is green. land never asks which green — the ground and the ledge are the same colour, so they are the same thing to it. Today that is the whole of platforms, and then three surprises.
Today’s Topic 3 min
- Platforms are just more of the ground colour
- A hitbox: the costume that does the touching
- A
walkMy Block with Cheese Maze’s move-ask-undo - Head bumps, and levels that can actually be finished
Learning outcome
By the end of this lesson you will be able to:
- Build a level of steps that Pico can climb.
- Explain why the shape that touches is not always the shape you see.
- Stop Pico walking into a step’s side or jumping up through its underneath.
Learnt — steps 28 min
1 · Platforms need no new code
Paint four steps in the ground colour, each 50 above the last. Then run last lesson’s Pico, unchanged. A jump rises 66, so every step is in reach — and every landing just works, because every step is green.
How to use this: Click the green flag and watch Pico hop up all four steps to the star on its own.
2 · What touches is not what you see
Now walk Pico slowly off the edge of a step and stop. Pico is a big round head on two small legs. The legs step off — but the head is still over the step, so as Pico falls, its chin catches the corner and it hangs there, 20 pixels too low.
The fix every platform game uses is a hitbox: a plain box costume, as tall as Pico and a bit narrower than its head. land switches to it first and back to Pico last. The block runs without screen refresh, so the box is never drawn — the Stage only ever shows Pico.
define land
switch costume to (hitbox v)
set [on ground v] to (0)
if <touching color [#3FA34D]?> then
repeat until <not <touching color [#3FA34D]?>>
change y by (1)
end
set [y velocity v] to (0)
set [on ground v] to (1)
end
switch costume to (pico v)
land.How to use this: Click the green flag. Pico walks to the edge of step 1 twice — watch where it ends up each time.
3 · Walls, and the escalator
Walk Pico straight into the side of step 1. Nothing stops it walking into the green — and then land sees green and pushes Pico up until it is clear, which is on top of the step. Pico rides up 50 pixels like an escalator.
How to use this: Click the green flag. Pico only walks right — it never jumps.
The cure is Cheese Maze’s move-ask-undo, sideways. Walking gets its own My Block, with the hitbox too:
define walk (speed)
switch costume to (hitbox v)
change x by (speed)
if <touching color [#3FA34D]?> then
change x by ((0) - (speed))
end
switch costume to (pico v)
walk (4) :: custom and walk (-4) :: custom.How to use this: Click the green flag. Pico walks into step 1, is stopped, then jumps up onto it.
Basic — the climber 24 min
Start from your meadow project, and turn the meadow into a level.
Step 1 — paint the level
- Keep the ground, but leave a gap in the middle of it.
- Paint the gap blue — it becomes water next lesson.
- Paint four steps in the ground green, each about 50 higher than the one before and not too far apart.
- Paint one short block low enough to walk under but too high to jump onto.
Step 2 — the hitbox
- In Pico’s Costumes tab, duplicate the costume and call the copy
hitbox. - Draw a filled rectangle from the top of the head to the feet, and delete the rest.
- In
land, addswitch costume to (hitbox v)at the top andswitch costume to (pico v)at the bottom.
Step 3 — the walk block
- Make a block
walkwith a number input calledspeed, and tick Run without screen refresh. - Build it from Learnt part 3.
- In the loop, replace each
change x by (4)withwalk (4) :: custom— and the left one withwalk (-4) :: custom.
Step 4 — a way back, and a goal
- If Pico falls into the gap, send it back to the start:
if <(y position) < (-150)> then. - Put a Star on the top step. Touching it makes Pico happy and say so.
when flag clicked
set rotation style [left-right v]
go to x: (-215) y: (-104)
set [y velocity v] to (0)
forever
if <key (right arrow v) pressed?> then
point in direction (90)
walk (4) :: custom
end
if <key (left arrow v) pressed?> then
point in direction (-90)
walk (-4) :: custom
end
change [y velocity v] by (-1)
change y by (y velocity)
land :: custom
if <<key (space v) pressed?> and <(on ground) = (1)>> then
set [y velocity v] to (12)
end
if <(y position) < (-150)> then
go to x: (-215) y: (-104)
set [y velocity v] to (0)
end
if <touching (Star v)?> then
switch costume to (pico happy v)
say [I made it!]
end
end
walk and the boxed land.How to use this: Click the green flag. Arrows to walk, space to jump. Climb the four steps to the star; try walking into a step’s side.
Pico flickers into a grey box.
A switch costume to (pico) is missing at the end of walk or land, or one of them was made without Run without screen refresh.
Pico cannot walk at all.
The hitbox reaches lower than Pico’s feet, so it is already touching the floor and every step is undone. Raise its bottom edge a little.
Pico still rides up onto steps without jumping.
The arrow keys still use change x by (4). They must call walk, or the side check never runs.
I cannot reach one of my steps.
It is more than 66 above the one below it, or further away than a running jump goes. That is Challenge 3.
Jumping under the low block teleports Pico on top of it.
Yes — that is Challenge 1.
Head bumps
Stand Pico under the low block and jump straight up. Then change land so that hitting green on the way up is a bump, not a landing.
- Going up into green: push Pico down until clear.
- Going down into green: push up, as before — and only that counts as on ground.
- Either way, the speed becomes 0.
How to use this: Click the green flag. Pico jumps under the block twice — once without the ceiling check, once with it.
Teacher reveal — which way to push
if <touching color [#3FA34D]?> then
if <(y velocity) > (0)> then
repeat until <not <touching color [#3FA34D]?>>
change y by (-1)
end
else
repeat until <not <touching color [#3FA34D]?>>
change y by (1)
end
set [on ground v] to (1)
end
set [y velocity v] to (0)
end
The speed says which way Pico was going when it hit the green, so it says which way is out. Positive: it hit a ceiling, push down. Otherwise it hit a floor, push up. Only the floor sets on ground — otherwise a bump would let Pico jump again from the ceiling.
Jumping from thin air
A common first version of on ground sets it to 1 on landing and back to 0 only when Pico jumps. Build that version, then walk off the side of step 1 and press jump while falling.
- A counter of
mid-air jumps. - Run it with the “only when jumping” version, then with the every-tick version.
- Explain the difference in one sentence.
How to use this: Click the green flag. Pico walks off step 1 twice and presses jump while falling each time.
Teacher note
Walking off an edge is the one way to leave the ground without jumping, so it is the one case the “clear it when you jump” version never handles. This is the reason Lesson 3-30 insisted on clearing on ground at the top of land — a flag that describes the world has to be re-asked every tick, not changed only when you remember to.
Can it be reached?
Every step in a level has to be reachable, and some things should not be. Test both with Pico’s real numbers.
- Jump at the low block from beside it. It is 90 up.
- Jump from step 3 to step 4. It is 50 up.
- Write a rule for your own levels using the number 66.
How to use this: Click the green flag. Pico tries the 90-pixel block, then the 50-pixel step.
Teacher note
Leaving a margin matters: a step exactly 66 up is reachable only from the one tick at the top of the jump, which feels impossible to a player. Around 50 with a jump of 66 gives a comfortable window. The same thinking applies to gaps and Lesson 3-30’s running-jump lengths.
A lift
Add a green platform that slides back and forth over the water. Pico must be able to ride it all the way across without sliding off.
- A
Liftsprite painted in the same green, moving 2 a tick there and back. - A
lift speedvariable the lift keeps up to date. - When Pico lands on the lift, Pico moves by the lift’s speed too.
How to use this: Click the green flag. Pico rides the lift twice: once with nothing carrying it, once carried.
Teacher note
The good moment is the first ride. Pupils expect Pico to move with the lift because that is what would happen in real life, and they have to notice that nothing in their code says so. A game world only does what a script makes it do.
Summary 5 min
- Platforms are more of the ground colour, and landing on them is free.
- A hitbox costume does the touching, so a wide head cannot catch on a corner.
walkis move-ask-undo on x;landis push-out on y. Keep them apart.- Hitting green while going up is a head bump: push down, and do not count it as ground.
- Every step must be reachable — keep it well under the height of a jump.
- Platform
- Something a character can stand on, jump onto and bump into.
- Hitbox
- The invisible shape that does the touching, simpler than the picture you see.
- Head bump
- Hitting a platform from underneath while going up.
- Reachable
- Close enough, and low enough, for the player’s jump to get there.
Hand in
Save your level. Next lesson the water bites, a crab walks the ground, and there is a star worth finishing for.