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


Python Clock.get_time方法代码示例

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


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

示例1: run

# 需要导入模块: from clock import Clock [as 别名]
# 或者: from clock.Clock import get_time [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


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