本文整理汇总了Python中ball.Ball.rotate方法的典型用法代码示例。如果您正苦于以下问题:Python Ball.rotate方法的具体用法?Python Ball.rotate怎么用?Python Ball.rotate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ball.Ball
的用法示例。
在下文中一共展示了Ball.rotate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: World
# 需要导入模块: from ball import Ball [as 别名]
# 或者: from ball.Ball import rotate [as 别名]
#.........这里部分代码省略.........
self.canMove=True
self.player.setH(self.player.getH() - 300 * globalClock.getDt())
if (self.keyMap["forward"]!=0):
if (self.keyMap["speed-toggle"]!=0):
self.player.setY(self.player, -10 * globalClock.getDt())
if self.checkCollision():
self.player.setY(self.player, +10 * globalClock.getDt())
else:
self.player.setY(self.player, -25 * globalClock.getDt())
if self.checkCollision():
self.player.setY(self.player, +25 * globalClock.getDt())
if (self.keyMap["reverse"]!=0):
if (self.keyMap["speed-toggle"]!=0):
self.player.setY(self.player, +10 * globalClock.getDt())
if self.checkCollision():
self.player.setY(self.player, -10 * globalClock.getDt())
else:
self.player.setY(self.player, +25 * globalClock.getDt())
if self.checkCollision():
self.player.setY(self.player, -250 * globalClock.getDt())
# If ralph is moving, loop the run animation.
# If he is standing still, stop the animation.
if ((self.keyMap["forward"]!=0) or (self.keyMap["left"]!=0) or
(self.keyMap["right"]!=0)) and (self.keyMap["speed-toggle"]!=0):
if self.isWalking is False:
self.isWalking = True
self.player.setPlayRate(1, "walk")
self.player.loop("walk")
elif ((self.keyMap["forward"]!=0) or (self.keyMap["left"]!=0) or
(self.keyMap["right"]!=0)):
if self.isMoving is False or self.isWalking:
self.isWalking = False
self.isMoving = True
self.player.setPlayRate(1, "run")
self.player.loop("run")
elif (self.keyMap["reverse"]!=0) and (self.keyMap["speed-toggle"]!=0):
if self.isWalking is False:
self.isWalking = True
self.player.setPlayRate(-1, "walk")
self.player.loop("walk")
elif (self.keyMap["reverse"]!=0):
if self.isMoving is False or self.isWalking:
self.isWalking = False
self.isMoving = True
self.player.setPlayRate(-1, "run")
self.player.loop("run")
else:
if self.isMoving:
self.player.stop()
self.player.pose("walk",5)
self.isMoving = False
self.isWalking = False
# If the camera is too far from ralph, move it closer.
# If the camera is too close to ralph, move it farther.
camvec = self.player.getPos() - base.camera.getPos()
camvec.setZ(0)
camdist = camvec.length()
camvec.normalize()
if (camdist > 10.0):
base.camera.setPos(base.camera.getPos() + camvec*(camdist-10))
camdist = 10.0
if (camdist < 5.0):
base.camera.setPos(base.camera.getPos() - camvec*(5-camdist))
camdist = 5.0
# The camera should look in ralph's direction,
# but it should also try to stay horizontal, so look at
# a floater which hovers above ralph's head.
self.floater.setPos(self.player.getPos())
self.floater.setZ(self.player.getZ() + 2.0)
base.camera.lookAt(self.floater)
# Panda action
#self.panda1.follow(self.player, globalClock.getFrameTime())
#self.panda2.follow(self.player, globalClock.getFrameTime())
#self.panda1.waitedTooLong(globalClock.getFrameTime())
#self.panda2.waitedTooLong(globalClock.getFrameTime())
# Car action
# self.car.circle(self.player)
# Ball action
self.ball1.rotate(self.player)
self.ball2.rotate(self.player)
self.ball3.rotate(self.player)
return task.cont