import model import core.model import core.utils class PacmanLevel: def __init__(self, disp, path): self.disp = disp self.path = path def load(self, env): pacman = None ghosts = [] f = open(self.path, "r") cur_h = cur_w = 0 for l in f.readlines(): for c in l: a = None if c == "#": a = model.Wall(self.disp) elif c == "G": a = model.Ghost(self.disp) ghosts.append(a) elif c == "P": a = model.Pacman(self.disp, env) pacman = a if a: a.place(env.sectors[cur_h][cur_w]) cur_w += 1 cur_h += 1 cur_w = 0 f.close() return pacman, ghosts