Added entities management to class Map

This commit is contained in:
Charles Peyrat 2020-10-16 15:52:47 +02:00 committed by Nicolas Margulies
parent 2e82849395
commit 42c9957ceb
1 changed files with 4 additions and 2 deletions

View File

@ -1,14 +1,16 @@
#!/usr/bin/env python #!/usr/bin/env python
class Map: class Map:
width: int width: int
height: int height: int
tiles: list tiles: list
def __init__(self, width: int, height: int, tiles: list): def __init__(self, width: int, height: int, tiles: list, entities: list):
self.width = width self.width = width
self.height = height self.height = height
self.tiles = tiles self.tiles = tiles
self.entities = entities
@staticmethod @staticmethod
def load(filename: str): def load(filename: str):
@ -22,7 +24,7 @@ class Map:
lines = [line for line in lines if line] lines = [line for line in lines if line]
height = len(lines) height = len(lines)
width = len(lines[0]) width = len(lines[0])
return Map(width, height, lines) return Map(width, height, lines, [])
def draw_string(self) -> str: def draw_string(self) -> str:
return "\n".join("".join(tile.char for tile in line) for line in self.tiles) return "\n".join("".join(tile.char for tile in line) for line in self.tiles)