Task: MIL-003#1 Task: MIL-003#2 Task: MIL-003#3 Task: MIL-003#4 Task: MIL-003#5 Task: MIL-003#6
27 lines
1006 B
Markdown
27 lines
1006 B
Markdown
**English** · [Dansk](Step-4-Alien-Fleet-da) · [Bahasa Malaysia](Step-4-Alien-Fleet-ms)
|
|
|
|
# Step 4: Alien fleet
|
|
|
|

|
|
|
|
## What we built
|
|
|
|
The `Alien` and `Fleet` classes: five rows of eight aliens, each row in its own colour, centred at the top of the screen. The positions are worked out by `fleet_positions` in `rules.py`.
|
|
|
|
## What we gained
|
|
|
|
- Turning a grid into a list of positions with nested loops
|
|
- Separating the layout calculation (pure, tested) from the drawing
|
|
- Using one colour per row to tell rows apart
|
|
- Keeping the alien objects in a list the rest of the game can use
|
|
|
|
## Try it
|
|
|
|
Start the game; the fleet is in place.
|
|
|
|
## Where the code is
|
|
|
|
`src/alien.py`, `src/fleet.py`, `src/rules.py`: `fleet_positions`
|
|
|
|
Previous: [Shooting](Step-3-Shooting) · Next: [Alien movement](Step-5-Alien-Movement) · [Overview](Home)
|