Poodletooth-iLand/panda/direct/controls/SwimWalker.py
Master Jumblespeed d882959bfa switch to remote
2015-05-18 22:11:33 -04:00

26 lines
1.1 KiB
Python
Executable file

from direct.showbase.InputStateGlobal import inputState
from direct.directnotify import DirectNotifyGlobal
from direct.controls import NonPhysicsWalker
class SwimWalker(NonPhysicsWalker.NonPhysicsWalker):
notify = DirectNotifyGlobal.directNotify.newCategory("SwimWalker")
def _calcSpeeds(self):
# get the button states:
forward = inputState.isSet("forward")
reverse = inputState.isSet("reverse")
turnLeft = inputState.isSet("turnLeft") or inputState.isSet("slideLeft")
turnRight = inputState.isSet("turnRight") or inputState.isSet("slideRight")
# Check for Auto-Run
if base.localAvatar.getAutoRun():
forward = 1
reverse = 0
# Determine what the speeds are based on the buttons:
self.speed=(forward and self.avatarControlForwardSpeed or
reverse and -self.avatarControlReverseSpeed)
self.slideSpeed=0.
self.rotationSpeed=(
(turnLeft and self.avatarControlRotateSpeed) or
(turnRight and -self.avatarControlRotateSpeed))