player rotation

This commit is contained in:
2025-07-11 19:11:17 +02:00
parent adad70eaa5
commit dd97b1c415
3 changed files with 16 additions and 1 deletions

View File

@@ -1,6 +1,6 @@
import pygame
from circleshape import CircleShape
from constants import PLAYER_RADIUS
from constants import PLAYER_RADIUS, PLAYER_TURN_SPEED
class Player(CircleShape):
@@ -20,3 +20,15 @@ class Player(CircleShape):
def draw(self, screen):
pygame.draw.polygon(screen, (255,255,255), self.triangle(), 2)
def rotate(self, dt):
self.rotation += PLAYER_TURN_SPEED * dt
def update(self, dt):
keys = pygame.key.get_pressed()
if keys[pygame.K_a]:
self.rotate(-dt)
if keys[pygame.K_d]:
self.rotate(dt)