L17 ยท T2 Week 9 ๐ŸŽฏ CT5-DPM-01 ยท CT5-COM-01 ๐Ÿ“‚ Phase 2 โ€” Alien Invasion ยท Ch 14 Scoring + End

Lesson 17: Ship Hits + Lives + Game Over (Matthes Ch 13 ยง6)

Learning Intentions

Success Criteria

๐Ÿ“ Do Now โ€” Error of the Day

Look at your L16 game. Right now, nothing bad happens if an alien reaches the bottom. Is that fair? What should happen?

๐Ÿ‘ I Do โ€” Teacher Demo

Live-code the ship-alien collision check with spritecollideany. Build _ship_hit() with sleep(0.5) + reset. Add _check_aliens_bottom() (reuses _ship_hit). Track ships_left as a simple counter (GameStats class comes next lesson).

๐Ÿค We Do โ€” Build Together

Class adds stakes together. Run into an alien โ€” ship dies, lives drop, ship re-centres, 0.5s pause. Lose 3 lives โ€” game exits (for now).

๐Ÿš€ You Do โ€” Your Turn

Tune ship_limit. Try 1 (brutal), 3 (book), 5 (easy). Arcade quests cover spritecollideany + counter tracking.

  • Add self.ships_left = 3 to Game.__init__
  • Add pygame.sprite.spritecollideany(self.ship, self.aliens) check each frame
  • Build _ship_hit(): sleep(0.5), empty groups, respawn fleet + ship
  • Add _check_aliens_bottom() โ€” treat bottom-reach the same as ship-hit

๐ŸŽฎ Practice Quests โ€” work through these

Loading practice quests for this lesson...

Three tiers โ€” pick yours

Support

_ship_hit pre-written

Core

build from scratch

Extension

flash + brief invincibility

Extensions

๐Ÿ“ Exit Ticket โ€” Coding Journal

Journal: why does _ship_hit call sleep(0.5)? What would happen if we didn't?

Evidence of Learning

Lives decrement on hit; game ends cleanly after 3 deaths.

โ† PreviousLesson L16โ†‘ HubAll LessonsNext โ†’Lesson L18