def test_astar_callback(map_, path_callback): astar = libtcodpy.path_new_using_function( libtcodpy.map_get_width(map_), libtcodpy.map_get_height(map_), path_callback, ) libtcodpy.path_compute(astar, *POINTS_AB) libtcodpy.path_delete(astar)
def test_dijkstra_callback(map_, path_callback): path = libtcodpy.dijkstra_new_using_function( libtcodpy.map_get_width(map_), libtcodpy.map_get_height(map_), path_callback, ) libtcodpy.dijkstra_compute(path, *POINT_A) libtcodpy.dijkstra_delete(path)
def test_map(): map = libtcodpy.map_new(16, 16) assert libtcodpy.map_get_width(map) == 16 assert libtcodpy.map_get_height(map) == 16 libtcodpy.map_copy(map, map) libtcodpy.map_clear(map) libtcodpy.map_set_properties(map, 0, 0, True, True) assert libtcodpy.map_is_transparent(map, 0, 0) assert libtcodpy.map_is_walkable(map, 0, 0) libtcodpy.map_is_in_fov(map, 0, 0) libtcodpy.map_delete(map)
def print_walkable_map(self): """ Prints a map of where this entity is allowed to walk. """ for y in range(libtcod.map_get_height(self.dungeon_map)): line = "" for x in range(libtcod.map_get_width(self.dungeon_map)): if libtcod.map_is_walkable(self.dungeon_map, x, y): line += " " else: line += "#" print(line)
def print_visible_map(self): """ Prints a map of what this entity sees right now. """ for y in range(libtcod.map_get_height(self.dungeon_map)): line = "" for x in range(libtcod.map_get_width(self.dungeon_map)): if libtcod.map_is_in_fov(self.dungeon_map, x, y): line += " " else: line += "#" print(line)
def print_is_transparent_map(self): """ Prints a map of what this entity can see through. """ for y in range(libtcod.map_get_height(self.dungeon_map)): line = "" for x in range(libtcod.map_get_width(self.dungeon_map)): if libtcod.map_is_transparent(self.dungeon_map, x, y): line += " " else: line += "#" print(line)