def load(self, levelfile):
"""Load the level"""
self.data = []
- for line in levelfile.readlines():
- self.data.append(list(line))
+ # Because of how kivy's coordinate system works,
+ # we reverse the lines so things match up between
+ # the file and the display (top of file == top of display)
+ for line in reversed(levelfile.readlines()):
+ self.data.append(list(line.strip('\n')))
def load_tiles(self):
"""Load the list of tiles for the level"""
def at_exit(self, pos):
return pos in self.exit_pos
+
+ def blocked(self, pos):
+ if pos[0] < 0:
+ return True
+ if pos[1] < 0:
+ return True
+ try:
+ tile = self.data[pos[1]][pos[0]]
+ except IndexError:
+ return True
+ if tile == '.':
+ return True
+ return False