Task: MIL-003#1 Task: MIL-003#2 Task: MIL-003#3 Task: MIL-003#4 Task: MIL-003#5 Task: MIL-003#6
962 B
962 B
English · Dansk · Bahasa Malaysia
Step 2: Spaceship
What we built
The Ship class, a green triangle at the bottom of the screen. The arrow keys move it one step left or right, and it stops at the screen edges. The limit is a pure function, clamp, in rules.py.
What we gained
- Subclassing
Turtleto make a game object - Binding keys with
listenandonkeypress - Keeping a rule free of the screen (
clamp) so a test needs no window - Testing screen objects in a container instead of on the desktop
Try it
Press Left and Right.
Where the code is
src/ship.py, src/rules.py: clamp
Previous: Game screen · Next: Shooting · Overview
