Esempio n. 1
0
  def testLimitVelocity(self):
    vel = (1,1)
    self.ship.setVel(vel)
    self.ship.limitVelocity()
    newVel = self.ship.getVel()
    newVelScalar = tupleLength(newVel)
    self.failIf(newVelScalar > Ship.SPEED_MAX)
    self.failIf(newVelScalar < 0)

    vel = (Ship.SPEED_MAX, Ship.SPEED_MAX)
    self.ship.setVel(vel)
    self.ship.limitVelocity()
    newVel = self.ship.getVel()
    newVelScalar = tupleLength(newVel)
    self.failUnless( abs(newVelScalar - Ship.SPEED_MAX) < 0.01)
Esempio n. 2
0
 def limitVelocity(self):
     shipVel = self.getVel()
     newVelScalar = tupleLength(shipVel)
     if newVelScalar > Ship.SPEED_MAX:
         newVelScale = Ship.SPEED_MAX / newVelScalar
         newVel = scaleTuple(shipVel, newVelScale)
         self.setVel(newVel)
Esempio n. 3
0
 def testTupleLength(self):
   self.failUnlessEqual( tupleLength( (3, 4) ), 5)
Esempio n. 4
0
 def testTupleLength(self):
     self.failUnlessEqual(tupleLength((3, 4)), 5)