本文整理汇总了Python中Physics.updatePhysics方法的典型用法代码示例。如果您正苦于以下问题:Python Physics.updatePhysics方法的具体用法?Python Physics.updatePhysics怎么用?Python Physics.updatePhysics使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Physics
的用法示例。
在下文中一共展示了Physics.updatePhysics方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SpaceDominationMain
# 需要导入模块: import Physics [as 别名]
# 或者: from Physics import updatePhysics [as 别名]
#.........这里部分代码省略.........
if tg.parent == spawn:
tg.parent = ship
def updateTriggers(self):
# update triggers
primObjComplete = True
for tg in self.triggerList:
tg.update(self)
if not tg.completed and tg.type.count("objective-primary") > 0:
primObjComplete = False
return primObjComplete
def gameLoop(self):
dt = self.clock.tick(consts.FRAMERATE)
self.timeTotal += dt
# display the FPS
if dt > 0:
self.fpstext = self.defaultfont.render("FPS: " + str(float(int(10000.0 / dt)) / 10), 1, (0, 250, 0))
if self.gameState == self.GAMESTATE_RUNNING:
# do physics
if self.lastTick == 0: self.lastTick = pygame.time.get_ticks()
#if pygame.time.get_ticks() - self.lastTick > 33:
# self.physics.updatePhysics(self)
# self.lastTick = pygame.time.get_ticks()
timestep = float(dt) * consts.GAMESPEED * 0.001
self.elapsedTime += dt
self.physics.updatePhysics(self, timestep)
vel = Vec2(0,0)
vel.setXY(*self.playerShip.velocity)
#print "Ship: %f / Vel: %f (%f, %f) / timestep: %f" % (self.playerShip.get_rotation(), vel.theta, self.playerShip.velocity[0], self.playerShip.velocity[1], timestep)
# update all sprites
for sprite in self.backgroundSpriteGroup:
sprite.update(self)
for sprite in self.shipSpriteGroup:
sprite.update(self, timestep)
for sprite in self.foregroundSpriteGroup:
sprite.update(self, timestep)
if self.updateTriggers():
# player completed all primary objectives - mission should end with a victory status now
self.endMission()
else:
failed = False
for tg in self.triggerList:
if not tg.completed and tg.type.count("objective-primary") > 0 and tg.condition.count("survive") > 0:
failed = True
if failed:
self.endMission()
if not self.playerShip in self.shipSpriteGroup:
# player ship died - game over :(
#self.gameState = self.GAMESTATE_GAMEOVER
#self.menuManager.main_menu_click()
self.endMission()