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


Python Timer.timer方法代码示例

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


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

示例1: update_display

# 需要导入模块: from utils import Timer [as 别名]
# 或者: from utils.Timer import timer [as 别名]
    def update_display(self, elevators, floors):

        # elevator positions
        for i, e in enumerate(elevators):
            self.print_elevator(i, e.old_pos, c=" " * (len(str(e)) + 2))
            self.print_elevator(i, e.pos, c=str(e), color=e.state)

        # rider counds
        for f in xrange(len(floors)):
            m = len(floors[f])
            self.screen.print_at(" " * 20, self.frame_x + 2, self.frame_y + self.frame_h - 2 - f)

            label = "{:<10}{:<3}({})".format("*" * min(m, 10), "..." if m > 10 else "", m)
            self.screen.print_at(label, self.frame_x + 2, self.frame_y + self.frame_h - 2 - f)

        # stats:
        self.screen.print_at(" " * self.frame_w, self.frame_x, self.frame_y - 1)
        self.screen.print_at(
            "Time: {:<6.1f}, Produced: {:<6}, Delivered: {:<6} ({:<2.0f}%), Died: {:<6} ({:2.0f}%)".format(
                Timer.timer(self.game).time(),
                self.game.produced,
                self.game.delivered,
                100.0 * self.game.delivered / self.game.produced,
                self.game.died,
                100.0 * self.game.died / self.game.produced,
            ),
            self.frame_x,
            self.frame_y - 1,
        )

        self.screen.refresh()
开发者ID:yuribak,项目名称:pylevator,代码行数:33,代码来源:elev.py

示例2: __init__

# 需要导入模块: from utils import Timer [as 别名]
# 或者: from utils.Timer import timer [as 别名]
    def __init__(self, screen, floor_count, elev_count, life_expectancy, rps):

        self.life_expectancy = life_expectancy
        self.rps = rps

        self.display = Display(screen, floor_count, elev_count, self)

        self.floors = [list() for _ in xrange(floor_count)]
        self.elevators = [Elevator(random.randint(0, floor_count - 1)) for _ in xrange(elev_count)]

        self.timer = Timer.timer(self)

        self.delivered = 0
        self.produced = 0
        self.died = 0
开发者ID:yuribak,项目名称:pylevator,代码行数:17,代码来源:elev.py

示例3: main

# 需要导入模块: from utils import Timer [as 别名]
# 或者: from utils.Timer import timer [as 别名]
    def main(s):

        g = Game(s, floor_count, elev_count, life_expectancy, rps)

        t = Timer.timer(g)

        while t.time() < game_time:

            current_frame = t.time()

            g.update()

            d = game_second - (t.time() - current_frame)
            if d > 0:
                if fast_mode:
                    t.skip(d)
                else:
                    sleep(d)
开发者ID:yuribak,项目名称:pylevator,代码行数:20,代码来源:elev.py


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