Dojo Defender Session 4: Demo
How to demo the solution
- Open a terminal in the project folder.
- Run:
uv run python3 code/sessions/05-breakout/dojo-defender-solution/main.pyShow:
- The game starts in the MENU with the “DOJO DEFENDER” title and “Press SPACE to start”
- SPACE starts the game and resets all the values
- Three enemy types:
- Drone (blue, square) — moves straight down
- Zigzag (red, triangular) — moves diagonally, bounces off the edges
- Charger (yellow, pointed) — follows the ship horizontally
- Wave system: Wave 1 only drones, Wave 2-3 drones + zigzag, Wave 4+ chargers too
- Game over: shows “GAME OVER” with the score and “Press SPACE to restart”
- State transitions: MENU → PLAYING → GAME_OVER → PLAYING
Code highlights to show:
state = "MENU"and the three branches in the drawing loopreset_game()function with all the global variablesspawn_enemy_drone(),spawn_enemy_zigzag(),spawn_enemy_charger()- The movement per
enemy.typein the game loop spawn_enemy()with wave-based selection