Scratch lesson 15 of 20 · Advanced · About 55–70 minutes
Build a two-jump platformer. Make a runner fall, jump and stop at solid ledges using gravity, wall checks and tiny moves that keep the runner inside the level.
What you’ll make A platformer with left and right movement, jumping only from the ground, solid ledges and a flag to reach.
Get ready
Open the Scratch editor (opens in a new tab) and start a new project.
- Paint a bitmap backdrop with a light background. Draw a thick floor across the whole Stage, with its top about one-quarter of the Stage height from the bottom.
- Use one dark, flat colour for the floor and platforms. Above the floor, draw a ledge roughly 40 units higher on the left and another roughly 40 units higher on the right. Leave a short gap between the ledges. Use the Stage width of 480 units for scale.
- Paint a small, filled rectangle sprite about 18 units tall and name it Runner. Keep the costume centred and use a colour different from the platforms. Drag it above the floor near the left. Read the x and y in the sprite panel. Those numbers are your starting point.
- Paint a bright Goal sprite and drag it just above the top ledge. Keep it small enough to make reaching it a clear target.
- For this sprite only on Runner, make Fall speed, Grounded, Jump held, Side step and Vertical step. Display Fall speed and Grounded while testing.
To keep your project, choose File → Save to your computer in Scratch.

Build it in Scratch
Choose the sprite named above each stack. The colours help you find the block categories. Indented rows sit inside the block above. Follow the end marker to see where each loop or condition closes.
1. Check whether there is ground under the runner
Select Runner. In My Blocks, make check ground and tick Run without screen refresh, so the tiny test movement is hidden. Move down one pixel, check the platform colour and move back up straight away. In touching color?, open the colour swatch, use the eyedropper and click well inside a painted platform on the Stage. The outline or background may be a different colour.
define check groundset [Grounded] to (0)change y by (-1)if <touching color [platform colour]?> thenset [Grounded] to (1)change y by (1)2. Move sideways one pixel at a time
Make move sideways with Run without screen refresh ticked. Read the arrows once, then make four small moves in the chosen direction. On each move, check the new x position stays within the screen margin, then undo the last pixel if it touches the solid colour. Sample the same interior colour for this second sensing block. The abs reporter lets one boundary check work at both Stage edges.
define move sidewaysset [Side step] to (0)if <key [left arrow] pressed?> thenchange [Side step] by (-1)if <key [right arrow] pressed?> thenchange [Side step] by (1)repeat (4)if <([abs] of ((x position) + (Side step))) < (221)> thenchange x by (Side step)if <touching color [platform colour]?> thenchange x by ((0) - (Side step))3. Stop vertical movement when the runner hits a platform
Make move vertically with Run without screen refresh ticked. Take one-pixel steps up or down. The size of Fall speed tells Scratch how many to attempt. If a step would enter solid colour, undo it and set the speed to 0. The not check skips the remaining moves that frame. This handles landing and bumping the underside of a ledge with the same block.
define move verticallyset [Vertical step] to (-1)if <(Fall speed) > (0)> thenset [Vertical step] to (1)repeat ([abs] of (Fall speed))if <not <(Fall speed) = (0)>> thenchange y by (Vertical step)if <touching color [platform colour]?> thenchange y by ((0) - (Vertical step))set [Fall speed] to (0)4. Add gravity and one jump per press
Build the green-flag script on Runner. Replace the example start coordinates with the ones you recorded after placing your sprite above the floor. Sideways movement comes before the ground check, so stepping off a ledge stops you jumping from its old position. Gravity subtracts 1 from the vertical speed each frame. The cap of −12 limits the number of collision checks. A jump sets the speed to 11 only when grounded and when Space has just been pressed. The fourth custom block is in the next step. Keep the green-flag loop outside the custom blocks so Scratch redraws between frames.
when green flag clickedgo to x: (-185) y: (-75)set [Fall speed] to (0)set [Jump held] to (0)say []forevermove sidewayscheck groundchange [Fall speed] by (-1)if <(Fall speed) < (-12)> thenset [Fall speed] to (-12)check jump keymove verticallyif <touching [Goal]?> thensay [You reached the flag!]stop [this script]wait (0.02) seconds5. Check for a new press of Space
Make check jump key and add its definition below. Jump held remembers the previous frame. When Space is down after being up, only a grounded runner can jump. Let go to re-arm the key. Click the green flag to test a fresh run. If your top ledge feels impossible to reach, lower it slightly before adjusting the physics.
define check jump keyif <key [space] pressed?> thenif <<(Grounded) = (1)> and <(Jump held) = (0)>> thenset [Fall speed] to (11)set [Jump held] to (1)elseset [Jump held] to (0)Test your project
- Click the green flag without touching the keys. Runner should fall to the floor, then stay level. Grounded should read 1 after landing.
- Jump into the underside of a ledge and watch for a clean stop and fall. Jump beside the ledge and steer onto the top. Check that holding Space does not cause another jump on landing.
- Step off a ledge without Space. Runner should fall. Reach the flag, then click the green flag again and check that the win bubble disappears.
If something goes wrong
- Runner falls through the floor or passes into a wall.
- Sample the platform colour again in all three touching color blocks. Paint flat filled shapes with thick interiors.
- Runner is stuck as soon as the game starts.
- With the project stopped, drag Runner fully above the floor and away from ledges. Use the sprite panel to replace the start coordinates.
- The goal is hard to reach.
- Move the ledges closer together or reduce their height difference. Test each jump before adding another obstacle.
Make it your own
- Add a third ledge using the same solid colour. Confirm it behaves like the others without any new collision script.
- Try a starting jump speed of 9 and compare how high Runner reaches. Put it back to 11 if the level needs the extra height.
What you’ve learned Gravity changes speed, speed changes position, and small collision steps protect solid surfaces. Testing the horizontal and vertical axes separately makes each collision easier to predict.