Game tutorial · Platformer
How to make a platformer game in Scratch (step by step, with an AI helper)
A platformer is a game where a character runs and jumps from platform to platform – think of the classic side-scrolling adventures. In this guide you build one in Scratch 3 from scratch: a player that falls with gravity, lands on platforms, walks into walls without walking through them, jumps with the space key and reaches a goal. Every step has the exact blocks, and we point out where Bee, the AI buddy in Enimist's Maker Studio, can help when you get stuck.
Plan the game and make the sprites
Before snapping blocks, decide three things: who the player is, what the platforms look like and how you win. For a first game keep it small: one player sprite, one sprite called “Ground” that holds every platform, and one “Goal” sprite such as a flag.
Draw the Ground sprite in the paint editor with the rectangle tool: a long floor at the bottom and three or four shorter platforms higher up. Using one sprite for all platforms matters, because later a single block – touching Ground? – checks all of them at once.
Keep the player costume small (about 40 pixels tall). Big sprites get stuck on platform edges more easily.

Tip: In the Maker Studio, tap the “Draw for me” chip in the Bee panel and describe your hero or a backdrop (“a sunny sky with hills”). Bee draws a vector picture you can still edit in the paint editor.
Add gravity with a “y speed” variable
Real games don't move the player a fixed amount every frame – they keep a speed and change it a little at a time. Make a variable called “y speed” (For this sprite only). Each frame, gravity pulls the speed down by 1, and the player moves by the speed.
Because the speed keeps growing, the player falls slowly at first and then faster – exactly like a real jump arc. This is the most important idea in every platformer.
when green flag clicked set rotation style [left-right] go to x: (-180) y: (0) set [y speed] to (0) forever change [y speed] by (-1) change y by (y speed)
Land on the platforms
Right now the player falls straight through the floor. Inside the forever loop, after moving, check if the player is touching Ground. If it is, push it up one pixel at a time until it isn't – then it stands exactly on top of the platform – and reset the speed to 0.
Pushing up pixel by pixel with repeat until is more reliable than jumping back by the speed, because the player might have sunk a different amount each time.
if <touching (Ground)?> then
repeat until <not <touching (Ground)?>>
change y by (1)
set [y speed] to (0)Walk left and right – without walking through walls
Add two ifs at the top of the forever loop: right arrow moves 4 steps to the right and points the sprite right, left arrow does the opposite. The rotation style left-right you set earlier keeps the sprite from turning upside down.
To stop the player from walking through the side of a tall platform, check Ground right after each horizontal move. If the player is now inside a wall, undo the move. Because the landing step keeps the player just above the floor, standing on a platform never counts as touching a wall.
if <key (right arrow) pressed?> then
point in direction (90)
change x by (4)
if <touching (Ground)?> then
change x by (-4)
if <key (left arrow) pressed?> then
point in direction (-90)
change x by (-4)
if <touching (Ground)?> then
change x by (4)Jump with the space key
The player may only jump while standing on something, otherwise it could fly by holding space. The landing check already knows that moment: it is inside the “if touching Ground” block. Replace the last block of that step with an if – else: when space is pressed, set y speed to 12, otherwise set it to 0.
Try different numbers. A jump speed of 12 with gravity −1 reaches about 70 pixels high. If the jump feels floaty, make gravity −1.5; if platforms are too high, raise the jump speed.
if <key (space) pressed?> then set [y speed] to (12) else set [y speed] to (0)
Falling off and reaching the goal
Add one more if to the loop: if the player's y position drops below −170 it fell off the screen, so send it back to the start and reset the speed.
For the goal, give the Goal sprite its own script: when green flag clicked, forever, if touching the player, say “You win!” for 2 seconds and stop all. Add a coin sprite and a “score” variable when you want more – change score by 1 when the player touches a coin, then hide the coin.
if <(y position) < (-170)> then go to x: (-180) y: (0) set [y speed] to (0)
Stuck? How the AI buddy can help
In Enimist's Maker Studio, Bee can see your sprites and blocks, so you can ask about your own project: “Why does my player fall through the platform?” Bee answers briefly, names the exact block and asks a guiding question instead of writing the whole game for you.
Want Bee to build it? Type what you want – “add a double jump to my player” – and Bee reads your project, prepares the change as a draft card (“Bee will: add 1 script(s)”) and waits. Tap Apply to put it in your project, or Discard; after applying, Undo puts everything back. Then tap “Done” to see how much of the game you made yourself.
Ideas to try next: a double jump (count jumps in a variable), moving platforms (a second Ground-like sprite that glides), or a second level (switch the Ground costume when the player reaches the goal).

Scratch is a project of the Scratch Foundation, in collaboration with the Lifelong Kindergarten Group at the MIT Media Lab. Enimist Studio is not affiliated with Scratch or the Scratch Foundation.
