Esempio n. 1
0
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()
Esempio n. 2
0
    def test_area(self, area, fcolor, bcolor):
        """
        Draw routines to test game areas.

        Draws some test things in a specific area.

        Arguments:
          area   : area to be tested
          fcolor : foreground color to use for test
          bcolor : background color to use for test
        """
        libtcod.console_set_default_background(area['con'], bcolor)
        libtcod.console_set_default_foreground(area['con'], fcolor)
        libtcod.console_clear(area['con'])
        libtcod.console_print_frame(area['con'], 0, 0, area['w'], area['h'], False, None, area['name'] + ": " + str(area))
        for i in range(area['h']):
            libtcod.console_print_ex(area['con'], 0, i, libtcod.BKGND_NONE, libtcod.LEFT, str(i + 1))
        libtcod.console_blit(area['con'],
                             0, 0, area['w'], area['h'],
                             0, area['x'], area['y'])