Exemplo n.º 1
0
  @Override
  public void moveComponent() {
    inMotion = true;
    direction = body.getRotation();
    net.phys2d.math.ROVector2f p = body.getPosition();
    x = p.getX();
    y = p.getY();
    for (Iterator<Sensor> sIter = sensors.iterator(); sIter.hasNext(); ) {
      Sensor s = (Sensor) sIter.next();
      s.moveComponent();
    }

    final double distance = Util.euclideanDistance(lastX, lastY, x, y);
    final double velDist = lastVelocity - getSpeed() > 0 ? lastVelocity - getSpeed() : 0;
    if (velDist > 10) {
      crashmeter += velDist;
    }
    if (velDist > maxDeceleration) {
      maxDeceleration = velDist;
    }
    overallDeceleration += velDist;
    lastVelocity = getSpeed();

    odometer += distance;
    lastX = x;
    lastY = y;
  }