"elif'ed" the movement keys for the player.
This commit is contained in:
parent
781573dd9d
commit
9fe46b6f44
|
@ -94,22 +94,22 @@ class Player(worldobject.WorldObject):
|
|||
|
||||
keys = pygame.key.get_pressed()
|
||||
if keys[pygame.K_UP]:
|
||||
if not self.holding:
|
||||
if not self.holding and not self.is_moving:
|
||||
self.direction = (0, -1)
|
||||
self.anim = 'up'
|
||||
self.move(0, -1)
|
||||
if keys[pygame.K_DOWN]:
|
||||
if not self.holding:
|
||||
elif keys[pygame.K_DOWN]:
|
||||
if not self.holding and not self.is_moving:
|
||||
self.direction = (0, 1)
|
||||
self.anim = 'down'
|
||||
self.move(0, 1)
|
||||
if keys[pygame.K_RIGHT]:
|
||||
if not self.holding:
|
||||
elif keys[pygame.K_RIGHT]:
|
||||
if not self.holding and not self.is_moving:
|
||||
self.direction = (1, 0)
|
||||
self.anim = 'right'
|
||||
self.move(1, 0)
|
||||
if keys[pygame.K_LEFT]:
|
||||
if not self.holding:
|
||||
elif keys[pygame.K_LEFT]:
|
||||
if not self.holding and not self.is_moving:
|
||||
self.direction = (-1, 0)
|
||||
self.anim = 'left'
|
||||
self.move(-1, 0)
|
||||
|
|
|
@ -36,7 +36,7 @@ class WorldObject(object):
|
|||
|
||||
self.init_x = self.move_x = self.x = x - (x % self.tile_x)
|
||||
self.init_y = self.move_y = self.y = y - (y % self.tile_y)
|
||||
self.init_direction = self.direction
|
||||
self.init_direction = self.move_direction = self.direction
|
||||
|
||||
self.holding = None
|
||||
self.holder = None
|
||||
|
@ -91,6 +91,8 @@ class WorldObject(object):
|
|||
if self.holding:
|
||||
self.holding.move(move_x, move_y)
|
||||
|
||||
self.move_direction = self.move_x, self.move_y
|
||||
|
||||
return True
|
||||
return False
|
||||
|
||||
|
|
Loading…
Reference in New Issue