Ground check: if y is below ground → put y on ground and stop falling.
Jump: if on ground AND SPACE → set yVelocity = jumpForce.
Think: What if gravity is −3 instead of −1?
It pulls down faster. Jumps feel shorter and harder.
Think: Why use yVelocity at all?
It keeps track of how fast we move. This makes jumps smooth.
Part 1
Build steps
Draw the ground line on the Stage.
Make sprites: Cube; Spike (keep hidden for now).
Make variables (for all sprites): yVelocity, gravity,
jumpForce.
On green flag: set gravity=-1, jumpForce=14, yVelocity=0, go
to x:-150 y:-120.
Forever: change yVelocity by gravity; change y by yVelocity.
Ground: if y < -120 → set y to -120; if yVelocity
< 0 → set to 0.
Jump: if SPACE and on ground → set yVelocity = jumpForce.
Part 1
Blocks to build
when green flag clicked
set [gravity v] to [-1]
set [jumpForce v] to [14]
set [yVelocity v] to [0]
go to x: (-150) y: (-120)
forever
change [yVelocity v] by (gravity)
change y by (yVelocity)
if <(y position) < (-120)> then
set y to (-120)
if <(yVelocity) < (0)> then set [yVelocity v] to (0)
if <key [space v] pressed?> and <(y position) = (-120)> then
set [yVelocity v] to (jumpForce)
Part 1
Check & challenge
Quick check: The cube lands without shaking.
Bug hunt: Did you use yVelocity (not just gravity)?
Challenge: Stop double‑jump. Only jump when on ground.
Exit ticket: Which variable makes jumps higher?
Part 1
Q&A: The 3 important variables
What is yVelocity?
It is the cube’s up/down speed right now.
When you jump, yVelocity is positive (goes up).
When you fall, gravity makes yVelocity smaller, then negative (goes down).
On the ground, we set yVelocity to 0 so it stops.
What is gravity?
A small number we add every step that pulls the cube down.
We add it to yVelocity each frame.
More negative gravity = stronger pull down = harder game.
Example: −1 is gentle, −3 is very strong.
What is jumpForce?
How strong the push up is when you press SPACE.
On jump, we set yVelocity = jumpForce.
Bigger jumpForce = higher jump.
Too big can make the game too easy or buggy.
Part 2
Spikes with Clones
Goal (30 min)
Make spikes appear from the right.
Move left and disappear off the screen.
Variable:gameSpeed = 7
Part 2
How it works
Original Spike: hide; repeat → wait a random time → make a clone.
Clone Spike: show; go to x:260 y:-120; move left by -gameSpeed.
When x < -260: delete this clone (remove it).
Why clones: we can have many spikes at once, each with its own timing.
Repeat until x position < -260: change x by 0 - gameSpeed.
After the loop: delete this clone.
Extra: pick a random costume (single or double spike) before moving.
Part 2
Blocks to build
when green flag clicked
hide
forever
wait (pick random (0.8) to (1.6)) seconds
create clone of [myself v]
when I start as a clone
show
go to x: (260) y: (-120)
repeat until <(x position) < (-260)>
change x by ((0) - (gameSpeed))
delete this clone
Part 2
Check & challenge
Quick check: Spikes come in, move left, and go away.
Bug hunt: Is the original spike hidden?
Challenge: Sometimes spawn two spikes very close together.
Exit ticket: Show the block that deletes clones off‑screen.