- Bug fix for moving while no keys are pressed

This commit is contained in:
Jason Yeung 2009-08-15 01:59:47 +00:00
parent fc74ddace3
commit c50e998801

View File

@ -379,14 +379,16 @@ class ShipPilot(PhysicsWalker):
# How far did we move based on the amount of time elapsed? # How far did we move based on the amount of time elapsed?
dt = ClockObject.getGlobalClock().getDt() dt = ClockObject.getGlobalClock().getDt()
minSpeed = (self.ship.acceleration + self.ship.speedboost) * self.ship.speednerf minSpeed = (self.ship.acceleration + self.ship.speedboost) * self.ship.speednerf
minStraightSail = 1.0 / self.MAX_STRAIGHT_SAIL_BONUS * self.STRAIGHT_SAIL_BONUS_TIME * self.ship.speednerf minStraightSail = 1.0 / self.MAX_STRAIGHT_SAIL_BONUS * self.STRAIGHT_SAIL_BONUS_TIME * self.ship.speednerf
if reverse: if reverse:
# Decelerate while sails are up # Decelerate while sails are up
self.straightHeading -= dt * self.TURNING_BONUS_REDUCTION * 2.0 if (self.straightHeading < 0):
#elif (self.__speed < minSpeed) and forward: self.straightHeading -= dt * self.TURNING_BONUS_REDUCTION * 2.0
else:
self.straightHeading -= dt * self.TURNING_BONUS_REDUCTION * 4.0
elif (self.straightHeading < minStraightSail) and forward: elif (self.straightHeading < minStraightSail) and forward:
# If not at MinSpeed, Accelerate regardless # If not at MinSpeed, Accelerate regardless
self.straightHeading += dt * 1.5 self.straightHeading += dt * 1.5
@ -399,7 +401,7 @@ class ShipPilot(PhysicsWalker):
self.straightHeading = minStraightSail self.straightHeading = minStraightSail
else: else:
self.straightHeading -= dt * self.TURNING_BONUS_REDUCTION self.straightHeading -= dt * self.TURNING_BONUS_REDUCTION
else: elif forward:
# Add in the Straight Sailing Time # Add in the Straight Sailing Time
self.straightHeading += dt self.straightHeading += dt
@ -407,8 +409,8 @@ class ShipPilot(PhysicsWalker):
# Allow straightHeading to reach a negative value # Allow straightHeading to reach a negative value
self.straightHeading = max(self.REVERSE_STRAIGHT_SAIL_BONUS_TIME, self.straightHeading) self.straightHeading = max(self.REVERSE_STRAIGHT_SAIL_BONUS_TIME, self.straightHeading)
else: else:
# Normally min straightHeading is 1.0 # Normally min straightHeading is 0.0
self.straightHeading = max(1.0, min(self.STRAIGHT_SAIL_BONUS_TIME, self.straightHeading)) self.straightHeading = max(0.0, min(self.STRAIGHT_SAIL_BONUS_TIME, self.straightHeading))
# Straight Sailing Acceleration Bonus # Straight Sailing Acceleration Bonus
straightSailBonus = 0.0 straightSailBonus = 0.0
@ -456,7 +458,7 @@ class ShipPilot(PhysicsWalker):
if self.currentTurning < 0.001 and self.currentTurning > -0.001: if self.currentTurning < 0.001 and self.currentTurning > -0.001:
self.currentTurning = 0.0 self.currentTurning = 0.0
self.__rotationSpeed = self.currentTurning self.__rotationSpeed = self.currentTurning
# Broadcast Event to Handlers (ShipStatusMeter) # Broadcast Event to Handlers (ShipStatusMeter)
messenger.send("setShipSpeed-%s" % (self.ship.getDoId()), [self.__speed, self.getMaxSpeed()]) messenger.send("setShipSpeed-%s" % (self.ship.getDoId()), [self.__speed, self.getMaxSpeed()])