player rotation
This commit is contained in:
@@ -5,3 +5,4 @@ ASTEROID_MIN_RADIUS = 20
|
|||||||
ASTEROID_KINDS = 3
|
ASTEROID_KINDS = 3
|
||||||
ASTEROID_SPAWN_RATE = 0.8 # seconds
|
ASTEROID_SPAWN_RATE = 0.8 # seconds
|
||||||
ASTEROID_MAX_RADIUS = ASTEROID_MIN_RADIUS * ASTEROID_KINDS
|
ASTEROID_MAX_RADIUS = ASTEROID_MIN_RADIUS * ASTEROID_KINDS
|
||||||
|
PLAYER_TURN_SPEED = 300
|
||||||
|
|||||||
2
main.py
2
main.py
@@ -29,6 +29,8 @@ def main():
|
|||||||
|
|
||||||
pygame.Surface.fill(screen, (0,0,0))
|
pygame.Surface.fill(screen, (0,0,0))
|
||||||
|
|
||||||
|
player.update(dt)
|
||||||
|
|
||||||
player.draw(screen)
|
player.draw(screen)
|
||||||
|
|
||||||
pygame.display.flip() #refresh screen
|
pygame.display.flip() #refresh screen
|
||||||
|
|||||||
14
player.py
14
player.py
@@ -1,6 +1,6 @@
|
|||||||
import pygame
|
import pygame
|
||||||
from circleshape import CircleShape
|
from circleshape import CircleShape
|
||||||
from constants import PLAYER_RADIUS
|
from constants import PLAYER_RADIUS, PLAYER_TURN_SPEED
|
||||||
|
|
||||||
|
|
||||||
class Player(CircleShape):
|
class Player(CircleShape):
|
||||||
@@ -20,3 +20,15 @@ class Player(CircleShape):
|
|||||||
def draw(self, screen):
|
def draw(self, screen):
|
||||||
pygame.draw.polygon(screen, (255,255,255), self.triangle(), 2)
|
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