player forward backward movement
This commit is contained in:
12
player.py
12
player.py
@@ -1,6 +1,6 @@
|
||||
import pygame
|
||||
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):
|
||||
@@ -32,3 +32,13 @@ class Player(CircleShape):
|
||||
|
||||
if keys[pygame.K_d]:
|
||||
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