Introduction to Scratch Basketball Game Project
Want to create your own basketball game in Scratch that actually feels like real basketball? This complete step-by-step tutorial shows you exactly how to build a fun, interactive Scratch basketball game with a moving hoop, realistic jumping ball physics, a jumping player, live scoring, sound effects, and a 30-second timer!
Perfect for kids 8-14, complete beginners, and teachers looking for an exciting coding project. By the end, you’ll master:
- ✓ Sprite cloning and gravity simulation
- ✓ Variables for score and timer
- ✓ Color-sensing for accurate scoring
- ✓ Smooth player jumping and shooting animations
- ✓ Random moving hoop with glide effects
- ✓ Game over and “You Win!” screens
No prior coding experience needed! Follow along with the written steps below or watch the full video tutorial. Ready to code the ultimate Scratch basketball game? Let’s dunk into it! 🏀
Watch the full tutorial on YouTube here:
👉 How to Make a Basketball Game in Scratch | Full Tutorial | (Moving Hoop + Jumping Ball + Score)
Why This Scratch Basketball Game Tutorial Stands Out
Unlike basic “throw ball into static hoop” projects, this tutorial teaches real game development concepts used in professional games:
- Realistic physics with gravity and velocity
- Dynamic difficulty (moving hoop gets faster)
- Clone management (unlimited basketballs!)
- Polish: sound effects, animations, particle effects
Hundreds of students have already built and remixed this exact project!
What You’ll Learn: Key Scratch Coding Skills for Beginners
- How to make a game in Scratch step-by-step
- How to use sprites, costumes, and backdrops
- How to use variables and loops for scoring and movement
- How to add sounds, effects, and levels
- How to enhance your Scratch programming projects
Best Laptop for Kids Learning Scratch in 2025
Before Starting This Scratch Basketball Tutorial – Grab the #1 Laptop/Tablet for Scratch.
Disclosure: The product links are affiliate links. We may earn from qualifying purchases at no additional cost to you.
Step-by-Step Guide: Basketball Game in Scratch
How to Open and Set Up Your Scratch Project
Go to Scratch and click “Create” to open a new project.
Delete the default cat sprite — we’ll create our own characters.
Adding and Customizing Sprites and Backdrop in Scratch
- Basketball sprite → From Scratch’s library
- Andy (player) sprite → Any character you like
- Hoop sprite → You can upload or draw your own
- Backdrop → Search for “Playing Field”
Adjust sizes:
- Hoop size:
50% - Basketball and Andy: Adjust for proper proportion
Editing Costumes for Your Basketball Game Sprites
Ensure that:
- The basketballs in Andy’s hand and the basketball sprite look the same.
- Delete unnecessary costume layers.
- Duplicate the hoop’s costume 4 times to animate it when the ball scores.
1. How to Code the Basketball Sprite: Clones, Physics & Scoring in Scratch
🧱 Creating Basketball Clones on Spacebar Press
when flag clicked
hide
forever
if <key [space v] pressed?> then
create clone of [myself v]
wait (0.3) secs
end
endExplanation:
when flag clicked: This starts when the green flag (game start) is clicked.hide: Hides the original basketball so only its clones appear.forever: Keeps checking for spacebar presses throughout the game.if <key [space] pressed>: Detects when the player presses space.create clone of myself: Makes a new basketball each time you press space.wait (0.3) secs: Prevents too many basketballs from spawning too fast.
✅ Result: Every time you press space, a new basketball clone appears.
Simulating Basketball Physics: Gravity, Falling & Rotation in Scratch
when I start as a clone
show
set [ball falling v] to (24)
repeat until <(y position) < (-130)>
change x by (10)
change y by (ball falling)
change [ball falling v] by (-2)
turn cw (6) degrees
end
hideExplanation:
when I start as a clone: Each clone runs this code when created.show: Makes the new basketball visible.ball falling = 24: Sets the initial upward velocity (it starts moving up).repeat until y < -130: Keeps running the loop until the ball hits the ground.change x by (10): Moves the ball horizontally (rightwards).change y by (ball falling): Makes the ball move up or down based on velocity.change ball falling by (-2): Gradually decreases velocity, simulating gravity.turn cw (6): Rotates the ball slightly for a spinning effect.hide: Makes the ball disappear after it falls off-screen.
✅ Result: The basketball launches upward, falls under gravity, and disappears after landing.
Adding Sound Effects to Basketball Throws
start sound [pop v]Explanation:
- Adds a bounce sound each time a basketball is thrown.
- Makes the game more realistic and interactive.
2. Coding the Jumping Player (Andy): Movement, Jumps & Shoot Animations
Implementing Jump Mechanics with Gravity Simulation
when flag clicked
show
set [y velocity v] to (0)
forever
change y by (y velocity)
if <(y position) > (-130)> then
change [y velocity v] by (-2)
else
set [y velocity v] to (0)
set y to (-130)
end
endExplanation:
y velocitycontrols vertical speed (positive = up, negative = down).change y by y velocitymoves Andy up or down.if (y > -130): Means Andy is above ground → apply gravity.change y velocity by -2: Gradually brings Andy back down.else: When Andy touches the ground → stop falling and reset position.
✅ Result: Andy can jump, fall back, and land naturally using basic physics.
Triggering Jumps with Arrow Keys
when [up arrow v] key pressed
if <(y position) = (-130)> then
set [y velocity v] to (25)
endExplanation:
- When up arrow is pressed:
- If Andy is on the ground, set
y velocity = 25. - This launches Andy upward — starting the jump motion.
- If Andy is on the ground, set
✅ Result: Pressing the up arrow makes Andy jump.
Horizontal Movement: Left/Right Controls & Costume Switches
forever
if <key [right arrow v] pressed?> then
change x by (10)
switch costume to [Andy C v]
end
if <key [left arrow v] pressed?> then
change x by (-10)
switch costume to [Andy D v]
end
endExplanation:
- Moves Andy left and right using arrow keys.
- Changes costumes (Andy C / Andy D) for walking animations.
✅ Result: Andy moves smoothly and faces the correct direction when walking.
Animating the Shooting Action on Spacebar
when [space v] key pressed
switch costume to [Andy A v]
wait (0.3) secs
switch costume to [Andy B v]Explanation:
- When space is pressed (to throw basketball),
- Andy switches to throwing animation (costume A → B).
✅ Result: Andy visually appears to throw the ball when you shoot.
3. Creating a Moving Hoop in Scratch: Random Glides & Score Animations
Random Hoop Movement with Glide Blocks
when flag clicked
show
switch costume to [1 v]
forever
glide (1) secs to x: (pick random (-240) to (240)) y: (pick random (-50) to (105))
endExplanation:
- Makes the hoop continuously move to random x/y positions.
- Glide gives smooth movement.
- Random X (-240 to 240): Side-to-side movement across the screen.
- Random Y (-50 to 105): Small up/down movement to increase challenge.
✅ Result: The hoop moves randomly, making the game harder.
Triggering Hoop Score Animation on Ball Touch
forever
if <touching [basketball v]> then
switch costume to [2 v]
wait (0.2) secs
switch costume to [3 v]
wait (0.2) secs
switch costume to [4 v]
wait (0.1) secs
switch costume to [1 v]
end
endExplanation:
- Detects when a basketball touches the hoop.
- Quickly cycles through hoop costumes (1 → 4) to show a “swish” animation.
- Resets to costume 1 after animation.
✅ Result: A visual effect when the basketball enters the hoop.
4. Implementing Game Logic: Score Variables
Initializing Score and Timer Variables
when flag clicked
set [score v] to (0)
set [timer v] to (30)
forever
wait (0.1) secs
change [timer v] by (-0.1)
endExplanation:
- Initializes two variables:
score= number of successful shotstimer= game countdown
- Every 0.1 seconds, timer decreases by 0.1 (→ smooth countdown).
✅ Result: 30-second countdown timer.
Detecting Scores with Color Sensing
if <touching color [#dark-orange v] or touching color [#light-orange v]> then
change [score v] by (1)
delete this clone
endExplanation:
- The basketball checks if it touches the orange hoop color.
- If yes:
- Add 1 to score.
- Delete that basketball clone.
✅ Result: Score increases by 1 for every successful basket.
5. Implementing Timer & Win/Lose Conditions
Backdrop Switches for Win/Lose Screens
forever
if <(timer) < (0.1)> then
switch backdrop to [Game Over v]
hide
stop all
end
if <(score) > (9)> then
switch backdrop to [You Win v]
hide
stop all
end
endExplanation:
- If the timer runs out, switch backdrop → “Game Over”.
- If score > 9, switch backdrop → “You Win”.
hidehides Andy,stop allends all scripts.
✅ Result: Game ends automatically when time runs out or player wins.
Hoop Reactions at Game End
when backdrop switches to [Game Over v]
hide
when backdrop switches to [You Win v]
hideExplanation:
- When the game switches backdrop, hide the hoop.
- Keeps the final scene clean and readable.
✅ Result: Hoop disappears after the game ends.
6. Adding Background Music and Sound Effects to Your Scratch Game
Looping Sounds with Forever Blocks
when flag clicked
forever
play sound until done
endExplanation:
- Plays looping background music for the entire gameplay.
- The sound resets automatically after finishing, creating a continuous effect.
✅ Result: Adds atmosphere and excitement to the game.
7. How All Elements Work Together: Scratch Basketball Game Summary
| Sprite | Role | Interactions |
|---|---|---|
| Basketball | Shoots, falls, detects score | Checks color of hoop, adds score |
| Andy | Player movement & jumping | Controls shooting animation |
| Hoop | Moves randomly & animates | Reacts when ball touches it |
| Stage | Manages backgrounds | Displays “You Win” or “Game Over” |
| Variables | Timer, Score | Tracks progress |
Loved Building This Scratch Basketball Game? Take Coding Offline Next!
Now keep the excitement going with the hands-on coding toys parents buy right after finishing Scratch projects like this one.
Optional Enhancements: Level Up Your Scratch Basketball Game
Adding Difficulty Levels to Increase Hoop Speed
if <(score) > (5)> then
set [hoop speed v] to (0.5)
end- Makes the hoop move faster after scoring 5 points.
Creating Particle Effects for Scoring Moments
when I receive [scoreEffect v]
repeat (10)
create clone of [spark v]
end- Creates spark or star effects when a basket is made.
Implementing Time Bonus Power-Ups
if <touching [clock sprite v]> then
change [timer v] by (5)
hide
end- Adds +5 seconds when player collects a clock sprite.
Summary of Steps: Scratch Basketball Game Tutorial
Key Features of Your Scratch Basketball Game
| Feature | Logic Used | Key Scratch Concepts |
|---|---|---|
| Jumping | y velocity + gravity | Variables, loops |
| Shooting | Clones + sounds | Events, cloning |
| Moving hoop | Random glide | Motion blocks |
| Scoring | Color detection | Sensing, variables |
| Timer | Countdown | Wait + change variable |
| Win/Lose | Conditional logic | Operators, control |
| Animation | Costumes | Looks, timing |
How to Make a Basketball Game in Scratch with Moving Hoop, Jumping Ball & Scoring. Complete beginner tutorial to create a fully playable basketball game in Scratch with realistic physics, moving hoop, jumping player, score counter and 30-second timer.
Total Time: 31 minutes
Set Up Your Scratch Project & Add Sprites
Start a new project, delete the cat, add Basketball, Andy (player), Hoop sprites and a sports backdrop. Resize and edit costumes.
How to Code the Basketball Sprite: Clones, Physics & Scoring in Scratch
Create clones when spacebar pressed, add gravity loop with velocity variable, rotate ball, play sound, and delete clone when off screen.
Coding the Jumping Player (Andy): Movement, Jumps & Shoot Animations
Add gravity-based jumping with up arrow, left/right movement, costume switching, and shooting animation on spacebar.
Create a Moving Hoop with Random Motion & Score Animations
Make the hoop glide to random positions and trigger score animation when basketball touches orange color.
Implementing Score, Timer & Win/Lose Conditions
Create score and timer variables, detect orange color for scoring, switch backdrops when score > 9 (win) or timer ends (lose).
Adding Background Music and Sound Effects to Your Scratch Game
Loop background music, add pop sound on throw, then optionally add difficulty levels, particle effects and power-ups.
Scratch Basketball Game Full Tutorial
Frequently Asked Questions (FAQs) About Building a Basketball Game in Scratch
| Question | Answer |
|---|---|
| What age group is this Scratch basketball game tutorial best for? | Ideal for kids aged 8-12 and coding beginners. No prior experience needed—it teaches basics like loops, variables, and sprites through fun gameplay. |
| Do I need to download Scratch, or can I follow this tutorial online? | No download required! Use the free online editor at scratch.mit.edu. All code blocks are easy to copy-paste. |
| How long does it take to build the full basketball game in Scratch? | About 45-60 minutes for the core game, including sprites and logic. Add 20-30 minutes for optional enhancements like power-ups. |
| Why use color sensing for scoring instead of touch detection? | Color sensing (e.g., orange hoop) is simpler for beginners and more visual in Scratch, avoiding complex collision code while keeping it engaging. |
| Can I add multiplayer features to this Scratch basketball game? | Yes! Use broadcasts for turn-based play or clone multiple players. Start simple, then expand with variables for team scores. |
| What if my basketball clones don’t disappear after scoring? | Check the “if touching color orange” block in the Basketball sprite—ensure it includes “delete this clone” after incrementing the score variable. |
| How do I share my completed Scratch basketball game project? | Upload it to scratch.mit.edu, add a description with #ScratchBasketball, and remix others’ projects for inspiration. Tag @KodexAcademy for feedback! |
Conclusion: Master Fun Game Development in Scratch
The Scratch basketball game tutorial demonstrates how a simple, interactive game can be created using sprites, motion, variables, cloning, and events. By following the steps, learners built a game where a basketball can be thrown, the hoop moves dynamically, and the score updates in real time. Key programming concepts like collision detection, gravity simulation, keyboard controls, and costume animations were applied to make the game engaging and realistic.
The project highlights several important learning outcomes:
- Sprite management: Customizing basketball, Andy, and hoop sprites to create smooth animations.
- Cloning and motion: Generating multiple basketballs and simulating gravity with variables.
- User interaction: Using arrow keys and space bar to jump, move, and shoot.
- Game logic: Implementing scoring, timers, and win/lose conditions.
- Audio and visual effects: Adding pop sounds, background music, and costume changes to enhance gameplay.
This tutorial also encourages creativity and extension, allowing learners to add new levels, effects, or more complex scoring systems. Overall, it provides a hands-on, beginner-friendly introduction to game design and Scratch programming, while teaching essential concepts like loops, conditionals, variables, and event handling.
By the end, learners not only have a playable basketball game but also a solid understanding of how to structure interactive projects in Scratch, laying a strong foundation for more advanced game development.
🎥 Watch the full tutorial here: How to Make a Basketball Game in Scratch
Call to Action
- Don’t forget to check out the full video tutorial: How to Make a Basketball Game in Scratch | Full Tutorial | (Moving Hoop + Jumping Ball + Score)
- Like, comment & share the video
- Visit kodexacademy.com
- subscribe to the Kodex Academy YouTube channel for deeper Scratch content.
Happy coding with Kodex Academy! 🚀
Explore More Scratch Tutorials at 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!
- 🌐 Kodex Academy Blogs
- 📢 Telegram
- 💬 WhatsApp Channel
- 🔗 Patreon
- 🌐 Games Website
- 𝕏 Twitter








