Dojo Defender Session 7: Demo
How to demo the solution
- Open a terminal in the project folder.
- Run:
uv run python3 code/sessions/08-sky-highway/dojo-defender-solution/main.pyShow:
- Menu: shows the high score (0 the first time)
- SPACE starts the game
- Power-ups spawn: shoot enemies until a power-up drops (20% chance)
- Blue power-up (spread shot): shows “SPREAD SHOT: 5s” at the top, fires 3 bullets
- Green power-up (shield): shows “SHIELD: 5s”, shield aura around the ship, absorbs 1 hit
- Yellow power-up (speed boost): shows “SPEED BOOST: 5s”, ship moves 2x faster
- Game over: shows the score, the high score, and “NEW HIGH SCORE!” on a record
- Restart: the new high score is saved
Code highlights to show:
spawn_powerup()— spawn on enemy death- Power-up collection + timer in the game loop
save_highscore()/load_highscore()— reading and writing a file- Spread shot:
angles = [-15, 0, 15]withmath.sin()andmath.cos()