player rotation
This commit is contained in:
14
player.py
14
player.py
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user