Lesson 10: Bullet Class + Sprite Inheritance (Matthes Ch 12 ยง8 pt 1)
Learning Intentions
- Build a Bullet class that inherits from pygame.
- sprite.
- Sprite so it gets Group-management features for free.
Success Criteria
- My Bullet class inherits from Sprite using class Bullet(Sprite).
- I can explain what super().__init__() does.
- A single bullet can be created manually and drawn at the ship's top.
๐ 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
- Parameterise bullet colour from Settings (prep for L11).
- Experiment with different bullet shapes (circle, oval).
๐ 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.