From 87c71981992c8825cec4bfac1cdf5cc59d951484 Mon Sep 17 00:00:00 2001 From: Marcin Kostrzewski Date: Mon, 6 Apr 2020 10:38:12 +0200 Subject: [PATCH] Player can now interact with interactable entities --- src/game/EventManager.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/game/EventManager.py b/src/game/EventManager.py index 1bc3e42..f5dc67e 100644 --- a/src/game/EventManager.py +++ b/src/game/EventManager.py @@ -1,5 +1,6 @@ import pygame +from src.entities.Interactable import Interactable from src.entities.Pickupable import Pickupable from src.entities.Player import Rotations @@ -39,11 +40,18 @@ class EventManager: def handlePlayerControls(self, keys): # 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) + + # 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):