player forward backward movement
This commit is contained in:
@@ -6,3 +6,4 @@ 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
|
PLAYER_TURN_SPEED = 300
|
||||||
|
PLAYER_SPEED = 200
|
||||||
|
|||||||
12
player.py
12
player.py
@@ -1,6 +1,6 @@
|
|||||||
import pygame
|
import pygame
|
||||||
from circleshape import CircleShape
|
from circleshape import CircleShape
|
||||||
from constants import PLAYER_RADIUS, PLAYER_TURN_SPEED
|
from constants import PLAYER_RADIUS, PLAYER_SPEED, PLAYER_TURN_SPEED
|
||||||
|
|
||||||
|
|
||||||
class Player(CircleShape):
|
class Player(CircleShape):
|
||||||
@@ -32,3 +32,13 @@ class Player(CircleShape):
|
|||||||
|
|
||||||
if keys[pygame.K_d]:
|
if keys[pygame.K_d]:
|
||||||
self.rotate(dt)
|
self.rotate(dt)
|
||||||
|
|
||||||
|
if keys[pygame.K_w]:
|
||||||
|
self.move(dt)
|
||||||
|
|
||||||
|
if keys[pygame.K_s]:
|
||||||
|
self.move(-dt)
|
||||||
|
|
||||||
|
def move(self, dt):
|
||||||
|
forward = pygame.Vector2(0, 1).rotate(self.rotation)
|
||||||
|
self.position += forward * PLAYER_SPEED * dt
|
||||||
|
|||||||
Reference in New Issue
Block a user