From 6a1fe72cabdbc3b85d9210c17298856cbd392eac Mon Sep 17 00:00:00 2001 From: Wirus Date: Sun, 5 Apr 2020 15:41:42 +0200 Subject: [PATCH] Game: correct declarative order Map: collidableTerrain list --- src/game/Game.py | 7 ++++--- src/game/Map.py | 3 +++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/game/Game.py b/src/game/Game.py index 8e5b7b5..d586e17 100644 --- a/src/game/Game.py +++ b/src/game/Game.py @@ -39,14 +39,15 @@ class Game: self.screen = Screen(self, self.config["window"]) print("OK") - self.eventManager = EventManager(self) - # Start Map implement + self.mapDataFolder = path.dirname("../data/mapdata/") self.map = Map(path.join(self.mapDataFolder, 'map.txt'), self.screen) self.player = Player((0, 0), self.map.tileSize) self.map.addEntity(self.player) - # End Map implement + self.eventManager = EventManager(self, self.player) + + self.mainLoop() diff --git a/src/game/Map.py b/src/game/Map.py index 17f19d3..fecffd0 100644 --- a/src/game/Map.py +++ b/src/game/Map.py @@ -8,6 +8,8 @@ class Map: self.screen = screen self.terrain = [] self.entities = [] + self.collidableTerrain = [] + with open(filename, 'rt') as f: for line in f: self.terrain.append(line) @@ -26,6 +28,7 @@ class Map: for col, tile in enumerate(tiles): if tile == 'w': self.screen.draw(TerrainTile('wall.png', self.tileSize), Locations.MAP, col*self.tileSize, row*self.tileSize) + self.collidableTerrain.append(self.terrain) elif tile == ',': self.screen.draw(TerrainTile('floor.png', self.tileSize), Locations.MAP, col*self.tileSize, row*self.tileSize) elif tile == '.':