How to Make a Game in Scratch | Snake Game in Scratch | Step-by-Step Game Coding

How to Make a Game in Scratch Snake Game in Scratch Step-by-Step Game Coding Kodex Academy

Introduction: Make Snake Game in Scratch

Watch the full tutorial here – How to Make a Game in Scratch | Snake Game in Scratch | Step-by-Step Game Coding | Kodex Academy

Creating games in Scratch is a fun way for beginners and kids to learn programming, logic, creativity, and design. A Snake Game is a classic project that introduces many essential concepts:

  • Scratch motion and control blocks
  • Using variables (score, speed, clones)
  • Event handling (when flag clicked, broadcast messages)
  • Sensing (collision / touching)
  • Using clones for creating trails or segments
  • Adding winners/losers (game over, you win)
  • Backdrops, sprites, costumes, sound

In this tutorial, we’ll build a Snake Grid style game in Scratch step by step (very similar to the Kodex Academy example). By doing this, you’ll cover many of the core Scratch building blocks. We will also suggest enhancements to make your game more interesting as you get more comfortable.

Why “Snake Game” is Great for Scratch Beginners

Some of the reasons this project is ideal:

  • It teaches Scratch variables tutorial (score, speed, clone count) in action.
  • You use motion and control blocks to move the snake around.
  • You’ll work with scratch tutorial game paradigms: sprites, backdrops, events.
  • It’s simple enough for kids, but has room for enhancements.
  • It combines programming & animation (trail of clones, sprite movement).

Game Overview

Here’s what the final game does:

  • You control a snake sprite.
  • There is a strawberry (food) sprite.
  • When the snake catches the strawberry, your score increases, and the speed of the snake increases.
  • If the snake touches the screen edge, game over.
  • If the score reaches a certain number (e.g. 5), you win.
  • There are “You Win” and “Game Over” sprites or backdrops that appear when those conditions are met.
  • There is background music/sound effect (“Dance Magic” in the example).

How to Make a Snake Game in Scratch: Step-by-Step Game Coding

Step 1: Start a New Project & Setup Backdrop & Sprites

  1. New Project: In Scratch, click Create to start a fresh project.
  2. Delete Default Sprite: Remove the cat unless you want to customize it.
  3. Backdrop: Choose a backdrop or paint your own. It could be a simple grid or plain color. Keep it clean so collisions and edges are visible.
  4. Snake Sprite (Head):
    • Either pick a sprite or paint one. A simple shape works (square or circle).
    • Name it “Snake” or “Head”.
    • Set its size appropriately (not too large so it can move freely).
  5. Food Sprite:
    • Create or pick a sprite for food (e.g. strawberry, apple).
    • Name it “Food” or “Strawberry”.
  6. Win / Game Over Sprites:
    • Create two new sprites (or backdrops), one saying “You Win!”, one saying “Game Over”.
    • Design their costumes/text styles, colors.
    • Initially hide them at start.

Step 2: Create Variables

Make these variables (for all sprites):

  • Score — to track how many food items eaten.
  • Speed — to control how fast the snake moves.
  • (Optional) CloneCount or just Clone — if using clones to produce tail or trail effects.
  • (Optional for more complex) HighScore, Lives, etc.

Step 3: Snake Movement Logic (Motion & Control Blocks)

This handles moving the snake head via arrow keys, and continuous movement.

Script in Snake Sprite:

when green flag clicked
go to x: (0) y: (0)
set [Speed v] to (4)
set [Score v] to (0)

forever
    move (Speed) steps
    if <key [up arrow] pressed?> then
        point in direction (0)
    end
    if <key [down arrow] pressed?> then
        point in direction (180)
    end
    if <key [right arrow] pressed?> then
        point in direction (90)
    end
    if <key [left arrow] pressed?> then
        point in direction (-90)
    end
end
  • when green flag clicked starts the game.
  • forever loop makes the motion continuously happen.
  • move (Speed) steps moves the snake.
  • Arrow‑key pressed sensing blocks change the direction.

Step 4: Food Behaviour

Make the food appear randomly, and when the snake touches it, perform actions.

Script in Food Sprite:

when green flag clicked
go to random position

forever
    if <touching [Snake v]?> then
        change [Score v] by (1)
        change [Speed v] by (0.2)   // optional: faster over time
        go to random position
        // Optional: wait (0.1) seconds
    end
end
  • go to random position from the Motion category places the food somewhere on the stage.
  • The touching [Snake] from Sensing detects when snake eats the food.
  • Update variables as needed (score, speed).

Step 5: Win and Game Over Conditions

Game Over (if snake hits edge):

In the Snake sprite script:

when green flag clicked
forever
    if <touching edge?> then
        broadcast [GameOver v]
        stop [all]
    end
end

Win condition (if score reaches certain number):

when green flag clicked
forever
    if <(Score) = (5)> then
        broadcast [YouWin v]
        stop [all]
    end
end
  • You decide the score to win (e.g. 5, 10, etc.).
  • broadcast lets other sprites know what happened (Game Over or You Win).

Step 6: Show / Hide Win & Game Over Sprites

In the “Game Over” sprite:

when green flag clicked
hide

when I receive [GameOver v]
show
go to front layer

In the “You Win” sprite:

when green flag clicked
hide

when I receive [YouWin v]
show
go to front layer
  • hide at start ensures they are invisible during gameplay.
  • show on broadcast displays the correct ending.

Step 7: Optional Trail / Tail or Clone Effects

To make snake leave a trail (which visually approximates a tail), or make clones follow the head:

In Snake sprite:

when green flag clicked
forever
    create clone of myself
end

when I start as clone
wait (0.1) seconds
delete this clone
  • The clones are small copies of the snake head; each clone lasts briefly then disappears.
  • The delay (wait) controls the length/thickness/distance of the trail.

For more advanced tail (body segments that persist and follow), you may use lists to keep past positions and clones that follow those positions. (See enhancements below.)

Step 8: Sound / Music

Add audio to make the game more fun:

when green flag clicked
forever
    start sound [Dance Magic v] until done
end
  • Use any loop or sound from Scratch’s sound library.
  • Also, add sound effects when food is eaten, when game ends, etc.

Step 9: Reset / Replay Functionality

Allow players to play again without refreshing:

  • Create a “Play Again” or “Restart” sprite (a button).
  • That sprite is hidden at start.

Script in Restart Button Sprite:

when green flag clicked
hide

when I receive [GameOver v]
show
go to front layer

when I receive [YouWin v]
show
go to front layer

when this sprite clicked
broadcast [ResetGame v]
hide
  • When clicked, you broadcast ResetGame which is handled in Snake, Food, etc., to reset variables, positions, hide game over/win sprites.

Reset handling (in Snake / Food sprites):

when I receive [ResetGame v]
// Reset positions
go to x: (0) y: (0)
// Reset variables
set [Score v] to (0)
set [Speed v] to (4)
hide [GameOver sprite]
hide [YouWin sprite]
// Reset food
// etc.

Enhancements & Extra Features

Once you’ve got the basic game working, here are some advanced enhancements you can try:

  1. Snake Tail Body / Growable Tail
    Use lists to store the x, y positions of the head as it moves. Then make body segment clones follow those positions (lag‑behind). When food is eaten, increase tail length.
  2. Self‑Collision Detection
    Check if the head is touching any of its body clones or touching a color used by its body. If yes → Game Over.
  3. Wrap‑around Edges
    Instead of “Game Over” when touching edges, let the snake wrap around (appear on opposite side). Use if x > boundary then set x to −boundary, etc.
  4. Multiple Food Types / Special Items
    For example:
    • Food that gives extra points.
    • Food that slows you down or speeds you up.
    • Poisonous food that subtracts points or gives penalty.
  5. Difficulty Levels
    Let the player choose Easy / Medium / Hard which affects starting Speed, or how fast speed increases, or number of food items required to win.
  6. High Score Saving
    Use a variable HighScore to remember best score achieved. Use it to compare at game over, then display.
  7. Visual & Costume Effects
    • Change snake head’s costume direction depending on movement.
    • Color trails or shaders via color effect.
    • Flashing or scaling effects on Game Over / Win.
  8. Sound Effects for Events
    • Eat sound when food is collected.
    • Game Over sound.
    • Win sound.
  9. Timer / Survival Mode
    Instead of scoring to win, see how long you can survive.

Common Pitfalls & Debugging Tips

  • Snake moving backwards: ensure you’re not letting the snake instantly reverse direction (so if going up, pressing down shouldn’t immediately work). You might need to guard in code (if current direction ≠ opposite).
  • Clones causing lag: too many clones or small wait time can slow Scratch. Increase wait or limit clone creation.
  • Food appears on snake/tail: randomness might place food where the snake is; you can test after positioning if it’s touching snake and reposition until it’s not.
  • Game doesn’t reset properly: ensure all variables are reset, sprites hidden/shown appropriately.
  • Collision detection of tail: if using clones or body segments, ensure head detects touching body segments before you move the head, else it immediately crashes.

Conclusion: How to Make a Game in Scratch

Creating a Snake Game in Scratch is a fantastic project for beginners, kids, and budding game developers. It introduces essential programming concepts like:

  • Variables (Score, Speed, etc.)
  • Motion and Control blocks
  • Events and Broadcasting
  • Sensing and Collision detection
  • Cloning and basic AI behavior

By following this step-by-step guide — and optionally enhancing it with features like growing tails, speed boosts, music, or wrap-around edges — you not only build a fun game, but also gain solid problem-solving skills and confidence in using Scratch for game development.

Call to Action

  1. Don’t forget to check out the full video tutorial: How to Make a Game in Scratch | Snake Game in Scratch | Step-by-Step Game Coding | 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! 🚀

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!

Further Reading & Links

Recent Posts

How to Make a Math Racing Game in Scratch | Game Concepts and Complete Tutorial

In this tutorial, you’ll learn to build a Math Racing Game in Scratch. Players solve math problems to move their character forward; wrong answers benefit the opponent. It’s a race of speed, accuracy...

How to make Memory Skill Game in Scratch | Card Matching Game in Scratch – Part 2 | Step-by-Step Coding

In this tutorial you'll learn how to make memory skill game in Scratch / card matching game in Scratch. This is a great beginner‑to‑intermediate project for scratch tutorial game, scratch programming...

How to make a Card Matching Game in Scratch | Memory Skill Game in Scratch – Part 1 | Step-by-Step Coding

In this Scratch tutorial, we'll walk you through how to make a card matching game in Scratch, also known as a memory game or skill game. This is a popular beginner project that introduces essential...

Create a Quiz Game in Scratch | Spelling Test in Scratch | Picture Identification in Scratch

Want to make learning spelling fun, visual, and interactive? In this Scratch tutorial, you'll learn how to make a spelling quiz game in Scratch using picture identification, text-to-speech, and...

How to make a Double Jump Game in Scratch | Platformer game in Scratch | Step by Step Coding

How to make a Double Jump Game in Scratch. Scratch is a fantastic platform for beginners to learn programming by making games, animations, and interactive stories. Among the many kinds of games...

How to Use Variables in Scratch | Variable Blocks in Scratch | Complete Tutorial

Introduction: Variable Blocks in Scratch Whether you’re just getting started with Scratch programming or looking to take your projects to the next level, understanding variables and lists is...

How to Make Earth Revolve Around the Sun in Scratch: A Complete Tutorial & Enhancements

Animating Earth revolving around the Sun is a classic beginner/intermediate Scratch animation project. It combines trigonometry (sine & cosine), variables, loops, and visual scripting. Kids can learn...

How to Make a Game in Scratch | Snake Game in Scratch | Step-by-Step Game Coding

In this tutorial, we’ll build a Snake Grid style game in Scratch step by step (very similar to the Kodex Academy example). By doing this, you’ll cover many of the core Scratch building blocks. We will...

How to Use Operator Blocks in Scratch | Full Guide with Live Coding & Examples

One of the most powerful features in Scratch is its Operator Blocks — essential for handling math operations, logic comparisons, and string manipulations...

How to Create a Thirsty Crow Story in Scratch | Animation Story in Scratch for Kids

In this tutorial, you’ll learn how to create the classic “Thirsty Crow” story in Scratch, using simple animation, voice, and sprite actions. This is a perfect project for kids who are new to coding...

How to Create a Dodge Ball Game in Scratch: A Complete Step-by-Step Tutorial for Beginners

This step-by-step tutorial will guide you through how to create a Dodge Ball game in Scratch from scratch! In this game, you’ll control a character trying to dodge falling balls, earn points, and...

How to use Sensing Blocks in Scratch | Scratch programming for beginners | Live Coding with Examples

In today’s session, we’re diving deep into one of the most powerful features of Scratch — Sensing Blocks. These blocks allow your projects to interact with the world, detect touches, respond to...

Build an Egg Shooting Game in Scratch: Step-by-Step Coding | Complete Guide for Beginners

Learn how to create a fun, interactive shooting game in Scratch with this detailed tutorial inspired by classic arcade games. Perfect for kids and beginners looking to dive into Scratch programming!...

How to Make a Maze Game in Scratch | Step by Step Coding | Full Tutorial & Enhancements

Introduction: Why Build a Maze Game in Scratch? If you’re looking for a Scratch beginner project idea that’s fun, interactive, and educational, then building a maze game in Scratch is the...

Scratch Control Block Tutorial: Full Guide with Loops, Conditions, Cloning & Code Examples

“Control blocks” in Scratch are those blocks (from the Control category) that manage the flow of your script: when things happen, how many times they happen, making decisions, repeating actions...

How to Create a Car Racing Game in Scratch – Part 2 – Step-by-Step Coding

Welcome to your ultimate guide on how to make a car racing game in Scratch—a step‑by‑step tutorial. You'll learn Scratch game development techniques, see actual code blocks, and discover enhancements...

How to Make a Hurdle Jumping Game in Scratch – Build a Fun Hurdle Runner with Score & Win Screen

Are you ready to create your very own hurdle jumping game in Scratch—just like the iconic Chrome Dino or Super Mario? 🎮 Whether you're new to Scratch or just looking for your next fun project, this...

How to Create a Car Racing Game in Scratch – Part 1 – Step-by-Step Coding

In this Scratch car racing game tutorial, we’ll walk you through how to create a fully functional, visually exciting, and incredibly fun car racing game using Scratch. In this blog, we’ll cover: How...
Scroll to Top