def show_player_stats(): player_stats=libtcod.console_new(20,20) libtcod.console_set_default_background(player_stats,libtcod.darkest_grey) libtcod.console_set_default_foreground(player_stats, libtcod.white) # libtcod.console_clear(player_stats) libtcod.console_print_frame(player_stats, 0, 0, libtcod.console_get_width(player_stats), libtcod.console_get_height(player_stats), clear=True) height=0 libtcod.console_print_rect(player_stats, 1, 1, libtcod.console_get_width(player_stats)-2, libtcod.console_get_height(player_stats)-2, "Name: %s \nHealth: %s/%s\nView distance: %s\nStrength: %s\nTo hit: %s\nExp: %s"# %(P.player.name,P.player.health,P.player.max_health, P.player.view_distance, P.player.strength,P.player.to_hit,P.player.exp)) libtcod.console_print_ex(player_stats, libtcod.console_get_width(player_stats)//2, 0, libtcod.BKGND_DEFAULT, libtcod.CENTER, "Player Stats") libtcod.console_print_ex(player_stats, libtcod.console_get_width(player_stats)//2, libtcod.console_get_height(player_stats)-1, libtcod.BKGND_DEFAULT, libtcod.CENTER, "[spacebar]") libtcod.console_blit(player_stats,0,0, libtcod.console_get_width(player_stats), libtcod.console_get_height(player_stats), 0,5,5, 1.0,0.1) key = libtcod.console_check_for_keypress(libtcod.KEY_PRESSED) while not (libtcod.KEY_SPACE==key.vk): key = libtcod.console_check_for_keypress(libtcod.KEY_PRESSED) libtcod.console_blit(player_stats,0,0, libtcod.console_get_width(player_stats), libtcod.console_get_height(player_stats), 0,5,5, 1.0,0.1) libtcod.console_flush() R.render()
def draw_items(): height = 0 libtcod.console_set_default_background(cons.items_console, libtcod.red) libtcod.console_set_default_foreground(cons.items_console, libtcod.white) libtcod.console_clear(cons.items_console) for item in tile_items: height+=libtcod.console_print_rect_ex(cons.items_console, 0, height, libtcod.console_get_width(cons.items_console), libtcod.console_get_height(cons.items_console), libtcod.BKGND_NONE, libtcod.LEFT, item.name) libtcod.console_blit(cons.items_console,0,0, libtcod.console_get_width(cons.items_console), height, 0,1,1, 1.0,0.5) libtcod.console_flush()
def get_dimensions(self): return libtcod.console_get_height(self.win), libtcod.console_get_width(self.win)