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


Python Clock.tick方法代码示例

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


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

示例1: tick

# 需要导入模块: from clock import Clock [as 别名]
# 或者: from clock.Clock import tick [as 别名]
 def tick(self):
     """ advance the clock by one second """
     previous_hour = self._hours
     # super().tick()
     Clock.tick(self)
     if (self._hours < previous_hour):
         self.advance()
开发者ID:Sabinu,项目名称:Harta,代码行数:9,代码来源:calendar_clock.py

示例2: handle_ticktock_to_next_update

# 需要导入模块: from clock import Clock [as 别名]
# 或者: from clock.Clock import tick [as 别名]
def handle_ticktock_to_next_update(force):
    t = res_manager.get_next_update_time()
    if t < 0:
        return False
    else:
        if force:
            while Clock.get() < t:
                Clock.tick()
            return handle_ticktock(1)
        else:
            return handle_ticktock(t - Clock.get())
开发者ID:Jason918,项目名称:self-web,代码行数:13,代码来源:res_pool.py

示例3: tick_or_tock

# 需要导入模块: from clock import Clock [as 别名]
# 或者: from clock.Clock import tick [as 别名]
def tick_or_tock():
    global __on_tick
    if not __on_tick:
        res_manager.changed_res_set.clear()
        res_manager.run_timer()
        __on_tick = True
        if len(__clock_tick_event_receiver) > 0:
            for receiver in __clock_tick_event_receiver:
                notify_id = sky_client.write((RECEIVER, "Event", receiver),fill_content_id=True)
                #sky_client.take(template=(TARGET, notify_id, '?'))
    else:
        res_manager.run_listener()
        Clock.tick()
        report()
        __on_tick = False
开发者ID:Jason918,项目名称:self-web,代码行数:17,代码来源:res_pool.py

示例4: run

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

#.........这里部分代码省略.........
                                dir = params["dir"]
                                g_coll = groupmanager.get(params["collision_group"])
                                object = object_cls(pos, dir, g_coll)

                            elif spawn["object_base_cls_name"] == "Bonus":
                                pass
                            else:
                                raise ValueError, "Invalid value '%s' for attrubite \
                    'object_base_cls_name' in stage %s" % (
                                    spawn["object_base_cls_name"],
                                    stage_name,
                                )
                        else:
                            object = object_cls(pos)

                        if spawn["bonus_cls_name"]:
                            if isinstance(object, BonusHolder):
                                object.set_bonus(spawn["bonus_cls_name"], spawn["bonus_params"])
                            else:
                                raise ValueError, "Instances of %s can not hold bonuses." % object.__class__.__name__

                        if spawn["mover_cls_name"]:
                            mover_cls = eval("mover.%s" % spawn["mover_cls_name"])
                            m = mover_cls(pos, object.max_speed, spawn["mover_params"])
                            object.set_mover(m)

                        for g in spawn["groups"]:
                            if g == "enemies":
                                g_enemies.add(object)
                            elif g == "explosions":
                                g_explosions.add(object)
                            elif g == "enemy_projectiles":
                                g_enemy_projectiles.add(object)
                            elif g == "player_projectiles":
                                g_player_projectiles.add(object)

            # time management
            clock.tick(40)
            # clock.tick( float(sys.argv[1]) )
            stage_clock += clock.get_time()

            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    sys.exit()
                elif event.type == pygame.KEYDOWN:
                    if event.key == pygame.K_q:
                        sys.exit()
                    elif event.key == pygame.K_s:
                        if ship():
                            ship().next_weapon()
                    elif event.key == pygame.K_a:
                        if ship():
                            ship().previous_weapon()
                    elif event.key == pygame.K_x:
                        if ship():
                            ship().activate_shield(True)
                elif event.type == pygame.KEYUP:
                    if event.key == pygame.K_UP:
                        if ship():
                            ship().fly_up(False)
                    elif event.key == pygame.K_x:
                        if ship():
                            ship().activate_shield(False)

            pressed_keys = pygame.key.get_pressed()
            if pressed_keys[pygame.K_UP]:
                if ship():
                    ship().fly_up(True)
            if pressed_keys[pygame.K_DOWN]:
                if ship():
                    ship().fly_down(viewport_size[1])
            if pressed_keys[pygame.K_LEFT]:
                if ship():
                    ship().fly_left()
            if pressed_keys[pygame.K_RIGHT]:
                if ship():
                    ship().fly_right(viewport_size[0])
            if pressed_keys[pygame.K_z]:
                if ship():
                    ship().shoot()

            back.clear(screen, clear_bg)
            back.update()
            back.draw(screen)

            # temp
            # if ship():
            #  ship().damage(1)
            #

            g_draw.clear(screen, clear_bg)
            hud.clear(screen, clear_bg)

            g_draw.update()
            hud.update()

            g_draw.draw(screen)
            hud.draw(screen)

            pygame.display.flip()
开发者ID:erszcz,项目名称:agrajag,代码行数:104,代码来源:run.py

示例5: Clock

# 需要导入模块: from clock import Clock [as 别名]
# 或者: from clock.Clock import tick [as 别名]
from clock import Clock
x = Clock()
print(x)
for i in xrange(10000):
    x.tick()
print(x)
开发者ID:ganeshchand,项目名称:learning-python,代码行数:8,代码来源:TestClock.py


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