🏆 Phase 4 · Advanced Projects
🟣 Advanced
MODULE 14
Space Shooter
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!
Section 1
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
Section 2
The Code — Three Sprite System
Ship (Player) — Movement + Shooting
SCRATCH BLOCKS
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] ← fire! wait (.25) seconds ← limit fire rate
Bullet — Clone Lifecycle
SCRATCH BLOCKS
when 🚩 clicked hide ← original stays hidden when I start as a clone go to [Ship] ← start at the ship! show repeat until <(y position) > 180> change y by (10) ← fly upward if <touching [Enemy]?> then broadcast [enemy-hit] ← tell enemy it was hit change [score] by (10) delete this clone delete this clone ← reached top without hitting
Enemy — Clone Spawner + Hit Detection
SCRATCH BLOCKS
when 🚩 clicked hide forever create clone of [myself] wait (1.5) seconds ← spawn rate when I start as a clone go to x: (pick random -200 to 200) y:(170) show forever change y by (-2) ← drift down if <(y position) < -170> then change [lives] by (-1) ← reached bottom = lose life! delete this clone if <touching [Ship]?> then change [lives] by (-1) delete this clone when I receive [enemy-hit] if <touching [Bullet]?> then ← only this clone if it's touching the bullet play sound [explosion] delete this clone
⚠️
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!Section 3
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
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
Module 14 of 16Phase 4 — Advanced Projects