🏆 Phase 4 · Advanced Projects 🟣 Advanced MODULE 14

Space Shooter

⏱️ 55 min
📖 Theory + Build
🧩 5 Quiz Questions
🚀 Full Game Build
Your progress in Phase 450%
🎯 What you'll learn: How to fire bullets using clones, create waves of enemies, track lives, and build a complete Space Shooter game — one of the most classic arcade games!

Anatomy of a Space Shooter

🚀
Player Ship
Moves left/right. Shoots bullets upward. Has lives.
🔵
Bullet
Clone-based. Appears at ship, moves up. Destroys enemies on contact.
👾
Enemy
Clone-based. Spawns at top, drifts down. Player loses life if it reaches bottom.
💥
Explosion
Brief animation played when an enemy or player is hit.
Score
+10 per enemy hit. +50 bonus for clearing a wave. Show with variable.
❤️
Lives
Start with 3. Lose one when enemy reaches bottom or hits ship. Game over at 0.
HOW BULLETS WORK — CLONE LIFECYCLE
Press SpaceShip fires
Create Cloneof Bullet sprite
Clone appearsat ship position
Clone movesup (change y by 10)
Hit enemy?delete this clone

The Code — Three Sprite System

🧩 CODEShip (Player) — move and shoot
🚀
Ship
You control this one!
when 🚩 clicked
set score to 0
set lives to 3
go to x: 0 y: -150
forever
if key right arrow pressed? then
change x by 5
if key left arrow pressed? then
change x by -5
if key space pressed? then
create clone of Bullet
wait 0.25 seconds
💬 In kid words: "Arrows slide the ship left and right. Space bar fires a bullet clone — the little wait stops you firing a laser wall!"
🧩 CODEBullet — born at the ship, flies up, disappears
Bullet
The original hides — clones do the flying
when 🚩 clicked
hide
🫥 The original bullet stays invisible backstage.
when I start as a clone
go to Ship
show
repeat until y position > 180
change y by 10
if touching Enemy ? then
broadcast enemy-hit
change score by 10
delete this clone
delete this clone
💬 In kid words: "Each bullet is born at the ship and zooms upward. Hit an enemy? Shout 'enemy-hit!', collect 10 points and vanish. Reach the top without hitting anything? Just vanish."
🧩 CODEEnemy — spawner, drifting down, and getting hit
👾
Enemy
Three scripts on the enemy sprite
when 🚩 clicked
hide
forever
create clone of myself
wait 1.5 seconds
🏭 Script 1: "A new alien appears every 1.5 seconds!"
when I start as a clone
go to x: pick random -200 to 200 y: 170
show
forever
change y by -2
if y position < -170 then
change lives by -1
delete this clone
if touching Ship ? then
change lives by -1
delete this clone
👾 Script 2: "Each alien starts at a random spot up top and drifts down. If it reaches the bottom or crashes into your ship — you lose a life!"
when I receive enemy-hit
if touching Bullet ? then
start sound explosion
delete this clone
💥 Script 3: "When the 'enemy-hit' signal arrives, only the alien actually touching the bullet explodes — the others keep coming!"
⚠️
Live checking — only 0? Then game over
In your game loop (or a separate "lives watcher" forever loop), add: if lives = 0 then say "Game Over!" wait 2 secs stop all. Without this check, the game continues even when lives hit zero!

Build It Step by Step

1
Create sprites: Ship, Bullet, Enemy
Draw or use library sprites. Ship → spaceship, Bullet → thin oval/beam (10px wide), Enemy → alien or asteroid. Keep sprites small (ship 60px, bullet 15px, enemy 40px).
2
Set the backdrop
Use the "Stars" backdrop from the Backdrop Library, or draw your own space background with dark blue and star dots.
3
Code the Ship (player)
Left/right movement, fire with space key (create Bullet clone). Limit fire rate with wait 0.25 seconds so bullets can't spam.
4
Code the Bullet clone
"When I start as a clone" → go to Ship → show → move up (change y 10) → if touching Enemy: broadcast enemy-hit, score+10, delete → if off screen: delete.
5
Code the Enemy spawner
Original hides and spawns clones every 1.5 seconds. Each clone appears at top with random X, drifts down. Touching Ship or bottom = lose life, delete.
6
Add Game Over screen
Check lives every frame. When lives = 0: stop all sprites, show "GAME OVER" backdrop, display final score. Add a restart button!
💡
Add difficulty waves!
As score increases, increase enemy speed and spawn rate. Example: if score > 100 then set enemy_speed to 3, if score > 200 then set spawn_wait to 1. The game gets harder as players improve!
🧩 Knowledge Check — Lesson 14
5 questions on Space Shooter mechanics!
1. How are bullets created in the Space Shooter game?
2. Why do we add "wait 0.25 seconds" after creating a bullet clone?
3. When a bullet hits an enemy, what sequence should happen?
4. What should happen when an enemy clone reaches y < -170 (the bottom)?
5. How can you make the game get harder as the player scores more points?
💪
Space Shooter Challenge — Lesson 14
Advanced multi-sprite game · Expert Level
Challenge: Boss Battle! 👾

Add a BOSS enemy that appears every 50 points — it's bigger, takes 5 hits to destroy, and shoots back!

Requirements:
1. Create a Boss sprite — big alien (size 150%), health variable starts at 5
2. Boss appears when score reaches 50, 150, 300 (use modulo checks)
3. Each bullet hit: change boss_health by -1. When boss_health = 0: score +50, boss hides
4. Boss fires back every 3 seconds — create clone of its own bullet heading DOWN
5. If boss bullet touches player ship: lose 1 life
💡 Show hints if you're stuck
  • Boss health: create variable boss_health. When bullet hits boss: change boss_health by -1. If boss_health = 0 then hide boss, score +50
  • Boss appears: in a watcher loop, if (score mod 50 = 0 and score > 0 and boss visible = false) then show boss, set boss_health to 5
  • Boss shoots: forever → wait 3 secs → create clone of [BossBullet]
  • Boss bullet clone: go to Boss position, show, change y by -5 until y < -170, if touching Ship: lives -1, delete clone
🚀

Space Shooter Complete!

You can build arcade games! Up next: plan and design your very own game from scratch!

Module 14 of 16Phase 4 — Advanced Projects
📝 Worksheet