Introduction: Touch the Blue Ball Game in Scratch – Learn Lists, Variables, and Animation!
Have you ever wanted to make interactive games in Scratch but weren’t sure where to begin? Or maybe you’re a teacher or parent looking for the perfect Scratch game tutorial for beginners to help kids get excited about programming?
Welcome to this hands-on project where you’ll build an exciting and fast-paced Scratch color changing ball game called “Touch the Blue Ball.” This project is more than just fun—it’s a creative way to introduce important coding concepts like:
- Using variables and lists in Scratch
- Broadcast messages for controlling game flow
- Color-changing sprite logic
- Randomized movement and bouncing mechanics
- Win/Loss conditions based on player actions
If you’re new to Scratch, don’t worry! This guide is designed with step-by-step Scratch game development instructions that anyone—from kids to coding-curious adults—can follow. And if you’ve coded in Scratch before, this project will deepen your understanding of how to:
- Use lists for managing multiple costumes
- Control sprite actions based on user inputs
- Create dynamic games that are fun, interactive, and visually appealing
In this game, the player is challenged to click on the blue ball while it continuously changes color and moves to random positions on the screen. If they click the correct color in time, they win; if they miss or click the wrong color, they lose.
It’s a simple concept—but one that teaches core programming logic, sharpens hand-eye coordination, and builds critical thinking skills. Perfect for classroom activities, coding clubs, or self-paced learning.
What You’ll Learn in This Tutorial:
- How to create a color changing sprite in Scratch
- How to build a ball bouncing game in Scratch
- How to use lists and variables effectively
- How to design a countdown with costume changes
- How to code win/fail conditions using if-else logic
- How to make a game fun, responsive, and educational
Whether you’re looking to learn Scratch game coding basics or you want to teach Scratch programming to kids in a fun and practical way, this project is a great start.
By the end of this tutorial, you’ll have a fully playable game and a deeper understanding of how to create simple games with Scratch—and you’ll also have the skills to expand it with levels, sound effects, scores, or even multiplayer features!
Ready to get started? Watch the full tutorial first and follow along with the guide:
Watch on YouTube – Touch the Blue Ball Game in Scratch | Make a List & Random Color Coding by Kodex Academy
Step‑by‑Step Coding for Touch the Blue Ball Game in Scratch
Step 1. Game Demo and Rules Explained
Begin with a demo to showcase gameplay:
- Click the green flag, see a countdown, then the ball moves randomly.
- Try clicking the blue ball to win, any other color results in fail.
Why this matters: Establishes Scratch game coding basics, setting expectations and motivating learners.
Watch this on video – Demo and Rules Explained
Step 2. Create the Ball Sprite (Costumes & Setup)
- Delete the default Scratch cat sprite.
- Add a “Ball” sprite (or draw one).
- Add 5 costumes—each a different color (e.g. red, blue, green).
- Set its size to about 150% for visibility.
This ensures the player can clearly see and click the ball, and gives us multiple colors to work with—crucial for color-related logic later.
Watch this on video – Preparing the Game Sprite: Choosing and Setting Up the Ball
Step 3: Choose a Backdrop
Pick a background like “Race 1” to give your game visual context. A dynamic backdrop enhances the user’s immersion.
Step 4: Instruction Sprite with Countdown
Watch this on video – Creating Instruction Sprite with Multiple Costumes for Game Start Countdown
Add an instruction sprite to display text prompts before the game begins:
- Paint a new sprite and create six costumes: “Simple”, “Click on the blue ball”, “3”, “2”, “1”, “Go”.
when green flag clicked
show
go to x: 0 y: 0
switch costume to [Simple v] // Costume 1
wait 1 sec
switch costume to [Click on the blue ball v]
wait 1 sec
switch costume to [3 v]
wait 1 sec
switch costume to [2 v]
wait 1 sec
switch costume to [1 v]
wait 1 sec
switch costume to [Go v]
wait 1 sec
broadcast [start v]
hide
This handles the countdown and signals the game to begin by broadcasting the "start"
message.
Step 5: Ball Behavior: Hiding, Random Position, Costume Changes
Watch this on video – How to Hide and Center the Ball in Scratch
What happens when the game starts:
when green flag clicked
hide
go to x: 0 y: 0
when I receive [start v]
go to x: pick random -240 to 240
y: pick random -180 to 180
show
The ball hides initially, then appears at a random position when the game starts—making each run unique and fun.
Step 6: Random Color Changing using Variables & Lists
Create:
- Variable:
costume number
- List:
costume list
, containing [1, 2, 3, 4, 5]
Why use a list?
It allows dynamic selection of costumes via index, a powerful technique to manage multiple options. This reflects how lists in Scratch can simplify handling multiple items.
when I receive [start v]
forever
set [costume number v] to (pick random 1 to 5)
switch costume to (item (costume number) of [costume list v])
wait 0.5 secs
end
Every half-second, the ball switches to a new random costume and thus a new color.
Step 7: Ball Glide & Bounce Mechanics
Watch this on video – Make the Ball Glide and Bounce Back from Edges in Scratch
Make the ball move smoothly and bounce off screen edges:
when I receive [start v]
forever
glide 0.5 secs to x: pick random -240 to 240 y: pick random -180 to 180
if on edge, bounce
end
Use glide
for smooth movement and if on edge, bounce
for natural animation. This creates a dynamic and engaging gameplay experience.
Step 8: Detecting Win or Fail – If‑Else Logic
Watch this on video – Create Win or Fail Conditions Based on Ball Color in Scratch
Add game-play logic for winning (click blue ball) or failing (click other color):
when this sprite clicked
if <(costume number) = 2> then // Assuming 2 = blue
wait 1 sec
broadcast [You Win v]
else
wait 1 sec
broadcast [You Fail v]
end
stop [all v]
If the current costume is blue (number 2), the player wins; otherwise, they lose. The stop all
block ends the game immediately.
Step 9: Win and Fail Messages
Create two sprites: one labeled “You Win” (e.g., a dancer) and one labeled “You Fail” (e.g., sad face of Monet).
For both sprites:
when green flag clicked
hide
when I receive [You Win v] // or [You Fail v]
go to x: 0 y: 0
show
These will appear at the center when the appropriate broadcast is received.
Enhancement Ideas (with Code Examples)
A. Add a Score Counter (Scratch variables & UX)
Create variable Score
:
when green flag clicked
set [Score v] to 0
when this sprite clicked
if <(costume number) = 2>
change [Score v] by 1
Display score as monitor for feedback.
B. Difficulty Levels / Speed Variation
Let players choose difficulty:
when green flag clicked
ask [Choose difficulty: Easy/Medium/Hard] and wait
if <(answer) = [Easy]> then set [speed v] to 1
...
Adjust glide delay or wait time based on difficulty.
C. Add Sound Effects
Import victorious or failure sounds:
when I receive [You Win v]
play sound [yay v]
show
D. Track Click Accuracy / Miss Count
Add variable Misses
:
when this sprite clicked
if not <(costume number) = 2> then
change [Misses v] by 1
Show feedback on errors.
Summary Table
Step | Goal | Code Snippet |
---|---|---|
1 | Ball sprite setup | Costumes & size configuration |
2 | Instruction countdown | when green flag → show → switch costume → broadcast [start] |
3 | Ball initial positioning | Hide & go to center |
4 | Random movement + show | when I receive [start] → go to pick random position → show |
5 | Color changing via list | Forever loop: pick random → switch costume from list |
6 | Glide + bounce logic | Glide with edge bounce |
7 | Click detection logic | If-else: costume number = 2 → win; else → fail + stop |
8 | Display outcome | Show “You Win” or “You Fail” sprites on broadcast |
Conclusion: Touch the Blue Ball Game in Scratch
Congratulations! By following this detailed, step-by-step tutorial, you’ve successfully built an interactive, color-changing “Touch the Blue Ball” game in Scratch.
This project wasn’t just about clicking a blue ball—it introduced you to the core fundamentals of game design in Scratch, including:
What You Accomplished
- ✅ Built an animated, bouncing ball game that changes color using variables and lists.
- ✅ Created an interactive countdown and instruction screen using costumes and broadcast messages.
- ✅ Implemented random movement and glide effects to make gameplay exciting and unpredictable.
- ✅ Used conditional logic (if-else) to check if the player wins or loses.
- ✅ Designed custom win/fail screens that react to game events.
- ✅ Learned how to use lists, variables, events, and loops—foundational blocks in Scratch programming.
Call to Action
- Don’t forget to check out the full video tutorial by Kodex Academy here: Touch the Blue Ball Game in Scratch | Make a List & Random Color Coding 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