How to Create a Basketball Game in Scratch: Full Step-by-Step Tutorial (Moving Hoop, Jumping Ball & Scoring)

Published By Kodex Academy — Learn. Build. Innovate.
How to Make a Basketball Game in Scratch Full Tutorial (Moving Hoop + Jumping Ball + Score)

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
end

Explanation:

  • 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
hide

Explanation:

  • 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
end

Explanation:

  • y velocity controls vertical speed (positive = up, negative = down).
  • change y by y velocity moves 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)
end

Explanation:

  • When up arrow is pressed:
    • If Andy is on the ground, set y velocity = 25.
    • This launches Andy upward — starting the jump motion.

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
end

Explanation:

  • 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))
end

Explanation:

  • 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
end

Explanation:

  • 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)
end

Explanation:

  • Initializes two variables:
    • score = number of successful shots
    • timer = 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
end

Explanation:

  • 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
end

Explanation:

  • If the timer runs out, switch backdrop → “Game Over”.
  • If score > 9, switch backdrop → “You Win”.
  • hide hides Andy, stop all ends 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]
hide

Explanation:

  • 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
end

Explanation:

  • 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

SpriteRoleInteractions
BasketballShoots, falls, detects scoreChecks color of hoop, adds score
AndyPlayer movement & jumpingControls shooting animation
HoopMoves randomly & animatesReacts when ball touches it
StageManages backgroundsDisplays “You Win” or “Game Over”
VariablesTimer, ScoreTracks 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

FeatureLogic UsedKey Scratch Concepts
Jumpingy velocity + gravityVariables, loops
ShootingClones + soundsEvents, cloning
Moving hoopRandom glideMotion blocks
ScoringColor detectionSensing, variables
TimerCountdownWait + change variable
Win/LoseConditional logicOperators, control
AnimationCostumesLooks, 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.

Frequently Asked Questions (FAQs) About Building a Basketball Game in Scratch

QuestionAnswer
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

  1. 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)
  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! 🚀

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!

Further Reading & Links

Recent Posts

How to Create a Health Bar Animation in Scratch: Healthy vs. Junk Food Game Tutorial

How to Make a Health Bar in Scratch | Healthy vs Junk Food Game | Scratch Animation | Kodex AcademyCreating fun and engaging games in Scratch not only helps kids learn coding, but also encourages...

How to Create a Basketball Game in Scratch: Full Step-by-Step Tutorial (Moving Hoop, Jumping Ball & Scoring)

Are you ready to create an exciting basketball game in Scratch with a moving hoop, jumping player, and real-time scoring? This step-by-step Scratch game tutorial is perfect for beginners who want to...

How to Make 3D Shapes in Scratch – Draw Cubes, Pyramids & Cylinders Using Pen Extension

If you’ve ever wondered how to make 3D shapes in Scratch or create 3D geometry using code, you’re about to dive into a creative world of math, animation, and programming fun. Learn how to make...

How to Make Flappy Bird Game in Scratch | Coin Collection Game in Scratch | Scratch Coding for Beginners

Have you ever wondered how people create fun games like Flappy Bird without writing a single line of code? With Scratch programming, anyone — from complete beginners to young creators — can build...

How to Make Day & Night Animation in Scratch (Step-By-Step Full Tutorial)

If you’ve ever wondered how to make day and night animation in Scratch or wanted to bring your stories and games to life with realistic sky transitions, this tutorial is perfect for you! Scratch is...

How to Make a Shooting Game in Scratch | Jet Shooting Game Tutorial (Step-By-Step Guide)

Introduction - Jet Shooting Game in Scratch Scratch Tutorial Game | Scratch Game Tutorial Easy | Scratch Programming Games | Jet Shooting Game in ScratchWant to build your first arcade-style...

Top 5 Animations in Scratch: Jump, Bounce & Fly (Beginner Tutorial + Code)

In this step-by-step guide, we explore the Top 5 animations in Scratch games that will make your projects smoother, interactive, and fun to play. You’ll learn: ✅ How to make a sprite jump ✅ How to...

How to Make a Tic-Tac-Toe Game in Scratch – Easy Scratch Tutorial for Beginners

We are going to build the all-time favourite logic game in Scratch: Tic‐Tac‐Toe. In this game two players take turns making X and O on a 3×3 grid. The first one to get three in a row — across, down or...

How to Make a Real-Time Wall Clock in Scratch | Step-by-Step Scratch Tutorial

If you’ve ever wondered how to make a real-time wall clock in Scratch, you’re in the right place! In this step-by-step Scratch tutorial, we’ll show you how to build a fully functional analog clock...

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

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

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...
Scroll to Top