diff --git a/src/entities/Player.py b/src/entities/Player.py index ffcbfd4..1a2d160 100644 --- a/src/entities/Player.py +++ b/src/entities/Player.py @@ -85,11 +85,10 @@ class Player(Entity): return self.statistics def rotate(self, rotation): - if self.alive: - # If the player is not facing given direction, it will not move the first time, it will only get rotated - if self.rotation.value != rotation.value: - self.image = pygame.transform.rotate(self.image, ((self.rotation.value - rotation.value) * 90)) - self.rotation = rotation + # If the player is not facing given direction, it will not move the first time, it will only get rotated + if self.rotation.value != rotation.value: + self.image = pygame.transform.rotate(self.image, ((self.rotation.value - rotation.value) * 90)) + self.rotation = rotation # Updates self.alive if any of the statistic reaches critical value def determineLife(self): diff --git a/src/game/EventManager.py b/src/game/EventManager.py index f5dc67e..7975494 100644 --- a/src/game/EventManager.py +++ b/src/game/EventManager.py @@ -41,33 +41,34 @@ class EventManager: # Key names are temporary # TODO: Load key bindings from JSON - # Picking up items - if keys[pygame.K_SPACE]: - object = self.game.map.getEntityOnCoord(self.player.getFacingCoord()) - # Picked up item gets removed from the map - if type(object) is Pickupable: - object.on_interaction(self.player) - self.game.map.removeSpriteFromMap(object) - elif type(object) is Interactable: - object.on_interaction(self.player) + if self.player.alive: + # Picking up items + if keys[pygame.K_SPACE]: + object = self.game.map.getEntityOnCoord(self.player.getFacingCoord()) + # Picked up item gets removed from the map + if type(object) is Pickupable: + object.on_interaction(self.player) + self.game.map.removeSpriteFromMap(object) + elif type(object) is Interactable: + object.on_interaction(self.player) - # Movement - if keys[pygame.K_w]: - self.player.rotate(Rotations.NORTH) - if not self.game.map.collision(self.player.rect.x, self.player.rect.y - self.player.rect.w): - self.player.move(Rotations.NORTH) - if keys[pygame.K_s]: - self.player.rotate(Rotations.SOUTH) - if not self.game.map.collision(self.player.rect.x, self.player.rect.y + self.player.rect.w): - self.player.move(Rotations.SOUTH) - if keys[pygame.K_d]: - self.player.rotate(Rotations.EAST) - if not self.game.map.collision(self.player.rect.x + self.player.rect.w, self.player.rect.y): - self.player.move(Rotations.EAST) - if keys[pygame.K_a]: - self.player.rotate(Rotations.WEST) - if not self.game.map.collision(self.player.rect.x - self.player.rect.w, self.player.rect.y): - self.player.move(Rotations.WEST) + # Movement + if keys[pygame.K_w]: + self.player.rotate(Rotations.NORTH) + if not self.game.map.collision(self.player.rect.x, self.player.rect.y - self.player.rect.w): + self.player.move(Rotations.NORTH) + if keys[pygame.K_s]: + self.player.rotate(Rotations.SOUTH) + if not self.game.map.collision(self.player.rect.x, self.player.rect.y + self.player.rect.w): + self.player.move(Rotations.SOUTH) + if keys[pygame.K_d]: + self.player.rotate(Rotations.EAST) + if not self.game.map.collision(self.player.rect.x + self.player.rect.w, self.player.rect.y): + self.player.move(Rotations.EAST) + if keys[pygame.K_a]: + self.player.rotate(Rotations.WEST) + if not self.game.map.collision(self.player.rect.x - self.player.rect.w, self.player.rect.y): + self.player.move(Rotations.WEST)