L10 ยท T2 Week 5 ๐ŸŽฏ CT5-DPM-01 ยท CT5-THI-01 ๐Ÿ“‚ Phase 2 โ€” Alien Invasion ยท Ch 12 Ship + Bullets

Lesson 10: Bullet Class + Sprite Inheritance (Matthes Ch 12 ยง8 pt 1)

Learning Intentions

Success Criteria

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

Look at this line: class Bullet(pygame.sprite.Sprite): โ€” what does it mean? Turn to your neighbour and try to explain for 60 seconds.

๐Ÿ‘ I Do โ€” Teacher Demo

Live-code the Bullet class with Sprite inheritance + super().__init__(). Draw a diagram on the whiteboard: Sprite = parent (free methods), Bullet = child (adds bullet-specific stuff).

๐Ÿค We Do โ€” Build Together

Class builds the Bullet class together. Create ONE test bullet manually and draw it at ship's midtop. Verify everyone sees a bullet.

๐Ÿš€ You Do โ€” Your Turn

Finish Bullet's update() and draw_bullet() methods. Customise colour, width. Arcade quests cover Sprite inheritance + pygame.Rect.

  • from pygame.sprite import Sprite at top of bullet.py
  • Build Bullet class with super().__init__()
  • Create Rect at ship.rect.midtop
  • Write update() and draw_bullet() methods

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

Loading practice quests for this lesson...

Three tiers โ€” pick yours

Support

Bullet class skeleton with super() line pre-written. Diagram of inheritance

Core

Follow the plan as written. Attempt the arcade quests above at your own pace.

Extension

Complete all quests above + try a Boss battle for bonus XP. Help a classmate if you finish.

Extensions

๐Ÿ“ Exit Ticket โ€” Coding Journal

Journal: in 1 sentence, what does super().__init__() do and why do we need it?

Evidence of Learning

Student can create one bullet manually (not on keypress yet) and see it drawn at the ship's top.

โ† PreviousLesson L09โ†‘ HubAll LessonsNext โ†’Lesson L11