- Learnt28 min · water, and a star
- Basic24 min · the level
- Challenge 1–327 min · a checkpoint, a crab, the stomp
- Extrabonus · ship it
Review — the arc so far 5 min
- Gravity changes the speed; the speed changes y; a jump sets the speed.
landpushes out of floors and ceilings;walkundoes moves into walls.- A hitbox costume does the touching, and nobody ever sees it.
Quick-fire
You can climb your level from bottom to top. Why is it not a game yet?
Reveal the answer
You cannot lose and you cannot win. A game needs a way to fail — the water, a crab — and a moment that says you have finished. Both are things you already know how to build; today puts them in the level.
Today’s Topic 3 min
- A second rule colour: water
- A
statevariable withplay,wonandover— from Storm Flight - A respawn point that a checkpoint can move
- An enemy you can defeat from above
Learning outcome
By the end of this lesson you will be able to:
- Give a level a hazard, lives and a goal.
- Move the place a player comes back to.
- Tell a stomp from a collision using the speed.
Learnt — losing and winning 28 min
1 · A second rule colour
The pit is painted one flat blue, and blue means water. It is the same question as the ground, about a different colour — and a different answer:
if <touching color [#2F80ED]?> then
change [lives v] by (-1)
go to x: (-215) y: (-104)
set [y velocity v] to (0)
end
land. Blue costs a life and a position.How to use this: Click the green flag. Pico walks off the end of step 2 into the water.
2 · A goal, and a state
Touching the star wins. But the loop is still reading the arrow keys, still falling, still checking the water — so the win needs to stop the game. That is Storm Flight’s state variable:
forever
if <(state) = [play]> then
land :: custom
if <touching (Star v)?> then
set [state v] to [won]
switch costume to (pico happy v)
say [Level complete!]
end
end
end
land as before. The whole game lives inside if <(state) = [play]> then, so when the state changes, the game simply stops happening.How to use this: Click the green flag and watch Pico climb to the star on its own.
Basic — the level 24 min
Open your climber from last lesson. Today it becomes a game you can win and lose.
Step 1 — two new variables
- Make
livesandstate, both with their monitors showing. - When the flag is clicked, set
livesto 3 andstatetoplay.
Step 2 — the water bites
- Delete last lesson’s
if <(y position) < (-150)> thencheck — the water does that job now. - After
land, add the water check from Learnt part 1. Pick the blue with the eyedropper. - Inside it, if
liveshas reached 0, setstatetooverand say so.
Step 3 — the whole game inside one if
- Put an
if <(state) = [play]> theninside the forever. - Drag everything that was in the forever into it.
- Change the star check so it sets
statetowon.
Step 4 — play it both ways
- Win it. Check nothing moves afterwards.
- Then lose on purpose three times, and check the game really ends.
when flag clicked
set rotation style [left-right v]
go to x: (-215) y: (-104)
set [y velocity v] to (0)
set [lives v] to (3)
set [state v] to [play]
forever
if <(state) = [play]> then
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 <touching color [#2F80ED]?> then
change [lives v] by (-1)
go to x: (-215) y: (-104)
set [y velocity v] to (0)
if <(lives) = (0)> then
set [state v] to [over]
say [Out of lives.]
end
end
if <touching (Star v)?> then
set [state v] to [won]
switch costume to (pico happy v)
say [Level complete!]
end
end
end
walk and land are the boxed ones from Lesson 3-31, with the ceiling check from its Challenge 1.How to use this: Click the green flag. Arrows to walk, space to jump. Reach the star — and try falling in the water.
One splash takes all three lives.
The go-to is missing, so Pico is still in the water on the next tick and the tick after that. Moving Pico out is what stops it counting again.
After I win, Pico still falls and walks.
Some blocks are outside the if <(state) = [play]>. Drag them in.
The water never does anything.
The blue was picked from the colour wheel, not from the Stage. Two blues that look the same are not the same — pick it with the eyedropper.
Pico gets the happy face for a moment and then loses it.
land and walk switch back to pico every tick. Once the state is won they stop running, so the happy face stays — check the star test sets the state.
A checkpoint
Put a flag on step 2. Once Pico has touched it, the water sends Pico back to the flag instead of the start.
- Two variables,
respawn xandrespawn y, set to the start when the flag is clicked. - The flag changes costume when it is reached, and moves the respawn point to itself.
- The water now uses
go to x: (respawn x) y: (respawn y).
How to use this: Click the green flag. Pico climbs to the flag, then walks off into the water.
Teacher note
The move worth pointing out: the respawn point stopped being two numbers typed into a block and became two variables. Anything in the game can change a variable — so anything can now decide where you come back. That is the whole idea of a checkpoint.
A crab on patrol
Add a crab that walks back and forth along the right-hand bank.
- It walks 30 ticks one way and 30 back, for ever — Cheese Maze’s patrol.
- Touching it costs Pico a life and sends it to the respawn point.
- The crab stops when the state is not
play.
How to use this: Click the green flag. Pico stands still on the right-hand bank and waits.
Teacher note
The crab moves with change x by (-3) in a repeat rather than glides, so it can be asked to stop at any tick. A glide cannot be paused halfway — which matters the moment the state stops being play.
The stomp
Landing on the crab should defeat it. Walking into it should still hurt.
- Touching the crab while
y velocityis below 0 — falling — is a stomp. - A stomp hides the crab and bounces Pico up a little.
- Any other touch costs a life, as before.
How to use this: Click the green flag. Pico jumps as the crab comes and lands on top of it.
Teacher reveal — the speed tells you which way
if <touching (Crab v)?> then
if <(y velocity) < (0)> then
broadcast [stomped v]
set [y velocity v] to (8)
else
change [lives v] by (-1)
go to x: (respawn x) y: (respawn y)
set [y velocity v] to (0)
end
end
The same trick as the head bump in 3-31: the sign of y velocity says how Pico arrived. Falling means from above. The bounce of 8 is not physics, it is feedback — a stomp that does not bounce feels like nothing happened.
Ship it
Put the whole arc together into a platform game you would hand to somebody else.
- A title that explains the keys, then a round that starts from it.
- Falling, jumping, steps, walls, head bumps and a hitbox.
- Three lives, water, a checkpoint and a crab you can stomp.
- A clock, and a best time that survives the round.
How to use this: Click the green flag, read the title, then play: arrows to walk, space to jump. Reach the star.
Teacher note
Notice how little of this lesson was new code. Lives and states are Storm Flight; the patrol is Cheese Maze; the clock and the best time are 3-27’s. The only genuinely new idea is reading the sign of a speed to tell a stomp from a collision. A finished game is mostly the pieces you already had, put in the right order.
Summary 5 min
- A second flat colour can be a second rule: green holds you up, blue takes a life.
- After a teleport, set the speed to 0 — somewhere new means starting still.
- The whole game sits inside
if <(state) = [play]> then, so winning or losing simply stops it. - A checkpoint is a respawn point kept in variables that the level can change.
- Falling onto an enemy is a stomp; the sign of
y velocitytells you which.
- Hazard
- Anything in a level that costs a life to touch.
- Respawn point
- Where the player comes back after losing a life.
- Checkpoint
- A place that moves the respawn point once you reach it.
- Stomp
- Defeating an enemy by landing on it from above.
Hand in
Save your game. You have finished the Jump Quest arc — a character made of a number that gravity changes, on one screen you painted yourself.