Introduction – Platformer Game in Scratch
Have you ever wanted to build your own Mario-style platformer game in Scratch? This step-by-step guide will walk you through how to make a 3-level platformer game in Scratch — featuring a jumping hen, coins (eggs) for scoring, water hazards, and lives.
This tutorial is perfect for beginners learning Scratch programming, game animation, and interactive storytelling. Inspired by the video tutorial from Kodex Academy, we’ll turn a simple animation into a complete playable game.
By the end of this guide, you’ll master:
- How to design multiple levels in Scratch
- How to code jump, gravity, and movement physics
- How to implement score and life tracking
- How to make level transitions and win/lose conditions
- How to enhance your game with sound effects and animations
What You’ll Need
Before starting, head to Scratch and open a new project.
You’ll use the Scratch editor to:
- Add sprites (like the Hen and Egg)
- Create levels using custom-painted backdrops
- Code game logic using Scratch’s visual programming blocks
Scratch Coding for 3-Level Platformer Game
Step 1: Setting Up the Game Characters
Delete the Default Cat Sprite
- Click on the cat sprite and delete it.
Add a Hen Sprite
- Click Choose a Sprite → Search “Hen”.
- Resize it to 50% so it fits the level layout.
- Keep only two costumes for smoother animation (delete costume 3 and 4).
Create the Level Sprite
- Click Paint → Draw rectangles to form platforms.
- Choose brown for land, and blue for water.
- Name the sprite “Level” and create 3 costumes:
- Costume 1: Level 1
- Costume 2: Level 2
- Costume 3: Level 3
Step 2: Coding the Hen’s Jump and Gravity
Create smooth up-down movement using a custom block.
Create a Custom Block
My Blocks → Make a Block → Name it “Up Down Movement”
Add two inputs:
jump heightfall speed
✅ Check Run Without Screen Refresh
Variables Required
Y velocity(for vertical movement)
Code for Jump & Gravity
when green flag clicked
set size to 50
set [Y velocity v] to 0
forever
Up Down Movement (15) (-1)
end
Define Up Down Movement (jump height) (fall speed)
change y by (Y velocity)
if <touching [level v]?> then
set [Y velocity v] to (0)
else
change [Y velocity v] by (fall speed)
end
if <key [up arrow v] pressed?> then
set [Y velocity v] to (jump height)
end
Now the hen jumps when the up arrow is pressed and falls back smoothly.
Step 3: Coding Left and Right Movement
Create Another Custom Block
My Blocks → Make a Block → “Left Right Movement”
Add inputs:
move speeddrag
Variables
X velocity
Code for Horizontal Movement
- define Left Right Movement (move speed) (drag)
if <key [right arrow v] pressed?> then
set [X velocity v] to (move speed)
point in direction (90)
else
if <key [left arrow v] pressed?> then
set [X velocity v] to ((move speed) * (-1))
point in direction (-90)
else
set [X velocity v] to ((X velocity) * (drag))
end
end
change x by (X velocity)
Add this inside the forever loop with the Up Down Movement block.
Step 4: Switching Between Levels
When the hen reaches the end of the screen, it should move to the next level.
Code for Level Transition
if <(x position) > [235]> then
broadcast [next level v]
end
In the Level Sprite:
when I receive [next level v]
change [level v] by (1)
next costume
This code switches to the next level background and increases the level counter.
Step 5: Detecting Water and Falling Off
If the hen touches water or falls below the stage, it should lose a life.
Code for Water & Fall Detection
# define Check Touching Water
if <touching color [#3399FF]> then
change [lives v] by (-1)
go to x: (-203) y: (-71)
end
# define Check Fall Off Screen
if <(y position) < [-170]> then
change [lives v] by (-1)
go to x: (-203) y: (-71)
end
Step 6: Adding the Egg and Scoring System
Add an Egg sprite for scoring.
Egg Setup
when green flag clicked
go to x: (100) y: (50)
switch costume to [egg1 v]
In Hen Sprite:
if <touching [egg v]?> then
broadcast [egg hatch v]
end
In Egg Sprite:
when I receive [egg hatch v]
switch costume to [egg2 v]
change [score v] by (1)
play sound [coin v]
wait (0.5) seconds
Step 7: Adding Win and Game Over Conditions
Variables
scorelives(set to 3 initially)
Code in Hen Sprite
when green flag clicked
set [score v] to (0)
set [lives v] to (3)
if <(score) = [10]> then
broadcast [you win v]
end
if <(lives) = [0]> then
broadcast [game over v]
end
Backdrop Code
when I receive [you win v]
switch backdrop to [You Win v]
when I receive [game over v]
switch backdrop to [Game Over v]
Step 8: Add Sound Effects and Animation
Enhance player engagement by adding:
- Jump Sound: when the up arrow is pressed
- Coin Sound: when the egg hatches
- Background Music: looped sound in the stage
You can find free sounds at Freesound.org or within the Scratch sound library.
Final Gameplay
Now test your game!
- Jump with Up Arrow
- Move with Left/Right Arrows
- Collect Eggs for score
- Avoid Water or falling off the screen
- Win when score = 10
- Lose when lives = 0
🎥 Watch the original video tutorial for visual guidance: How to Make a 3-Level Platformer Game in Scratch | Mario-Style Hen Adventure Game – by Kodex Academy
Enhancement Ideas
Take your game to the next level! Try adding:
1. Power-ups
Add a new sprite like a “star” that gives temporary invincibility.
when green flag clicked
forever
if <touching [star v]?> then
set [invincible v] to [true]
wait (5) seconds
set [invincible v] to [false]
end
end
2. Enemy Sprites
Create a walking enemy and code collision detection to decrease lives.
3. Background Music & Level Transitions
Use different backdrop music for each level using the “play sound until done” block.
4. Double Jump Feature
Add an advanced jump mechanic:
# define Double Jump
if <key [up arrow v] pressed?> then
if <(jump count) < [2]> then
change [Y velocity v] by (15)
change [jump count v] by (1)
end
end
if <touching [level v]?> then
set [jump count v] to (0)
end
Conclusion: Mario-Style Hen Adventure Game
Congratulations! You’ve successfully created your very own 3-Level Platformer Game in Scratch — complete with jumping mechanics, multiple levels, scoring, lives, and water hazards. This project not only helps you understand how to make a platformer game in Scratch, but also teaches essential concepts of game physics, event handling, and character animation that form the foundation of game development.
From a simple idea inspired by classic Mario games, you’ve built an engaging adventure featuring a lively hen that runs, jumps, and collects eggs across colorful levels. With just a few creative touches and Scratch coding blocks, you turned animation into an interactive gaming experience!
But don’t stop here — Scratch allows endless creativity! Try adding new levels, power-ups, moving enemies, background music, or even a double jump feature to make your game more dynamic and fun.
Call to Action
- Don’t forget to check out the full video tutorial: How to Make a 3-Level Platformer Game in Scratch | Mario-Style Hen Adventure Game – by Kodex Academy
- Like, comment & share the video
- Visit kodexacademy.com
- subscribe to the Kodex Academy YouTube channel for deeper Scratch content.
Happy coding with Kodex Academy! 🚀
Learn More with Kodex Academy
At Kodex Academy, we’re passionate about helping students learn coding in creative ways. This project teaches more than Scratch—it empowers young minds to build tools that work in the real world.
Explore more:
Stay updated with new content, free tutorials, and coding challenges!
- 🌐 Website: https://kodexacademy.com
- 🌐 Website: https://games.kodexacademy.com
- 💬 WhatsApp Channel: Join Now
- 💼 LinkedIn: Kodex Academy
- 📸 Instagram: @kodex_academy
- 𝕏 Twitter: @Kodex_Academy
- 📢 Telegram: Join Our Channel
- 🔗 Patreon: patreon.com/KodexAcademy
Further Reading & Links
- Scratch Wiki Motion Blocks: https://en.scratch-wiki.info/wiki/Motion_Blocks
- Scratch Programming for Beginners: https://scratch.mit.edu/projects/editor
- Scratch Animation Guide: https://en.scratch-wiki.info/wiki/Animating








