added SwimWalker; strafe turns

This commit is contained in:
Darren Ranalli 2005-12-13 02:03:42 +00:00
parent 830d509665
commit 81edb9fc7d
2 changed files with 32 additions and 9 deletions

View File

@ -184,14 +184,7 @@ class NonPhysicsWalker(DirectObject.DirectObject):
"""
onScreenDebug.add("controls", "NonPhysicsWalker")
def handleAvatarControls(self, task):
"""
Check on the arrow keys and update the avatar.
"""
if not self.lifter.hasContact():
# hack fix for falling through the floor:
messenger.send("walkerIsOutOfWorld", [self.avatarNodePath])
def _calcSpeeds(self):
# get the button states:
forward = inputState.isSet("forward")
reverse = inputState.isSet("reverse")
@ -209,7 +202,17 @@ class NonPhysicsWalker(DirectObject.DirectObject):
self.rotationSpeed=not slide and (
(turnLeft and self.avatarControlRotateSpeed) or
(turnRight and -self.avatarControlRotateSpeed))
def handleAvatarControls(self, task):
"""
Check on the arrow keys and update the avatar.
"""
if not self.lifter.hasContact():
# hack fix for falling through the floor:
messenger.send("walkerIsOutOfWorld", [self.avatarNodePath])
self._calcSpeeds()
if __debug__:
debugRunning = inputState.isSet("debugRunning")
if debugRunning:

View File

@ -0,0 +1,20 @@
from direct.showbase.ShowBaseGlobal import *
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")
# 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))