Lesson 19: Leveling Up โ Difficulty Scaling (Matthes Ch 14 ยง2)
Learning Intentions
- Make the game harder each time you clear a fleet โ ship/bullet/alien speeds all multiply by a scale factor.
Success Criteria
- Each new fleet is visibly faster.
- Ship speed and bullet speed also scale (so the game stays fair).
- I can explain why we split Settings into static + dynamic methods.
๐ Do Now โ Error of the Day
Play your L18 build for 90 seconds. Notice: every run feels exactly the same. The fleet speed doesn't change. Today we fix that.
๐ I Do โ Teacher Demo
Live-split Settings into __init__ (static: screen size, colours, speedup_scale) + initialize_dynamic_settings() (mutable: ship/bullet/alien speeds). Add increase_speed() that multiplies all three by scale.
๐ค We Do โ Build Together
Call self.settings.increase_speed() after fleet-clear. Call initialize_dynamic_settings() in _check_play_button (reset on new game). Each new fleet is faster.
๐ You Do โ Your Turn
Tune speedup_scale. Try 1.05 (gentle), 1.2 (stressful), 1.5 (brutal). Arcade quests cover static vs dynamic attributes.
- Refactor Settings: static attrs in __init__, dynamic attrs in initialize_dynamic_settings
- Add speedup_scale = 1.1 to static
- Write Settings.increase_speed() that multiplies all speeds by speedup_scale
- In _check_bullet_alien_collisions, after fleet-clear: self.settings.increase_speed()
- Call self.settings.initialize_dynamic_settings() in _check_play_button (reset on new game)
๐ฎ Practice Quests โ work through these
Loading practice quests for this lesson...
Three tiers โ pick yours
Support
settings_v2_starter.py with split scaffolded
Core
type along
Extension
level banner + cap
Extensions
- Cap speedup_scale at 3.0 so late-game stays playable.
- Add a 'LEVEL X' flash for 1 second when the fleet is cleared.
๐ Exit Ticket โ Coding Journal
Journal: why did we split Settings into two methods? What problem did it solve?
Evidence of Learning
Each new fleet is faster. Reset clicks bring speeds back to start.