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


Python Clock.draw方法代码示例

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


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

示例1: __init__

# 需要导入模块: from clock import Clock [as 别名]
# 或者: from clock.Clock import draw [as 别名]

#.........这里部分代码省略.........

    def stage(self):
        self.state = 1
        self.lights[1].on()
        self.staged.set()

    def _start(self):
        threading.Thread(None, self.timer, name=self.lane + " timer()").start()

    def launch(self):
        self.start.wait()
        if self.computer:
            if self.cmin == self.cmax:
                computer_delay = self.cmin
            else:
                computer_delay = random.randrange(
                    (self.total_delay * 1000) + (self.cmin * 1000),
                    (self.total_delay * 1000 ) + (self.cmax * 1000), 1) / 1000.0
            self.launched_time = self.start_time + computer_delay
            self.launched.set()
        else:
            self.launched.wait()
            self.launched_time += self.rollout
        self.reaction = self.launched_time + self.perfect
        self.reaction -= (self.total_delay + self.start_time)
        if not self.total_delay + self.start_time - time.time() < 0:
            time.sleep(self.start_time + self.total_delay + self.reaction -self.perfect - time.time())
        if self.reaction < self.perfect:
            self.red()
        self.pre_staged.clear()
        self.lights[0].off()
        self.staged.clear()
        self.lights[1].off()
        self.clock.draw(self.reaction)
        self.log.append(self.reaction)

    def timer(self):
        launch = threading.Thread(None,
            self.launch, name=self.lane + " launch()").start()
        threading.Thread(None,
            self.yellow1, name=self.lane + " yellow1()").start()
        threading.Thread(None,
            self.yellow2, name=self.lane + " yellow2()").start()
        threading.Thread(None,
            self.yellow3, name=self.lane + " yellow3()").start()
        threading.Thread(None,
            self.green, name=self.lane + " green()").start()
        self.state = 2

    def light(self, number=0):
        if self.foul.is_set():
            return False
        if self.tree_type == "pro":
            if number == 3:
                number = 1
            else:
                number = 0
        while time.time() < self.start_time + (self.delay * number):
            if self.foul.is_set():
                return False
        return True

    def yellow1(self):
        self.y1.wait()
        if not self.foul.is_set():
            self.lights[2].on()
开发者ID:daveisadork,项目名称:Racer,代码行数:70,代码来源:lane.py


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