From a06ce53fc1c4603d33a89a1334aa5687dc0e7e6f Mon Sep 17 00:00:00 2001 From: Marcin Kostrzewski Date: Sun, 5 Apr 2020 23:42:41 +0200 Subject: [PATCH 1/2] Implemented getEntityOnCoord method --- src/game/Map.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/game/Map.py b/src/game/Map.py index a8408d7..e70e439 100644 --- a/src/game/Map.py +++ b/src/game/Map.py @@ -1,8 +1,8 @@ import json import pygame -from game.TerrainTile import TerrainTile -from game.Screen import Locations +from src.game.TerrainTile import TerrainTile +from src.game.Screen import Locations from src.entities.Entity import Entity from src.entities.Pickupable import Pickupable @@ -75,6 +75,13 @@ class Map: self.screen.draw(object, Locations.MAP, 0, 0) self.collidables.add(object) + def getEntityOnCoord(self, coord): + result = None + for entity in self.collidables: + if entity.rect.x == coord[0] and entity.rect.y == coord[1] + result = entity + return result + def addEntity(self, entity): self.screen.draw(entity, Locations.MAP, 0, 0) self.collidables.add(entity) From 7b34e04665de8fbd32dd6eb9152ec08eed4c22cc Mon Sep 17 00:00:00 2001 From: Marcin Kostrzewski Date: Sun, 5 Apr 2020 23:43:15 +0200 Subject: [PATCH 2/2] Fixed syntax --- src/game/Map.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/game/Map.py b/src/game/Map.py index e70e439..3cbf07f 100644 --- a/src/game/Map.py +++ b/src/game/Map.py @@ -78,7 +78,7 @@ class Map: def getEntityOnCoord(self, coord): result = None for entity in self.collidables: - if entity.rect.x == coord[0] and entity.rect.y == coord[1] + if entity.rect.x == coord[0] and entity.rect.y == coord[1]: result = entity return result