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"]) self.screen = Screen(self, self.config["window"])
print("OK") print("OK")
self.eventManager = EventManager(self)
# Start Map implement
self.mapDataFolder = path.dirname("../data/mapdata/") self.mapDataFolder = path.dirname("../data/mapdata/")
self.map = Map(path.join(self.mapDataFolder, 'map.txt'), self.screen) self.map = Map(path.join(self.mapDataFolder, 'map.txt'), self.screen)
self.player = Player((0, 0), self.map.tileSize) self.player = Player((0, 0), self.map.tileSize)
self.map.addEntity(self.player) self.map.addEntity(self.player)
# End Map implement self.eventManager = EventManager(self, self.player)
self.mainLoop() self.mainLoop()

View File

@ -8,6 +8,8 @@ class Map:
self.screen = screen self.screen = screen
self.terrain = [] self.terrain = []
self.entities = [] self.entities = []
self.collidableTerrain = []
with open(filename, 'rt') as f: with open(filename, 'rt') as f:
for line in f: for line in f:
self.terrain.append(line) self.terrain.append(line)
@ -26,6 +28,7 @@ class Map:
for col, tile in enumerate(tiles): for col, tile in enumerate(tiles):
if tile == 'w': if tile == 'w':
self.screen.draw(TerrainTile('wall.png', self.tileSize), Locations.MAP, col*self.tileSize, row*self.tileSize) self.screen.draw(TerrainTile('wall.png', self.tileSize), Locations.MAP, col*self.tileSize, row*self.tileSize)
self.collidableTerrain.append(self.terrain)
elif tile == ',': elif tile == ',':
self.screen.draw(TerrainTile('floor.png', self.tileSize), Locations.MAP, col*self.tileSize, row*self.tileSize) self.screen.draw(TerrainTile('floor.png', self.tileSize), Locations.MAP, col*self.tileSize, row*self.tileSize)
elif tile == '.': elif tile == '.':