Lesson 13: The First Alien โ One Alien on Screen (Matthes Ch 13 ยง1-2)
Learning Intentions
- Build an Alien class (structurally similar to Ship) and place ONE alien in the top-left of the screen.
Success Criteria
- My alien.py has class Alien(Sprite) with __init__ that loads alien.bmp.
- Exactly one alien appears in the upper-left.
- I can explain why Alien looks almost identical to Ship.
๐ Do Now โ Error of the Day
Download alien.bmp from the hub's checkpoints folder. Open your Ship class. Look at every line โ which lines will change for an Alien class, and which can stay identical?
๐ I Do โ Teacher Demo
Live-code the Alien class (almost a copy of Ship โ different image, different starting position). Add self.aliens = pygame.sprite.Group() to Game, call self._create_fleet(). For today, _create_fleet just adds ONE alien.
๐ค We Do โ Build Together
Class builds Alien + places one on screen together. Highlight how much was copy-paste from Ship. 'Pattern reuse' is a core programmer skill.
๐ You Do โ Your Turn
Make sure ONE alien appears top-left. Experiment โ move it to centre or top-right. Arcade quests cover class reuse + positioning.
- Create alien.py with class Alien(Sprite)
- Load alien.bmp + get_rect() (exactly like Ship)
- In Game.__init__: self.aliens = pygame.sprite.Group(); self._create_fleet()
- _create_fleet (for now): just create ONE Alien and add it to self.aliens
- Call self.aliens.draw(self.screen) in _update_screen
๐ฎ Practice Quests โ work through these
Loading practice quests for this lesson...
Three tiers โ pick yours
Support
alien.bmp provided; fill in 2 lines in Alien.__init__
Core
write class from scratch
Extension
2 alien files + random choice
Extensions
- Load a different alien.bmp colour.
- Position the first alien in the centre of the top edge instead.
๐ Exit Ticket โ Coding Journal
Journal: 1 sentence on how Alien is similar to Ship. How does inheritance save typing?
Evidence of Learning
One alien sprite visible top-left of screen.