def draw_splash_screen(self): # title_height = self.console.print_box( # 0, 0, self.SCREEN_WIDTH, self.SCREEN_HEIGHT, # self.game.SPLASH_SCREEN.get_centered_title_art(self.SCREEN_WIDTH), # fg=tuple(self.game.SPLASH_SCREEN.title_art_color) # ) self.console.clear() self.draw_title() top_offset = self.LOGO_HEIGHT + 4 # bottom_offset = self.draw_credits() + 1 # remaining = self.SCREEN_HEIGHT - top_offset - bottom_offset - 1 # Have to do it this way because libtcod has a weird interaction with # CP437 characters key_hint1 = f"Choose an option with {chr(18)}" key_hint2 = ", confirm with the Spacebar or Enter" xstart = (self.SCREEN_WIDTH - (len(key_hint1) + len(key_hint2))) // 2 self.console.print(xstart, top_offset, key_hint1, fg=(112, 120, 128)) self.console.print(xstart + len(key_hint1), top_offset, key_hint2, fg=(112, 120, 128)) self.draw_main_menu_options(top_offset + 1) self.draw_credits() if not self._end_credits: self._end_credits = tcod.console_credits_render( self.SCREEN_WIDTH - 15, self.SCREEN_HEIGHT - 3, True) tcod.console_blit(self.console, 0, 0, self.SCREEN_WIDTH, self.SCREEN_HEIGHT, self.console, 0, 0) tcod.console_flush()
def main(): # I don't like a bunch of var at the start of every file and/or class - so every long living var # well be defined within the config folder - grouped by dev who will return an list with the necessessary values constants = get_window_constants() # FONT loading for the tile-set tcod.console_set_custom_font(constants['font_file'], constants['font_flags'], constants['char_horiz'], constants['char_vertic']) # main window console = tcod.console_init_root( constants['screen_width'], constants['screen_height'], constants['window_title'], constants['run_in_full_screen'], constants['renderer'], constants['render_order'], constants['render_vsync']) # Key and mouse-events handling state = State() credits_end = False # the main game loop while not tcod.event == tcod.event.Quit: # clear everything console.clear() # Honour to whom honour is due if not credits_end: credits_end = tcod.console_credits_render( constants['credit_x_pos'], constants['credit_y_pos'], constants['credit_alpha_enabled']) # Key, mouse and other events for event in tcod.event.get(): state.dispatch(event) # bring new painted content to the front tcod.console_flush()
def test_credits(console): libtcodpy.console_credits_render(0, 0, True) libtcodpy.console_credits_reset()