本文整理汇总了Python中Level.Level.retryLevel方法的典型用法代码示例。如果您正苦于以下问题:Python Level.retryLevel方法的具体用法?Python Level.retryLevel怎么用?Python Level.retryLevel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Level.Level
的用法示例。
在下文中一共展示了Level.retryLevel方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: WorldModel
# 需要导入模块: from Level import Level [as 别名]
# 或者: from Level.Level import retryLevel [as 别名]
class WorldModel(object):
DEBUG = False
physWorld = None
vel_iters, pos_iters = 6, 2
debugRender = None;
player = None
body = None
dynamic_enities = []
mFirstUpdate = True
mEntityToFollow = None
mTimer = None
mDeathTimer = 1.0
mSwitch = None
def __init__(self, camera, luObserver, fxObserver, lvl):
self.mSwitch = True
self.mTimer = 0.0
self.mLevelDone = False
self.mCamera = camera
self.mLuObs = luObserver
self.mFxObs = fxObserver
self.contactListener = ContactListener()
self.gravity = Gravity()
self.physWorld = b2World(gravity=(0,0),doSleep=True, contactListener=self.contactListener)
self.level = Level(self.physWorld, self.gravity, lvl)
self.player = Player(self.level.mStartPos, self.physWorld, self.gravity)
self.mEntityToFollow = self.player
def __resetWorld(self):
self.mSwitch = True
self.mDeathTimer = 1.0
self.mTimer = 0.0
self.dynamic_enities = []
self.mFirstUpdate = True
self.gravity.reset()
self.player.reset(b2Vec2(self.level.mStartPos.x + self.player.size.x/3, self.level.mStartPos.y + self.player.size.y/2))
self.mLuObs.levelChanged(self.level)
def restart(self):
self.level.retryLevel()
self.__resetWorld()
def update(self, delta):
self.mTimer += delta
#step the physicsworld
self.physWorld.Step(delta, self.vel_iters, self.pos_iters)
self.physWorld.ClearForces()
for body in self.physWorld.bodies:
#dynamic body
if body.type == b2_dynamicBody:
if self.mFirstUpdate:
if isinstance(body.userData, Player):
self.dynamic_enities.append(body)
if isinstance(body.userData, Player):
body.userData.update(delta)
elif isinstance(body.userData, Enemy):
body.userData.update(delta)
elif isinstance(body.userData, PickableObject):
body.userData.update(delta)
elif isinstance(body.userData, Particle):
body.userData.update(delta)
if self.mFirstUpdate == True:
self.mFirstUpdate = False
#update level, if level is done, returns true
if self.level.update(delta, self.player.position):
self.mLevelDone = True
#is player dead?
if not self.player.alive:
if self.mSwitch:
SoundManager.getInstance().playSound(SoundID.FLESHEXPLOSION)
self.mFxObs.addFx(BloodSplatter(self.physWorld, self.gravity.get(), self.player.position))
self.mSwitch = False
self.player.stopMovement()
self.mDeathTimer -= delta
if self.mDeathTimer < 0:
self.level.retryLevel()
self.__resetWorld()
def changeGravity(self, gravitydirection):
if self.player.isOnGround() == True:
self.gravity.set(gravitydirection)
for body in self.dynamic_enities:
if not body.userData.isInGravityZone():
body.userData.flip(gravitydirection)