本文整理汇总了Python中Camera.Camera.track方法的典型用法代码示例。如果您正苦于以下问题:Python Camera.track方法的具体用法?Python Camera.track怎么用?Python Camera.track使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Camera.Camera
的用法示例。
在下文中一共展示了Camera.track方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from Camera import Camera [as 别名]
# 或者: from Camera.Camera import track [as 别名]
#.........这里部分代码省略.........
shots = []
for entity in self.groups['updating']:
# update all entities, this should not change the state
shot = entity.update(self.timestep)
if shot:
# 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() ])