Project 26 of 35  ·  Scratch Programming  ·  Module 2
Module 2

Dodgeball

Create an action game where the player must dodge an increasing number of flying balls.

🍓  Open on Raspberry Pi Projects  ↗ Opens the official Raspberry Pi Foundation project — includes starter files and full step-by-step guide

What You Will Build

Create an action game where the player must dodge an increasing number of flying balls. Follow the guide below to build the project, then open the official Raspberry Pi page for starter files, worked examples and extra help.

🍓 This project is on the Raspberry Pi Foundation website. Click the orange button above to access the full guide, starter Scratch project and extension activities on projects.raspberrypi.org.

What You Will Learn

  • Move a player sprite with the mouse or arrow keys
  • Create bouncing ball clones that reflect off stage edges
  • Detect when a ball hits the player and lose a life
  • Increase difficulty by adding more balls as score grows
  • Display lives and score as HUD variables

Step-by-Step Guide

  • 1Create an arena backdrop.
  • 2Add a player sprite. In forever: go to [mouse-pointer].
  • 3Add a ball sprite. In a forever loop: move 5 steps. If touching edge: bounce.
  • 4Set ball to random start position and direction on start.
  • 5If ball touching [player]: change lives by -1, play hit sound, flash player.
  • 6Create a score variable that increases by 1 every second.
  • 7Every 10 seconds: create clone of [ball] so difficulty increases.
  • 8Create a lives variable set to 3. When lives = 0: game over.
  • 9Add a speed increase: every 20 seconds, change ball move steps from 5 to 6 to 7.
  • 10Add a shield power-up that appears every 30 seconds — collecting it grants 3 seconds of invincibility.

Extension Challenges

Finished the main project? Push further:

  • Add ball types: slow harmless, fast dangerous, bomb that ends the game instantly.
  • Add walls the player can duck behind to hide temporarily.
  • Create a 2-player mode: one controls the player, the other guides the ball using different keys.