Start with the sprite and the stage
A platformer needs a character that can move left and right and jump. In Scratch, that character is a sprite. Open Scratch, delete the default cat sprite, and upload or draw your own character — something simple works best while you are learning. Make it face right so you know which direction it is moving.
Next, set up your stage. The stage is the background where the game happens. You can draw a simple landscape with platforms, or use one of Scratch's built-in backgrounds and add platforms on top using the paint editor. Platforms are just rectangles — they do not need to be fancy. Make them a different color from the background so the sprite can land on them clearly.
Save your project now. Give it a name like "My First Platformer" so you do not lose your work.
Key Takeaways
- A platformer sprite needs four separate scripts: one for moving left and right, one for jumping, one for falling, and one to detect when it touches the ground.
- Jumping works by setting the sprite's vertical speed to a negative number, then letting gravity pull it back down each frame.
- Platforms are detected using the "touching color" block, which checks if the sprite's bottom is touching a platform color.
- Test your controls after each script you add so you can fix problems before they pile up.
Make the sprite move left and right
Click on your sprite and go to the Code tab. You will build scripts using blocks. Start with movement: when the player presses the left arrow key, the sprite should move left, and when they press the right arrow key, it should move right.
Drag a "when key pressed" block onto the canvas. Set it to "left arrow". Attach a "change x by" block below it and set the value to -5. This moves the sprite 5 pixels to the left each time the key is pressed. Repeat this for the right arrow, but change x by 5 (positive this time) to move right.
Test it: click the green flag to start the game and press the arrow keys. Your sprite should slide left and right across the stage. If it moves too fast or too slow, adjust the number — higher numbers mean faster movement.
Add gravity and falling
Right now your sprite does not fall. You need a script that pulls it down constantly. Create a new script with a "when green flag clicked" block. Below it, add a "forever" loop. Inside the loop, put a "change y by" block set to 5. This makes the sprite fall 5 pixels every frame.
Test it: start the game and watch your sprite fall off the bottom of the stage. That is gravity working. You will add a floor and platforms next to stop the falling.
The y-axis in Scratch points up, so positive numbers move the sprite down. If your sprite is moving the wrong direction, flip the sign.
Detect when the sprite touches a platform
Your sprite needs to stop falling when it lands on something. Platforms are usually a solid color — let us say brown. You will use the "touching color" block to check if the sprite is touching brown.
In your gravity script, find the "forever" loop where you added the falling code. Before the "change y by 5" block, add an "if" block. Inside the condition, put "touching color brown". If the sprite is touching brown, it should not fall — so inside the "if" block, set the y velocity to 0 or do nothing. If it is not touching brown, then apply gravity by changing y by 5.
Paint the bottom of your stage brown, or paint your platforms brown. Test the game: your sprite should now fall and stop when it hits a brown platform.
Make the sprite jump
Jumping is the core of a platformer. When the player presses the space bar and the sprite is touching the ground, the sprite should move up quickly, then slow down and fall back down. This happens because you set the vertical speed to a negative number (up), and gravity pulls it back to zero and beyond (down).
Create a new script: "when space key pressed". Add an "if" block that checks "touching color brown". Inside the "if" block, set a variable called "y velocity" to -15. This is the upward speed. The negative number means up.
Now go back to your gravity script. Instead of "change y by 5", use "change y by y velocity". Then add "change y velocity by 1" below it. This makes the sprite slow down as it rises, stop at the peak, and speed up as it falls — just like real gravity.
Test it: press space while standing on a platform. Your sprite should jump up and fall back down. Adjust the -15 number to make jumps higher or lower.
Add more platforms and test the full game
Now that movement, gravity, and jumping work, paint more platforms on your stage at different heights. Make a simple path the sprite can follow by jumping from one platform to the next. Keep platforms close enough that the sprite can reach them with a normal jump.
Play through your game. Jump across all the platforms. If a jump feels impossible, move the platform closer or increase the jump height. If the sprite gets stuck in a platform or falls through one, check that the platform color matches the color you used in the "touching color" block.
Common problems: if the sprite jumps multiple times in the air, it means the jump script is not checking if the sprite is on the ground. If the sprite does not jump at all, the variable "y velocity" might not be set up correctly. Go back and check each script block by block.
Expand with a goal and obstacles
A platformer is more fun with a goal. Create a new sprite — maybe a star or a flag — and place it at the end of your platform path. Add a script to that sprite: "if touching [your character sprite], broadcast 'win'". Then add a script to your stage that listens for the "win" broadcast and displays a message like "You won!"
You can also add obstacles. Create a sprite that is a different color — say red — and place it on some platforms. Add a script to your character: "if touching color red, broadcast 'lose'". Then add a "lose" handler that resets the game or shows a game-over message.
These additions turn your platformer from a movement exercise into an actual game with a win condition and failure states.
Frequently Asked Questions
Why does my sprite get stuck inside platforms?
The sprite is probably falling too fast or the platform detection is not working. Make sure the color in your "touching color" block exactly matches the platform color. If the sprite sinks partway into a platform before stopping, lower the gravity number (change it from 5 to 3 or 2) so it falls more slowly and stops sooner.
How do I make the sprite face the direction it is moving?
Add a "point in direction" block to your left and right movement scripts. When moving left, point the sprite to 180 degrees. When moving right, point it to 0 degrees. This makes the sprite turn to face where it is going.
Can I add a double jump?
Yes. Create a variable called "jumps left" and set it to 2 when the sprite touches the ground. Each time the space bar is pressed, subtract 1 from "jumps left" and only allow the jump if "jumps left" is greater than 0. When the sprite lands, reset "jumps left" to 2.
How do I make platforms move?
Add a "forever" loop to a platform sprite with "change x by 3" to move it horizontally or "change y by 3" to move it vertically. Your character will move with it because the gravity script checks "touching color" every frame. Moving platforms are trickier to land on, so test them carefully.
What if my game is too easy?
Make platforms smaller, space them farther apart, or lower the jump height by reducing the -15 value in your jump script. You can also add moving platforms, obstacles, or time limits to increase difficulty.