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 update(self): """Update the world's console buffer with current map data.""" for x in range (0, self.width): for y in range (0, self.height): cell_value = tcod.heightmap_get_value(self.elevation, x, y) cell_value = int(cell_value * 127) + 127 tcod.map_set_properties(self.map, x, y, (cell_value < 150), (cell_value < 150 and cell_value > 75)) if not tcod.map_is_transparent(self.map, x, y): cell_color = tcod.white elif not tcod.map_is_walkable(self.map, x, y): cell_color = tcod.blue else: cell_color = tcod.black tcod.console_set_char_background(self.console, x, y, cell_color)
def callback(ox, oy, dx, dy, user_data): if libtcodpy.map_is_walkable(map_, dx, dy): return 1 return 0