Player can now pick up items

This commit is contained in:
Marcin Kostrzewski 2020-04-06 00:40:16 +02:00
parent a45befd4fa
commit bc8474b4c5

View File

@ -1,5 +1,6 @@
import pygame import pygame
from src.entities.Pickupable import Pickupable
from src.entities.Player import Rotations from src.entities.Player import Rotations
# Player can move every given milliseconds # Player can move every given milliseconds
@ -36,7 +37,11 @@ class EventManager:
def handlePlayerControls(self, keys): def handlePlayerControls(self, keys):
# Key names are temporary # Key names are temporary
# TODO: Load key bindings from JSON # 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]: if keys[pygame.K_w]:
self.player.rotate(Rotations.NORTH) self.player.rotate(Rotations.NORTH)
if not self.game.map.collision(self.player.rect.x, self.player.rect.y - self.player.rect.w): if not self.game.map.collision(self.player.rect.x, self.player.rect.y - self.player.rect.w):