Introduction: How to Create a Dodge Ball Game in Scratch
Watch the full tutorial here – How to Create a Dodge Ball Game in Scratch | Fun & Easy Coding Game by Kodex Academy
Welcome to the ultimate Scratch game tutorial! If you’ve been searching for how to make a game in Scratch or looking for Scratch programming for beginners, you’re in the right place.
In this blog post, we’ll walk you through building an exciting Dodge Ball game in Scratch, inspired by the Kodex Academy’s YouTube tutorial. 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 survive as long as possible. Along the way, you’ll learn fundamental Scratch programming concepts like sprite movement, variables, collision detection, and game state management — all explained in an easy-to-follow way. So grab your computer, open Scratch, and let’s build your very own interactive Dodge Ball challenge!
What You’ll Learn
- How to set up sprites and backdrops in Scratch
- Creating variables for scoring, lives, and ball speed
- Programming player movement using arrow keys
- Coding falling balls with increasing speed
- Implementing collision detection and life tracking
- Managing game states: Win and Game Over
- Adding sounds and background music
- Enhancing the game with additional features
How to Create a Dodge Ball Game in Scratch: Step by step Coding
Game Design & Objective
- The game centers around a player-controlled sprite (Pico) that must dodge falling balls.
- The objective is to survive until the score reaches 30 points.
- The game ends either with a “You Win” screen (on success) or a “Game Over” screen (on losing all lives).
Step 1: Game Overview & Demo
The game is simple but fun — control a character (Pico) to dodge falling balls. Your score increases the longer you survive, but if a ball touches Pico, you lose a life. Survive long enough to win!
Step 2: Setting Up Your Scratch Project
- Create a new Scratch project at scratch.mit.edu.
- Delete the default Scratch Cat sprite.
- Choose the Pico Walking sprite (or any character you like).
- Resize the sprite to about 60% for better gameplay.
- Choose a backdrop — Kodex Academy used Jurassic for the main game.
- Duplicate the backdrop twice, renaming them to Game Over and You Win.
Step 3: Designing Game Screens
- On the Game Over backdrop, add red text saying “Game Over.”
- On the You Win backdrop, add pink text saying “You Win.”
Feel free to customize fonts and colors for your style!
Step 4: Create Variables
Go to the Variables category and create:
score
(for all sprites)ball speed
(for all sprites)lives
(for all sprites)
Step 5: Coding the Player (Pico)
Here’s the basic code blocks you need:
when green flag clicked
go to x: -2 y: -18
set [score v] to 0
set [lives v] to 3
set [ball speed v] to -5
set rotation style [left-right v]
forever
if <key [right arrow] pressed?> then
point in direction (90)
change x by (10)
next costume
end
if <key [left arrow] pressed?> then
point in direction (-90)
change x by (-10)
next costume
end
end
This moves Pico left and right with arrow keys and changes costumes to simulate walking.
Step 6: Adding the Falling Balls
- Add a new sprite — use a baseball or ball.
- Code the ball to fall from the top with increasing speed.
when green flag clicked
show
go to y: 180
go to x: (pick random -230 to 230)
forever
change y by (ball speed)
if <(y position) < -170> then
set y to 180
set x to (pick random -230 to 230)
play sound [pop v]
change [score v] by 1
change [ball speed v] by 0.2
end
if <touching [Pico Walking v]?> then
play sound [jump v]
change [lives v] by -1
set y to 180
end
end
You can duplicate the ball sprite to increase difficulty.
Step 7: Game Over & Winning Conditions
Add code to the Stage to switch backdrops based on game state:
when green flag clicked
switch backdrop to [Jurassic v]
forever
if <(score) = 30> then
switch backdrop to [You Win v]
broadcast [You Win v]
end
if <(lives) = 0> then
switch backdrop to [Game Over v]
broadcast [Game Over v]
end
end
Step 8: End Game Behavior for Sprites
For Pico and balls, add reactions on game end:
when I receive [Game Over v]
hide
stop [this script v]
when I receive [You Win v]
hide
stop [this script v]
For Pico, show messages before stopping:
when I receive [Game Over v]
say (join [Nice try! Your score is ] (score)) for 2 seconds
stop [all v]
when I receive [You Win v]
say (join [Well done! Your score is ] (score)) for 2 seconds
stop [all v]
Step 9: Adding Background Music
To make the game more immersive:
when green flag clicked
forever
play sound [Eggs - Softer v] until done
end
You can choose any background music or upload your own sound.
Step 10: Final Testing
Test your game by clicking the green flag and try to dodge balls. Increase the number of balls or change speed variables for more challenge!
Enhancement Features and Code
To level up your Scratch game, we included:
- Multiple Balls: Duplicated the ball sprite to increase challenge.
- Score-Based Difficulty Scaling: Ball speed increases over time.
- Power-ups (Optional): Introduced a method for adding extra life sprites.
- High Score Tracking: Used a session-based method to keep track of top score.
- Background Music: Continuous looping soundtrack for engagement.
1. Multiple Levels with Increasing Difficulty
Add levels and increase the speed and number of balls as player scores more.
when green flag clicked
set [level v] to 1
forever
if <(score) > (level * 10)> then
change [level v] by 1
change [ball speed v] by 1
create clone of [ball v]
end
end
Use clones for balls to dynamically add more balls.
2. Power-Ups for Extra Lives
Create a new sprite as a heart or shield that appears randomly. If Pico touches it, increase lives.
when green flag clicked
hide
wait (pick random 10 to 30) seconds
show
go to x: (pick random -230 to 230) y: 180
forever
change y by -5
if <touching [Pico Walking v]?> then
change [lives v] by 1
hide
wait (pick random 10 to 30) seconds
show
go to x: (pick random -230 to 230) y: 180
end
if <(y position) < -170> then
hide
wait (pick random 10 to 30) seconds
show
go to x: (pick random -230 to 230) y: 180
end
end
3. High Score Saving
Scratch doesn’t have built-in persistence, but you can show a high score for the session.
when green flag clicked
set [high score v] to 0
forever
if <(score) > (high score)> then
set [high score v] to (score)
end
end
Display the high score on the screen using a sprite or variable monitor.
Summary
In this in-depth tutorial, we explored how to build an exciting Dodge Ball game in Scratch, ideal for beginners, kids, or anyone just getting started with Scratch programming. The game challenges players to move a character left and right to avoid falling balls. As the player survives longer, the speed of the balls increases, making the game progressively more challenging and fun.
This project not only teaches basic game development but also reinforces essential programming concepts like variables, loops, events, conditional statements, and sensing — all using Scratch’s intuitive, block-based coding system.
Learning Outcomes
- Game development structure in Scratch.
- Visual coding concepts like motion, events, variables, and conditionals.
- Creating polished, interactive experiences with sound and visuals.
- Debugging and refining logic using real-time testing.
Call to Action
- Don’t forget to check out the full video tutorial: How to Create a Dodge Ball Game in Scratch | Fun & Easy Coding 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