Moving Around
We want the spaceship to be able to move; but what does that mean specifically? Let's break it down:
- If we press the move-left key, the ship should rotate to the left (i.e., counter-clockwise).
- If we press the move-right key, the ship should rotate to the right (i.e., clockwise).
- If we press the move-forward key, the ship should move forward.
- If we press the move-backward key, the ship should move backward.
Left and right seem pretty similar. Let's try to write a small function to tackle those first!
Assignment
-
-
-
def update(self, dt):
keys = pygame.key.get_pressed()
if keys[pygame.K_a]:
# ?
if keys[pygame.K_d]:
# ?
If you're using a non-QWERTY keyboard, you may want to change the keybindings in the code to something other than the W, A, S and D keys.
-
-
-
If everything seems to be working, run and submit the CLI tests.