diff --git a/robotgame/player.py b/robotgame/player.py index 485a4cf..bd97c5d 100644 --- a/robotgame/player.py +++ b/robotgame/player.py @@ -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) diff --git a/robotgame/worldobject.py b/robotgame/worldobject.py index 80a7c4f..d9e3cc2 100644 --- a/robotgame/worldobject.py +++ b/robotgame/worldobject.py @@ -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