Course

Geometry Dash in Scratch

Two short lessons. We build together. Questions have click‑to‑see answers.

Today

Part 1

Gravity and Jump

Goal (30 min)

Sprites: Cube, Spike (hide), Backdrop ground

Variables: yVelocity, gravity = -1, jumpForce = 14

Part 1

How it works

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

  1. Draw the ground line on the Stage.
  2. Make sprites: Cube; Spike (keep hidden for now).
  3. Make variables (for all sprites): yVelocity, gravity, jumpForce.
  4. On green flag: set gravity=-1, jumpForce=14, yVelocity=0, go to x:-150 y:-120.
  5. Forever: change yVelocity by gravity; change y by yVelocity.
  6. Ground: if y < -120 → set y to -120; if yVelocity < 0 → set to 0.
  7. 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

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)

Variable: gameSpeed = 7

Part 2

How it works

Think: What if we forget to delete clones?

They pile up off‑screen and slow the game.

Think: What happens if we set gameSpeed to 12?

Spikes move faster, so the game gets harder.

Part 2

Build steps

  1. On green flag set gameSpeed = 7.
  2. Spike (original): hide; forever → wait 0.8–1.6s → create clone of myself.
  3. When I start as clone: show; go to x:260 y:-120.
  4. Repeat until x position < -260: change x by 0 - gameSpeed.
  5. After the loop: delete this clone.
  6. 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