def pathfind(self, start, destination): """Pathfinding for the world. Destinations are 'snapped' to tiles. """ def NodeFactory(pos): x, y = pos[:2] l = 0 return Node((x, y)) try: if self.tmxdata.getTileGID(x, y, l) == 0: node = Node((x, y)) else: return None except: return None else: return node start = self.worldToTile(start) destination = self.worldToTile(destination) path = astar.search(start, destination, NodeFactory) return path
def pathfind(self, start, finish): """ return a path from start to finish """ return search(start, finish, self.factory)