当前位置: 首页>>代码示例>>Python>>正文


Python Console.blit方法代码示例

本文整理汇总了Python中console.Console.blit方法的典型用法代码示例。如果您正苦于以下问题:Python Console.blit方法的具体用法?Python Console.blit怎么用?Python Console.blit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在console.Console的用法示例。


在下文中一共展示了Console.blit方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from console import Console [as 别名]
# 或者: from console.Console import blit [as 别名]

#.........这里部分代码省略.........
        """y += 1
        for word in sorted(self.player.words):
            color = word.color
            x = 2
            self.panel_con.set_default_foreground(word.color)
            self.panel_con.print_string(x,y,word.name)
            y += 1"""

        y += 1
        self.panel_con.set_default_foreground(C_MENU)
        for stat in (('Size',self.player.creature.size),
                     ('Agility',self.player.creature.agility),
                     ('Perception',self.player.creature.perception),
                     ('Strength',self.player.creature.strength),
                     ('Speed',self.player.creature.speed)):
            x = 2
            self.panel_con.print_string(x,y,'%s: %i'%stat)
            y += 1

    def render_all(self):
        player_x = self.player.x
        player_y = self.player.y
        if FOCUS == FOCUS_PLAYER:
            focus_x = player_x
            focus_y = player_y
        elif FOCUS == FOCUS_FIXED:
            focus_x = LEVEL_W//2
            focus_y = LEVEL_H//2

        self.dungeon.render(focus_x, focus_y, self.map_con,
                            overlay=self.overlay)
        for entity in self.entities:
            if entity != self.player:
                entity.render(focus_x, focus_y, self.map_con)
        for entity in self.living_entities: #draw living creatures on top
            if entity != self.player:
                entity.render(focus_x, focus_y, self.map_con)
        self.player.render(focus_x, focus_y, self.map_con)
        self.map_con.draw_border(True,C_BORDER,C_BORDER_BKGND)

        if self.menu:
            self.menu.render(self.map_con)
        self.map_con.blit()

        self.message_log.render(self.log_con)
        self.log_con.blit()

        self.render_panel()
        self.panel_con.blit()

    def play(self):
        self.dungeon.update()
        self.render_all()
        libtcod.console_flush()
        t = time.time()
        while not libtcod.console_is_window_closed():
            #libtcod.sys_check_for_event(libtcod.EVENT_KEY_PRESS|libtcod.EVENT_MOUSE, self.key, self.mouse)

            #self.state = self.player.input_handler(key,mouse,
            #                                       self.input_state,
            #                                       self.menu)
            #if self.menu and self.state != STATE_MENU:
            #    self.menu = None

            #if self.state == STATE_PLAYING:
            #    self.player.creature.energy -= ENERGY_THRESHOLD
            #while self.state == STATE_PLAYING:
            player_room = self.cur_level.get_room_at(*self.player.pos)
            if player_room:
                active_rooms = [player_room]
                self.active_region = []
                for room in player_room.connections:
                    if room not in active_rooms:
                        active_rooms.append(room)
                        for r in room.connections:
                            if r not in active_rooms:
                                active_rooms.append(room)
                for room in active_rooms:
                    self.active_region += room.tile_positions
            else:
                self.active_region = [self.player.pos]
            self.active_entities=[]
            for entity in self.entities:
                if entity.pos in self.active_region:
                    self.active_entities.append(entity)

            self.clear_all()
            for entity in self.active_entities:
                entity.update()
                    
                #self.player.creature.energy += self.player.creature.speed
                #print self.player.creature.energy
                #if self.player.creature.energy >= ENERGY_THRESHOLD:
                    #self.state = STATE_PAUSED

            self.dungeon.update()
            self.render_all()
            libtcod.console_flush()
            self.fps = 1.0/(time.time()-t)
            t=time.time()
开发者ID:mscottmoore16,项目名称:golemrl,代码行数:104,代码来源:game.py


注:本文中的console.Console.blit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。