⚡ G-Warp

Tutorial 3: Make a platformer jump

You will make: a sprite that falls under gravity and can jump from a colored floor. You will use a gravity variable, the touching color [ ]? block, and if on edge, bounce. This is a starter physics demo, not a complete collision engine.

Step 1 — Draw the floor

  1. Make a simple backdrop with a solid green strip along the bottom. Note the color you used; the sensing block must match it.
  2. Select your player sprite and place it just above the strip. Save a backup copy.

Step 2 — Create two variables

  1. In Variables, make vertical speed and gravity.
  2. Use gravity as a small negative number, for example -0.5. Negative gravity pulls the player downward in this simple coordinate setup.

Step 3 — Add the falling loop

Use these block families to build the stack. Snap every line in order:

when flag clicked
set [vertical speed] to (0)
set [gravity] to (-0.5)
forever
  change y by (vertical speed)
  change [vertical speed] by (gravity)
  if <touching color [green]?> then
    if <(vertical speed) < (0)> then
      set [vertical speed] to (0)
  if on edge, bounce

Choose the same green as the floor in touching color [ ]?. The nested checks stop downward speed only when the player is touching the floor and is falling.

Step 4 — Add a jump

when [space] key pressed
if <touching color [green]?> then
  set [vertical speed] to (10)

Use the when [space] key pressed event. Change (10) to tune the jump height. If the jump never fires, make sure the player is actually touching the exact floor color when Space is pressed.

Test and tune

  1. Press Start: the player should fall and settle on the green floor.
  2. Press Space while standing on the floor. The sprite should jump and fall back down.
  3. Change gravity a little at a time. More negative gravity pulls down faster; a larger jump speed sends the player higher.
  4. Use the edge bounce block only if you want the player to turn away from Stage edges; remove it for a game where leaving the screen should end a jump.

Gotcha: a color collision only sees the chosen visible color. If the floor has gradients or decorations, use a flat collision strip or test the result carefully. This tutorial has not been runtime-tested against every build; confirm any nested Boolean block can be assembled in your current palette.

Glossary → · Parents & teachers → · All tutorials