

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Still calibrating
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]
screen object"white")self.triangle() function)constants.py file)x = SCREEN_WIDTH / 2y = SCREEN_HEIGHT / 2Draw 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.