import lib.libtcodpy as libtcod from rogue_one.generation.bsp_generation import BSPGenerator SCREEN_WIDTH = 80 SCREEN_HEIGHT = 50 bsp = BSPGenerator(libtcod.random_new()) map = bsp.generate_map(SCREEN_WIDTH, SCREEN_HEIGHT, 0) tree = bsp.run(map) def trace_sections(tree): rect = tree.data def listener(x, y): map[x][y] = 3 return True libtcod.line(rect.x1, rect.y1, rect.x2, rect.y1, listener) libtcod.line(rect.x1, rect.y1, rect.x1, rect.y2, listener) libtcod.line(rect.x2, rect.y1, rect.x2, rect.y2, listener) libtcod.line(rect.x1, rect.y2, rect.x2, rect.y2, listener) if tree.left is not None: trace_sections(tree.left) if tree.right is not None: trace_sections(tree.right) trace_sections(tree)
MAP_HEIGHT = 46 FOV_ALGO = 0 FOV_LIGHT_WALLS = True TORCH_RADIUS = 10 random = libtcod.random_new() libtcod.console_set_custom_font( "terminal12x12_gs_ro.png", libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_ASCII_INROW ) libtcod.console_init_root(SCREEN_WIDTH, SCREEN_HEIGHT, "rogue-one", False, libtcod.RENDERER_GLSL) con = libtcod.console_new(SCREEN_WIDTH, SCREEN_HEIGHT) map_gen = BSPGenerator(random) map = map_gen.generate_map(MAP_WIDTH, MAP_HEIGHT, 1) map_gen.run(map) world = Level(MAP_WIDTH, MAP_HEIGHT, con) tiler = TileGenerator() tiler.run(world, map) player = Entity(27, 22, "@", libtcod.white, con, world) npc = Entity(56, 27, "J", libtcod.yellow, con, world) objects = [npc, player] fov_map = libtcod.map_new(MAP_WIDTH, MAP_HEIGHT) for y in range(MAP_HEIGHT): for x in range(MAP_WIDTH): libtcod.map_set_properties(fov_map, x, y, not world[x][y].block_sight, not world[x][y].blocked)