added player drawing onto the screen

This commit is contained in:
specCon18 2025-01-14 03:05:15 -05:00
parent bfd9971cfb
commit ef4695aae2
4 changed files with 57 additions and 2 deletions

23
player.py Normal file
View file

@ -0,0 +1,23 @@
import circleshape
import constants
import pygame
class Player(circleshape.CircleShape):
def __init__(self,x,y):
super().__init__(x,y,constants.PLAYER_RADIUS)
self.rotation = 0
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)
def rotate(self,dt):