def setup(self): libtcod.console_set_custom_font('assets/dejavu16x16_gs_tc.png', libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_TCOD) libtcod.console_init_root(self.width, self.height, 'Pyrl', False) self.__con = libtcod.console_new(self.width, self.height) self.__map = Map(self.width, self.height, self.__con) self.__map.setup() self.__generate_entities()
def setUp(self, screenWidth, screenHeight, FPS, fgcol): libtcod.console_set_custom_font(self.fontImageFileName, libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_ASCII_INROW) libtcod.console_init_root(screenWidth, screenHeight, 'List-editor', False) libtcod.sys_set_fps(FPS) libtcod.console_set_background_flag(0, libtcod.BKGND_SET) libtcod.console_set_default_foreground(0, fgcol)
def init_libtcod(): startup_msg = ("analyzing air quality...", "calculating primordial soup..." ,"reading the future...", "carbon dating your hard drive..." ,"finding prime numbers...") print(random.choice(startup_msg)) libtcod.console_set_custom_font('data/fonts/terminal12x12_gs_ro.png', libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_ASCII_INROW) libtcod.console_init_root(C.SCREEN_WIDTH, C.SCREEN_HEIGHT, 'top dog -- v%s' % (C.VERSION), C.FULLSCREEN) libtcod.sys_set_fps(C.LIMIT_FPS) # default font color libtcod.console_set_default_foreground(0, libtcod.white) # set color control codes for inline string formatting # listed by priority: think defcon levels # high alert, priority one libtcod.console_set_color_control(libtcod.COLCTRL_1 ,libtcod.light_red ,libtcod.black) # warning, danger will robinson libtcod.console_set_color_control(libtcod.COLCTRL_2 ,libtcod.light_yellow ,libtcod.black) # informational, you got a quest item libtcod.console_set_color_control(libtcod.COLCTRL_3 ,libtcod.light_green ,libtcod.black) # tile and npc names libtcod.console_set_color_control(C.COL4 ,libtcod.light_azure ,libtcod.black) # all other words libtcod.console_set_color_control(libtcod.COLCTRL_5 ,libtcod.white ,libtcod.black) return libtcod.console_new(C.MAP_WIDTH, C.MAP_HEIGHT)
objects = file['objects'] player = objects[file['player_index']] inventory = file['inventory'] game_msgs = file['game_msgs'] game_state = file['game_state'] file.close() initialize_fov() ######################################### # 3 INSTANTIATE OUR CLASSES FOR GAME # # # ######################################### libtcod.console_set_custom_font( 'terminal10x10_gs_tc.png', libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_TCOD) libtcod.console_init_root(SCREEN_WIDTH, SCREEN_HEIGHT, 'roguelike demo with libtcod', False) con = libtcod.console_new( SCREEN_WIDTH, SCREEN_HEIGHT ) #this has created an offscreen console we'll use instead of printing to the main console libtcod.sys_set_fps(LIMIT_FPS) panel = libtcod.console_new(SCREEN_WIDTH, PANEL_HEIGHT) ######################################### # 4 MAIN LOOP # # # ######################################### main_menu()
'By Jotaf') # show options and wait for the player's choice choice = menu('', ['Play a new game', 'Continue last game', 'Quit'], 24) if choice == 0: # new game new_game() play_game() if choice == 1: # load last game try: load_game() except: msgbox('\n No saved game to load.\n', 24) continue play_game() elif choice == 2: # quit break libtcod.console_set_custom_font('terminal.png', libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_TCOD) libtcod.console_init_root(SCREEN_WIDTH, SCREEN_HEIGHT, 'python/libtcod tutorial', False) libtcod.sys_set_fps(LIMIT_FPS) con = libtcod.console_new(MAP_WIDTH, MAP_HEIGHT) panel = libtcod.console_new(SCREEN_WIDTH, PANEL_HEIGHT) main_menu()
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) 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) for x in range(SCREEN_WIDTH): for y in range(SCREEN_HEIGHT): col = libtcod.Color(60 * map[x][y], 60 * map[x][y], 60 * map[x][y]) libtcod.console_set_char_background(0, x, y, col) libtcod.console_set_default_foreground(0, libtcod.dark_grey) libtcod.console_put_char(0, x, y, ".") libtcod.console_flush() libtcod.console_wait_for_keypress(True)
# TEMPORARY: press r to review a business elif key.c == ord('r'): biz = random.choice(district.businesses) biz.visit(player) elif key.vk >= libtcod.KEY_0 and key.vk <= libtcod.KEY_KP9: # If amulet is displayed, redirect numeric input to amulet amulet.keyboard_input(key.vk) ############################################# # Initialization & Main Loop ############################################# libtcod.console_set_custom_font( 'res/dejavu16x16_gs_tc.png', libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_TCOD) libtcod.console_init_root(SCREEN_WIDTH, SCREEN_HEIGHT, 'Amulet of Yelpdor', False) libtcod.sys_set_fps(LIMIT_FPS) console = libtcod.console_new(SCREEN_WIDTH, SCREEN_HEIGHT) district = District() dungeon_map = generate_city_map(MAP_WIDTH, MAP_HEIGHT, district) dungeon_map.init_fov_map() screen = Screen(width=SCREEN_WIDTH, height=SCREEN_HEIGHT) camera = Camera(CAMERA_WIDTH, CAMERA_HEIGHT, dungeon_map) renderer = Renderer(console, screen, camera) messenger = Messenger(width=MESSENGER_WIDTH, height=MESSENGER_HEIGHT, screen=screen)