示例#1
0
    def render_ui(self, player):
        #prepare to render the GUI panel
        libtcod.console_set_background_color(self.panel, libtcod.black)
        libtcod.console_clear(self.panel)
        #show the player's HP
        self.render_bar(1, 1, 13, 10, player.hp, player.base_hp,
                        HP_BAR, libtcod.darker_red, self.create_color(COLOR_STATUS_TEXT), HP_BAR_PERCENT)
        self.render_bar(1, 2, 13, 10, player.mp, player.base_mp,
                        MP_BAR, libtcod.darker_red, self.create_color(COLOR_STATUS_TEXT), MP_BAR_PERCENT)
        self.render_stats_two_column(1, 3, "AC", player.base_ac, 13, "EVADE", "player.evade", COLOR_STATUS_TEXT,
                                     COLOR_STATUS_VALUES)
        self.render_stats_two_column(1, 4, "Str", "str", 13, "To", "tough", COLOR_STATUS_TEXT, COLOR_STATUS_VALUES)
        self.render_stats_two_column(1, 5, "Dex", "des", 13, "Int", "int", COLOR_STATUS_TEXT, COLOR_STATUS_VALUES)
        self.render_stats_two_column(1, 6, "XL", player.xl, 13, "EXP", "%d/%d" % (player.xp, util.xp_for_lvl(player.xl))
                                     , COLOR_STATUS_TEXT, COLOR_STATUS_VALUES)
        #blit the contents of "panel" to the root console
        libtcod.console_blit(self.panel, 0, 0, RIGHT_PANEL_WIDTH, RIGHT_PANEL_HEIGHT, 0, RIGHT_PANEL_X, 0)

        #print the game messages, one line at a time
        y = 0
        for (line, level) in gl.__msgs__:
            if level < 1 and not gl.__wizard_mode__:
                continue
            libtcod.console_set_foreground_color(self.panel_msg, self.message_colours.get(level, libtcod.white))
            libtcod.console_print_left(self.panel_msg, 0, y, libtcod.BKGND_NONE, line.ljust(SCREEN_WIDTH, ' '))
            y += 1
        libtcod.console_blit(self.panel_msg, 0, 0, SCREEN_WIDTH, MSG_PANEL_HEIGHT, 0, 0, MSG_PANEL_Y )
        libtcod.console_flush()
示例#2
0
 def render_ui(self, player):
     cc = self.create_color
     #prepare to render the GUI panel
     libtcod.console_set_default_background(self.panel, libtcod.black)
     libtcod.console_clear(self.panel)
     #show the player's HP
     self.render_bar(1, 1, 13, 10, player.hp, player.base_hp,
                     HP_BAR, libtcod.darker_red, cc(COLOR_STATUS_TEXT), HP_BAR_PERCENT)
     self.render_bar(1, 2, 13, 10, player.mp, player.base_mp,
                     MP_BAR, libtcod.darker_red, cc(COLOR_STATUS_TEXT), MP_BAR_PERCENT)
     self.render_stats_two_column(1, 3, "AC", player.base_ac, 13, "EVADE", "player.evade", COLOR_STATUS_TEXT,
                                  COLOR_STATUS_VALUES)
     self.render_stats_two_column(1, 4, "Str", "str", 13, "To", "tough", COLOR_STATUS_TEXT, COLOR_STATUS_VALUES)
     self.render_stats_two_column(1, 5, "Dex", "des", 13, "Int", "int", COLOR_STATUS_TEXT, COLOR_STATUS_VALUES)
     self.render_stats_two_column(1, 6, "XL", player.xl, 13, "EXP", "%d/%d" % (player.xp, util.xp_for_lvl(player.xl))
                                  , COLOR_STATUS_TEXT, COLOR_STATUS_VALUES)
     self.render_stats_two_column(1, 7, "Turns", gl.__turn_count__, 13, "", "", COLOR_STATUS_TEXT, COLOR_STATUS_VALUES)
     #blit the contents of "panel" to the root console
     libtcod.console_blit(self.panel, 0, 0, RIGHT_PANEL_WIDTH, RIGHT_PANEL_HEIGHT, 0, RIGHT_PANEL_X, 0)
示例#3
0
 def earn_exp(self, src):
     self.xp += src.xp
     if self.xp > util.xp_for_lvl(self.xl):
         self.lvl_up()
示例#4
0
 def earn_exp(self, src):
     self.xp += src.xp
     if self.xp > util.xp_for_lvl(self.xl):
         self.lvl_up()