Example #1
0
 public static Vector2 flee(Vector2 targetPos, Vehicle v) {
   Vector2 desiredVelocity = v.getCenter().cpy().sub(targetPos);
   Vector2 velocity = v.getVelocity();
   desiredVelocity.nor();
   desiredVelocity.mul(v.getMaxVelocity());
   desiredVelocity.sub(velocity).mul(CORRECTION);
   return desiredVelocity;
 }
Example #2
0
  public static Vector2 arrive(Vector2 targetPos, Vehicle v) {
    Vector2 desiredVelocity = v.getCenter().cpy().sub(targetPos);
    Vector2 velocity = v.getVelocity();

    float len = desiredVelocity.len();
    if (len > 0.05f) {
      desiredVelocity.nor();
      float min = Math.min(len, v.getMaxVelocity());
      desiredVelocity.mul(min);
      desiredVelocity.sub(velocity).mul(-CORRECTION);
    }
    return desiredVelocity;
  }
Example #3
0
  @Override
  public boolean touchDragged(int x, int y, int pointer) {

    if (howmanyfingers == 1 && pointer == 0) {
      delta.set(x, y).sub(last);
      delta.mul(0.01f * Constants.MOVESPEED);
      Vector3 temp = new Vector3(delta.y, 0, -delta.x);
      Quaternion rotation = new Quaternion();
      camera.combined.getRotation(rotation);
      rotation.transform(temp);
      camera.translate(temp);
      camera.update();
      last.set(x, y);
    }

    if (pointer == 0) last.set(x, y);

    return true;
  }