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


Python Camera.zoom_in方法代码示例

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


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

示例1: CreatureSim

# 需要导入模块: from Camera import Camera [as 别名]
# 或者: from Camera.Camera import zoom_in [as 别名]

#.........这里部分代码省略.........
        new_weights = self.breeder.breed(list(self.get_creatures()))

        new_creature = Creature(
            x=randrange(*self.game_bounds),
            y=randrange(*self.game_bounds),
            nn_weights=new_weights
        )

        new_creature.vision_cone = VisionCone(parent=new_creature, x=265, color=RED)
        self.entities.append(new_creature.vision_cone)

        self._insert_creature(new_creature)

        return new_creature

    def handle_collisions(self):
        # Handle collisions for each creature's vision cone
        for creature in self.get_creatures():

            # Get rough idea of what things could be colliding
            first_pass = self.quadtree.get_objects_at_bounds(creature.get_bounds())

            if first_pass:
                for entity in first_pass:
                    creature.vision_cone.check_collision(entity)
                    creature.check_collision(entity)

        for entity in self.entities:
            entity.finish_collisions()

    def handle_key_presses(self):
        # Camera Zoom
        if self.key_presses["zoom-in"]:
            self.camera.zoom_in(self.dt)
        if self.key_presses["zoom-out"]:
            self.camera.zoom_out(self.dt)

        # Camera movement
        if not self.follow_creature:
            if self.key_presses["cam-up"]:
                self.camera.move(y_change=-self.dt * self.CAMERA_MOVE_SPEED)
            if self.key_presses["cam-down"]:
                self.camera.move(y_change=self.dt * self.CAMERA_MOVE_SPEED)
            if self.key_presses["cam-left"]:
                self.camera.move(x_change=-self.dt * self.CAMERA_MOVE_SPEED)
            if self.key_presses["cam-right"]:
                self.camera.move(x_change=self.dt * self.CAMERA_MOVE_SPEED)

    def handle_events(self):
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                sys.exit()

            self.register_key_presses(event)

    def register_key_presses(self, event):
        # Key Down
        ########################
        if event.type == KEYDOWN:
            if event.key == K_ESCAPE:
                raise SystemExit()
            try:
                self.key_presses[self.key_map[event.key]] = True
            except KeyError:
                pass
开发者ID:jpinsonault,项目名称:creature_simulation,代码行数:69,代码来源:CreatureSim.py


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