Exemplo n.º 1
0
  // -------------------------- Kick ----------------------------------------
  //
  // applys a force to the ball in the direction of heading. Truncates
  // the new velocity to make sure it doesn't exceed the max allowable.
  // ------------------------------------------------------------------------
  public void kick(Vector2D direction, double force) {
    // ensure direction is normalized
    Vector2D d = direction.cloneVec();
    d.Normalize();

    // calculate the acceleration
    Vector2D acceleration = d.multiply(force).divide(mass);

    // update the velocity
    velocity.cloneVec(acceleration);
  }