Game Goal
Create a MIT Scratch game where a ball follows a path across the screen. Two turrets can rotate and shoot at the ball. The player controls the turret direction and shooting. When a bullet hits the ball, the ball disappears, an explosion animation plays, and the score increases.
Sprites Needed
- Ball
- Turret 1
- Turret 2
- Bullet 1
- Bullet 2
- Explosion
- Optional: Path or custom background
Variables Needed
Create the following variables for all sprites:
- Score
- Ball Alive
- Timer
- Ball Speed
- Level
Part 1: Create the Background Path
- Click the Stage.
- Go to Backdrops.
- Draw a road or path using the paint tools.
- Make the path go from the left side of the screen to the right side.
- The ball will follow this path.
Path Ideas
- Straight line
- Zigzag path
- Curved road
- Maze-style path
Part 2: Add a Timer
Add this code to the Stage.
when green flag clicked
set [Timer v] to [0]
forever
wait [1] seconds
change [Timer v] by [1]
end
The timer counts how long the game has been running.
Part 3: Make the Ball Move Faster Over Time
Add this code to the Stage.
when green flag clicked
set [Ball Speed v] to [2]
set [Level v] to [1]
forever
wait [10] seconds
change [Level v] by [1]
change [Ball Speed v] by [-0.2]
if <(Ball Speed) < [0.5]> then
set [Ball Speed v] to [0.5]
end
end
Important: In Scratch, a larger glide time makes the ball move slower. A smaller glide time makes the ball move faster.
Part 4: Program the Ball
The ball should move along the path using several glide points.
when green flag clicked
set [Score v] to [0]
set [Ball Alive v] to [1]
show
go to x: [-220] y: [0]
point in direction [90]
forever
if <(Ball Alive) = [1]> then
glide (Ball Speed) secs to x: [-100] y: [80]
glide (Ball Speed) secs to x: [0] y: [20]
glide (Ball Speed) secs to x: [100] y: [-60]
glide (Ball Speed) secs to x: [220] y: [0]
go to x: [-220] y: [0]
end
end
Part 5: Program Turret 1
Turret 1 will rotate left and right.
Turret 1 Controls
- Press A to turn left
- Press D to turn right
- Press W to shoot
when green flag clicked
go to x: [-150] y: [-120]
point in direction [0]
forever
if <key [a v] pressed?> then
turn left [5] degrees
end
if <key [d v] pressed?> then
turn right [5] degrees
end
end
Part 6: Program Bullet 1
Bullet 1 should start at Turret 1, point in the same direction as Turret 1, and move forward.
when green flag clicked
hide
when [w v] key pressed
go to [Turret 1 v]
point in direction ([direction v] of [Turret 1 v])
show
repeat until <<touching [edge v]?> or <touching [Ball v]?>>
move [10] steps
end
if <touching [Ball v]?> then
change [Score v] by [1]
set [Ball Alive v] to [0]
broadcast [Ball Hit v]
end
hide
Part 7: Program Turret 2
Turret 2 will also rotate left and right.
Turret 2 Controls
- Press Left Arrow to turn left
- Press Right Arrow to turn right
- Press Up Arrow to shoot
when green flag clicked
go to x: [150] y: [-120]
point in direction [0]
forever
if <key [left arrow v] pressed?> then
turn left [5] degrees
end
if <key [right arrow v] pressed?> then
turn right [5] degrees
end
end
Part 8: Program Bullet 2
when green flag clicked
hide
when [up arrow v] key pressed
go to [Turret 2 v]
point in direction ([direction v] of [Turret 2 v])
show
repeat until <<touching [edge v]?> or <touching [Ball v]?>>
move [10] steps
end
if <touching [Ball v]?> then
change [Score v] by [1]
set [Ball Alive v] to [0]
broadcast [Ball Hit v]
end
hide
Part 9: Make the Ball Disappear When Hit
Add this code to the Ball sprite.
when I receive [Ball Hit v] hide wait [1] seconds go to x: [-220] y: [0] set [Ball Alive v] to [1] show
This makes the ball disappear when it is hit, then respawn after 1 second.
Part 10: Add an Explosion Sprite
Create a new sprite called Explosion.
Explosion Costume Ideas
- Small explosion
- Medium explosion
- Large explosion
- Fading explosion
You can draw these costumes using circles, stars, or burst shapes.
Part 11: Program the Explosion Animation
Add this code to the Explosion sprite.
when green flag clicked hide when I receive [Ball Hit v] go to [Ball v] show switch costume to [explosion1 v] wait [0.1] seconds next costume wait [0.1] seconds next costume wait [0.1] seconds next costume wait [0.1] seconds hide
This makes the explosion appear where the ball was hit.
Part 12: Timer-Based Game Over
Add this code to the Stage if you want the game to last 60 seconds.
when green flag clicked wait [60] seconds say [Game Over!] for [3] seconds stop [all v]
Part 13: Score Goal
You can stop the game when the score reaches 10.
when green flag clicked
forever
if <(Score) >= [10]> then
say [You win!] for [3] seconds
stop [all v]
end
end
Final Game Requirements
- A ball follows a path across the screen.
- Two turrets are placed on the screen.
- The player controls turret rotation.
- The player controls turret shooting.
- The score increases when the ball is hit.
- The ball disappears when hit.
- An explosion animation appears when the ball is hit.
- A timer counts how long the game has been running.
- The ball moves faster as the game runs longer.
Student Drop-Off Requirements into google classroom
Submit the following items:
- Scratch project file or Scratch share link.
- Screenshot of your game running.
- Short video showing the required game features.
Your video should show:
- The timer counting up.
- The ball moving along the path.
- The ball getting faster over time.
- Both turrets rotating.
- Both turrets shooting.
- The explosion animation when the ball is hit.
- The score increasing when the ball is hit.
Suggested File Names
PX_ScratchTurretGame_lastname.sb3 PX_ScratchTurretGame_lastname.png PX_ScratchTurretGame_lastname.mp4