Files
095-assignment-space-invaders/docs/wiki/Step-8-Game-Over-and-Win.md
Tirsvad 0449c45507 Add the README screenshots, the wiki in three languages and the reflection
Task: MIL-003#1
Task: MIL-003#2
Task: MIL-003#3
Task: MIL-003#4
Task: MIL-003#5
Task: MIL-003#6
2026-11-21 18:29:47 +08:00

29 lines
1.4 KiB
Markdown

**English** · [Dansk](Step-8-Game-Over-and-Win-da) · [Bahasa Malaysia](Step-8-Game-Over-and-Win-ms)
# Step 8: Game over and win
![The GAME OVER message with the aliens at the ship](https://git.tirsystem.com/Tirsvad-Udemy-100-days-of-code/095-assignment-space-invaders/raw/branch/main/docs/images/step-8-game-over.png)
![The YOU WIN message after the last alien was shot](https://git.tirsystem.com/Tirsvad-Udemy-100-days-of-code/095-assignment-space-invaders/raw/branch/main/docs/images/step-8-win.png)
## What we built
The game is lost when an alien touches the ship or reaches the ship's row, and won when the last alien is shot. The pure function `game_state` decides, the `Banner` class writes GAME OVER or YOU WIN, and the keys stop working. The screenshots of this step come from prepared situations in `tools/scenarios/`.
## What we gained
- Describing the game as a state: playing, lost or won
- Letting one function decide the state, so the rule is in one place
- Stopping the frame loop and the keys when the game has ended
- Preparing a situation in a script to take a screenshot of a rare moment
## Try it
Let the aliens reach the ship, or shoot them all.
## Where the code is
`src/banner.py`, `src/game.py`: `check_state`, `src/rules.py`: `game_state`
Previous: [Barriers](Step-7-Barriers) · Next: [Score and lives](Step-9-Score-and-Lives) · [Overview](Home)