How to Make a 3-Level Platformer Game in Scratch | Mario-Style Hen Adventure Game

Scratch Game

How to Make a 3-Level Platformer Game in Scratch Mario-Style Hen Adventure Game

1. 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

1.1 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

2. Scratch Coding for 3-Level Platformer Game

2.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

2.2 Coding the Hen's Jump and Gravity

Create a Custom Block

My Blocks → Make a Block → Name it "Up Down Movement"

Add two inputs:

  • jump height
  • fall 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 then
  set [Y velocity v] to (0)
else
  change [Y velocity v] by (fall speed)
end
if then
  set [Y velocity v] to (jump height)
end

Now the hen jumps when the up arrow is pressed and falls back smoothly.

2.3 Coding Left and Right Movement

Create Another Custom Block

My Blocks → Make a Block → "Left Right Movement"

Add inputs:

  • move speed
  • drag

Variables

  • X velocity

Code for Horizontal Movement

define Left Right Movement (move speed) (drag)
if then
  set [X velocity v] to (move speed)
  point in direction (90)
else
  if 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.

2.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.

2.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 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

2.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 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

2.7 Adding Win and Game Over Conditions

Variables

  • score
  • lives (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]

2.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.

3. 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 –Kodex Academy

4. Enhancement Ideas

Take your game to the next level! Try adding:

4.1 Power-ups

Add a new sprite like a "star" that gives temporary invincibility.

when green flag clicked
forever
  if then
    set [invincible v] to [true]
    wait (5) seconds
    set [invincible v] to [false]
  end
end

4.2 Enemy Sprites

Create a walking enemy and code collision detection to decrease lives.

4.3 Background Music & Level Transitions

Use different backdrop music for each level using the "play sound until done" block.

4.4 Double Jump Feature

Add an advanced jump mechanic:

define Double Jump
if then
  if <(jump count) < [2]> then
    change [Y velocity v] by (15)
    change [jump count v] by (1)
  end
end
if then
  set [jump count v] to (0)
end

5. 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.

5.1 Call to Action

  1. 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
  2. Like, comment & share the video
  3. Visit kodexacademy.com
  4. Subscribe to the Kodex Academy YouTube channel for deeper Scratch content.

Happy coding with Kodex Academy! 🚀

5.2 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!

5.3 Further Reading & Links