added player movement
This commit is contained in:
parent
5b8a9dd113
commit
703023c019
2 changed files with 11 additions and 3 deletions
|
|
@ -24,6 +24,7 @@ class Player(circleshape.CircleShape):
|
|||
self.rotation += dt*constants.PLAYER_ROTATION_SPEED
|
||||
else:
|
||||
self.rotation += -dt*constants.PLAYER_ROTATION_SPEED
|
||||
|
||||
def update(self, dt):
|
||||
keys = pygame.key.get_pressed()
|
||||
|
||||
|
|
@ -31,3 +32,10 @@ class Player(circleshape.CircleShape):
|
|||
self.rotate(dt,"left")
|
||||
if keys[pygame.K_d]:
|
||||
self.rotate(dt,"right")
|
||||
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 * constants.PLAYER_SPEED * dt
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue