本文整理汇总了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()
示例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
示例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)