Game: correct declarative order

Map: collidableTerrain list
This commit is contained in:
Wirus 2020-04-05 15:41:42 +02:00
parent c338d6caa1
commit 6a1fe72cab
2 changed files with 7 additions and 3 deletions

View File

@ -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()

View File

@ -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 == '.':