#!/usr/bin/env python class Map: width: int height: int tiles: list def __init__(self, width: int, height: int, tiles: list): self.width = width self.height = height self.tiles = tiles @staticmethod def load(filename: str): with open(filename, "r") as f: file = f.read() return Map.load_from_string(file) @staticmethod def load_from_string(content: str): lines = content.split("\n") lines = [line for line in lines if line] height = len(lines) width = len(lines[0]) return Map(width, height, lines) def draw_string(self) -> str: return "\n".join("".join(tile.char for tile in line) for line in self.tiles) class Entity: y: int x: int img: str def __init__(self, y: int, x: int, img: str): self.y = y self.x = x self.img = img def move(self, x: int, y: int) -> None: self.x = x self.y = y