drawing player

This commit is contained in:
2025-07-04 20:58:34 +02:00
parent 73309cb310
commit adad70eaa5
5 changed files with 51 additions and 1 deletions

22
player.py Normal file
View File

@@ -0,0 +1,22 @@
import pygame
from circleshape import CircleShape
from constants import PLAYER_RADIUS
class Player(CircleShape):
def __init__(self, x, y):
super().__init__(x, y, PLAYER_RADIUS)
self.rotation = 0
# in the player class
def triangle(self):
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]
def draw(self, screen):
pygame.draw.polygon(screen, (255,255,255), self.triangle(), 2)