We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Moving

Now we want the ship to move back and forth with the W and S keys.

Assignment

    This is a course on programming, not vector math, so we've provided the math for you. All those words boil down to these lines of code:

    unit_vector = pygame.Vector2(0, 1)
    rotated_vector = unit_vector.rotate(self.rotation)
    rotated_with_speed_vector = rotated_vector * PLAYER_SPEED * dt
    self.position += rotated_with_speed_vector
    

    unit_vector.rotate() returns a new vector – it doesn't modify the original. That's why we assign the result to rotated_vector.

If everything looks good, run and submit the CLI tests.