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