

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 5
click for more info
Not enough gems
Cost: 6 gems
1: Sprites
incomplete
2: Draw Player
incomplete
3: Moving Around
incomplete
4: Moving
incomplete
5: Groups
incomplete
This lesson's interactive features are locked, please to keep using them
Let's draw a spaceship for the player!
When you use a constant or class from another file (like constants.py), remember to import it at the top of your file, for example: from constants import PLAYER_RADIUS.
PLAYER_RADIUS = 20 (the radius of the player's ship)
LINE_WIDTH = 2 (the width of the lines that draw the player's ship)
# in the Player class
def triangle(self) -> list[pygame.Vector2]:
forward = pygame.Vector2(0, 1).rotate(self.rotation)
right = pygame.Vector2(0, 1).rotate(self.rotation + 90) * self.radius / 1.5
a = self.position + forward * self.radius
b = self.position - forward * self.radius - right
c = self.position - forward * self.radius + right
return [a, b, c]The screen object
A color (use "white")
A list of points (use the list returned by a call to the self.triangle() function)
A line width (use the one in your constants.py file)
x = SCREEN_WIDTH / 2
y = SCREEN_HEIGHT / 2
Draw the player after filling the screen with black, but before flipping the screen.
Run the game for at least a few seconds, so that the log file gets populated.
If everything worked, you should see a black screen with a white triangle in the middle. Progress! Run and submit the CLI tests.