Esempio n. 1
0
Projectile::Projectile(float px, float py, float pDirection, float pVelocity, float pDamage, sf::Texture mSpriteTexture)
{
    CalculateVelocities(pDirection, pVelocity);

    SetDamage(pDamage);
    SetTexture(mSpriteTexture);
    SetDirection(pDirection);
    SetPosX(px);
    SetPosY(py);
}
Esempio n. 2
0
void LineSmoother::ProcessNewPoint()
{
   if(_orgPoints.size() < 1)
   {  // Nothing to do.
      return;
   }
   uint32 newPointIndex = _orgPoints.size()-1;
#ifdef DEBUG_LINE_SMOOTHER
   _orgPoints[newPointIndex].widthPixels = 1.0*newPointIndex;
#endif
   CalculateVelocities(newPointIndex);
   CalculateWidths(newPointIndex);
   CalculateSmoothPoints(newPointIndex);
}
Esempio n. 3
0
// Update the controller
void ServoPlugin::Update()
{
  // handle callbacks
  queue_.callAvailable();

  common::Time stepTime;
  stepTime = world->GetSimTime() - prevUpdateTime;

  if (controlPeriod == 0.0 || stepTime > controlPeriod) {
    CalculateVelocities();
    publish_joint_states();
    prevUpdateTime = world->GetSimTime();
  }

  if (enableMotors)
  {
    servo[FIRST].joint->SetVelocity(0, servo[FIRST].velocity);
    if (countOfServos > 1) {
      servo[SECOND].joint->SetVelocity(0, servo[SECOND].velocity);
      if (countOfServos > 2) {
        servo[THIRD].joint->SetVelocity(0, servo[THIRD].velocity);
      }
    }

    servo[FIRST].joint->SetMaxForce(0, maximumTorque);
    if (countOfServos > 1) {
      servo[SECOND].joint->SetMaxForce(0, maximumTorque);
      if (countOfServos > 2) {
        servo[THIRD].joint->SetMaxForce(0, maximumTorque);
      }
    }
  } else {
    servo[FIRST].joint->SetMaxForce(0, 0.0);
    if (countOfServos > 1) {
      servo[SECOND].joint->SetMaxForce(0, 0.0);
      if (countOfServos > 2) {
        servo[THIRD].joint->SetMaxForce(0, 0.0);
      }
    }
  }
}