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


Python Camera.setTarget方法代码示例

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


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

示例1: GameState

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

#.........这里部分代码省略.........
      self.drawScene()

      # Copy the contents of the frame buffer into our blur texture
      self.blurTexture.bind()
      glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0,
                       self.blurTexture.getTexWidth(),
                       self.blurTexture.getTexHeight(),
                       0)
      self.blurTexture.unbind()

      # Clear the fram buffer again
      glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
      glPopAttrib()

      # Blend in the motion blur with the background color
      self.drawMotionBlur(self.player.drunkAmount)

      # Draw the scene on top of the motion blur
      self.drawScene()


   def update(self, dt):
      '''
      Updates the game simulation based on the amount of time that has passed
      since the previous frame.
      '''
      # Update the input system
      self.updateInput(dt)

      # Update the avatar
      self.player.update(dt)

      # Update the camera
      self.camera.setTarget(self.player.pos, self.player.rot)
      self.camera.update(dt)

      for i in range(len(self.npcs)):
         self.npcs[i].update(dt)

      # Calculate the FPS
      self.numFrames += 1
      self.frameTime += dt
      if self.frameTime > 0.5:
         self.fps = float(self.numFrames) / self.frameTime
         self.frameTime = 0.0
         self.numFrames = 0
         print 'FPS: %f' % (self.fps)


   def updateInput(self, dt):
      '''
      Updates the state of the input system and processes all currently active
      actions.
      '''
      # Update the input manager
      self.inputMgr.update(dt)

      # Movement
      speed = 5
      accel    = gmtl.Vec3f(0, 0, speed)
      reverse  = gmtl.Vec3f(0, 0, -speed * 0.7)
      sleft    = gmtl.Vec3f( speed * 0.9, 0, 0)
      sright   = gmtl.Vec3f(-speed * 0.9, 0, 0)

#      vel_change = gmtl.Vec3f(0,0,0)
      self.vel_change = self.vel_change + accel   * self.actionForward.getEdgeState()
开发者ID:chadaustin,项目名称:isugamedev,代码行数:70,代码来源:GameState.py


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