From bc8474b4c531905eb769eab5266b003836f1614a Mon Sep 17 00:00:00 2001 From: Marcin Kostrzewski Date: Mon, 6 Apr 2020 00:40:16 +0200 Subject: [PATCH] Player can now pick up items --- src/game/EventManager.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/game/EventManager.py b/src/game/EventManager.py index 7ee55b6..313a0b8 100644 --- a/src/game/EventManager.py +++ b/src/game/EventManager.py @@ -1,5 +1,6 @@ import pygame +from src.entities.Pickupable import Pickupable from src.entities.Player import Rotations # Player can move every given milliseconds @@ -36,7 +37,11 @@ class EventManager: def handlePlayerControls(self, keys): # Key names are temporary # TODO: Load key bindings from JSON - + if keys[pygame.K_SPACE]: + object = self.game.map.getEntityOnCoord(self.player.getFacingCoord()) + if type(object) is Pickupable: + object.on_pickup(self.player) + self.game.map.removeSpriteFromMap(object) 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):