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

@@ -5,3 +5,4 @@ ASTEROID_MIN_RADIUS = 20
ASTEROID_KINDS = 3
ASTEROID_SPAWN_RATE = 0.8 # seconds
ASTEROID_MAX_RADIUS = ASTEROID_MIN_RADIUS * ASTEROID_KINDS
PLAYER_TURN_SPEED = 300

View File

@@ -29,6 +29,8 @@ def main():
pygame.Surface.fill(screen, (0,0,0))
player.update(dt)
player.draw(screen)
pygame.display.flip() #refresh screen

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)