Lesson 6: Ship Image + Ship Class (Matthes Ch 12 ยง4)
Learning Intentions
- Build a Ship class that loads a sprite and positions it on screen using Rect properties.
Success Criteria
- ship.bmp appears centred at the bottom of my window.
- I can explain what a Rect stores.
- My Ship class has __init__ and a blitme method.
๐ Do Now โ Error of the Day
Download ship.bmp from the hub's checkpoints folder. Put it in your game folder (same place as alien_invasion.py). The file name must match EXACTLY.
๐ I Do โ Teacher Demo
Live-code the Ship class: image.load, get_rect(), rect.midbottom = screen_rect.midbottom. Draw a diagram of Rect properties (x, y, right, bottom, midtop, midbottom, center).
๐ค We Do โ Build Together
Class types along: everyone gets a Ship class + a ship sprite visible at bottom-centre. Raise hand when yours appears. Test different starting positions.
๐ You Do โ Your Turn
Complete the Ship class. Experiment with Rect properties โ try top-centre, centre, off-screen. Arcade quests below cover image loading + Rect basics.
- Download ship.bmp from the hub
- Build the Ship class (type it)
- Create ship = Ship(screen) in main
- Call ship.blitme() in game loop after screen.fill()
๐ฎ Practice Quests โ work through these
Loading practice quests for this lesson...
Three tiers โ pick yours
Support
ship_class_starter.py with blitme method pre-written. Visual diagram of Rect
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
- Use your own 32ร48 ship sprite from piskelapp.com.
- Position ship at top-centre instead; explain what changed.
๐ Exit Ticket โ Coding Journal
Journal: what did it feel like seeing your first Pygame sprite on screen?
Evidence of Learning
Ship sprite visible at bottom-centre.