def start_menu(): title.init_blood() libtcod.console_credits_reset() finished_libtcod_credits = False selection = 0 while True: title.update() libtcod.console_clear(0) title.draw_blood() title.draw_title() libtcod.console_set_background_color(0, libtcod.dark_grey) libtcod.console_rect(0, 24, 14, 32, 7, False, libtcod.BKGND_MULTIPLY) libtcod.console_set_foreground_color(0, libtcod.red) libtcod.console_print_center(0, 40, 15, libtcod.BKGND_NONE, "Brutal RL: Slaves to Slaughter") libtcod.console_set_foreground_color(0, libtcod.white) libtcod.console_print_left(0, 35, 17, libtcod.BKGND_NONE, "New Game") libtcod.console_print_left(0, 35, 18, libtcod.BKGND_NONE, "Load Game") libtcod.console_print_left(0, 35, 19, libtcod.BKGND_NONE, "Quit") libtcod.console_print_left(0, 33, 17 + selection, libtcod.BKGND_NONE, ">") libtcod.console_print_left(0, 45, 17 + selection, libtcod.BKGND_NONE, "<") if not finished_libtcod_credits: finished_libtcod_credits = libtcod.console_credits_render(65, 43, True) libtcod.console_flush() key = libtcod.console_check_for_keypress(libtcod.KEY_PRESSED) if key.vk == libtcod.KEY_ESCAPE: if selection == 2: raise SetState("quit") else: selection = 2 elif key.vk in DIRECTION_KEYS and DIRECTION_KEYS[key.vk][0] == 0: selection += DIRECTION_KEYS[key.vk][1] selection %= 3 elif key.vk in [libtcod.KEY_ENTER, libtcod.KEY_KPENTER]: raise SetState([new_game, load_game, "quit"][selection]) mouse = libtcod.mouse_get_status() if mouse.lbutton: title.set_full(mouse.cx, mouse.cy) elif mouse.rbutton: title.set_empty(mouse.cx, mouse.cy)
def main_menu(self): ##============================================================================ path = os.path.join(sys.path[0],'content') path = path.replace('core.exe','') img = self.gEngine.image_load(os.path.join(path,'img','menu_background_2.png')) m_menu = Menus(self,SCREEN_HEIGHT/2+22,SCREEN_WIDTH,24,'',['Play a new game', 'Continue last game', 'Options (not working)', 'Quit', 'dev'], self.con) m_menu.is_visible = True #m_menu.can_drag = False while not libtcod.console_is_window_closed(): self.gEngine.image_blit_2x(img, 0, 0, 0) r,g,b = libtcod.red self.gEngine.console_set_default_foreground(0, r,g,b) self.gEngine.console_print(0, SCREEN_WIDTH/2-13, SCREEN_HEIGHT/2-10,'By Grishnak and SentientDeth') libtcod.console_credits_render(2, SCREEN_HEIGHT-2, True) self.gEngine.console_set_default_background(0,0,0,0) choice = m_menu.menu() self.gEngine.console_flush() self.gEngine.console_clear(0) if choice == 0: m_menu.destroy_menu() self.new_game() self.play_game() self.main_menu() if choice == 1: m_menu.destroy_menu() #try: self.load_game() #except: # msgbox('\n No saved game to load.\n', 24) # continue self.play_game() self.main_menu() if choice == 3 or choice == None: #quit self.logger.log.info('Quitting game') break if choice == 4: self.dev_mode.run() self.main_menu()
def test_credits(console): libtcodpy.console_credits_render(0, 0, True) libtcodpy.console_credits_reset()