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


Python Camera.shiftView方法代码示例

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


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

示例1: __init__

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

#.........这里部分代码省略.........
          # self.entityAddQueue += response.get("add Entities", [])
          # self.entityDelQueue += response.get("del Entities", [])
          shots.append((entity, shot))

      # this will apply the actions generated by update
      for entity, shot in shots:
        self.entityAddQueue.append(physics.shoot(entity, shot))
      self._processRemoving()
      self._processAdding()

      self.space.step(self.timestep) # this will do the physics and apply all actions
      self._processRemoving()
      self._processAdding()

      if enablePhysicsTesting:
        # DEBUG: test for physics consistency. Disabled as bouncing off Walls changes momentum
        # momentum =                        sum([ e.body.mass * e.body.velocity for e in self.blobs.itervalues() ])
        assertClose(self.physCheck_mass,  sum([ e.body.mass                   for e in self.blobs.itervalues() ]))
        assertClose(self.physCheck_area,  sum([ math.pi * e.radius**2         for e in self.blobs.itervalues() ]))
        # assertClose(self.physCheck_mometum.x, momentum.x)
        # assertClose(self.physCheck_mometum.y, momentum.y)


    ## DRAW ##
    gl.glClearColor(0,0,0, 0)
    gl.glClear(gl.GL_COLOR_BUFFER_BIT)
    gl.glLoadIdentity()

    self.camera.track() # does camera work (such as what it focuses on)
    for name in self.drawLayerNames:
      for func in self.drawCalls[name]:
        func()
      shift = Vec2d() if name.startswith('UI') else None
      with self.camera.shiftView(shift):
        self.drawLayers[name].draw()


    self.fps_display.draw()
    #self.window.flip()

  def loadLevel(self, levelName):
    # Initialize physics
    self.blobs = {}         # a dict from blob.id to blob
    self.highestBlobId = 0
    self.space = physics.createSpace(self)
    self.spaceView = SpaceView(self.space)

    # self.levelCreator = resources.loadEntities
    self.levelCreator = levelCreator.createLevel

    # load the entities
    for e in self.levelCreator(levelName):
      self.addEntity(e)

    self._processAdding()
    self._processRemoving()

    self.physCheck_mass     = sum([ e.body.mass                   for e in self.blobs.itervalues() ])
    self.physCheck_area     = sum([ math.pi * e.radius**2         for e in self.blobs.itervalues() ])
    self.physCheck_mometum  = sum([ e.body.mass * e.body.velocity for e in self.blobs.itervalues() ])

  def addEntity(   self, e):  self.entityAddQueue.append(e)
  def removeEntity(self, e):  self.entityDelQueue.append(e)


  def _processAdding(self):
开发者ID:DomNomNom,项目名称:osbot,代码行数:70,代码来源:Engine.py


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