Files
095-assignment-space-invaders/docs/wiki/Step-5-Alien-Movement.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

1.1 KiB

English · Dansk · Bahasa Malaysia

Step 5: Alien movement

The fleet after it has moved to the right

What we built

Every second the fleet moves one step sideways. When the next step would take an alien past the edge, the fleet drops closer and turns around. The time is read with time.monotonic, and the decision is made by the pure functions is_due and next_fleet_move.

What we gained

  • Moving by time, not by counting frames, so the speed does not depend on the computer
  • Writing the decision of the next move as a function that returns the change and the new direction
  • Dropping and reversing at an edge
  • Testing a time rule by passing the time in

Try it

Wait a few seconds and watch the fleet move.

Where the code is

src/fleet.py: update, move; src/rules.py: is_due, next_fleet_move

Previous: Alien fleet · Next: Shooting aliens · Overview