public class Position {
private Pair<Double> velocity;
private boolean ground;
private Pair<Double> position;
public void updateVelocity(Pair<Double> velocity) {
this.velocity = velocity;
position = (((ground == true) && ((this.position.getY() + (0.01 * velocity.getY())) < 0.0))
? new Pair<>(this.position.getX() + (0.01 * velocity.getX()), 0.0)
: new Pair<>(this.position.getX() + (0.01 * velocity.getX()),
(this.position.getY() + (0.01 * velocity.getY()))));
}
public void updateGround(boolean ground) {
this.ground = ground;
position = (((ground == true) && ((this.position.getY() + (0.01 * velocity.getY())) < 0.0))
? new Pair<>(this.position.getX() + (0.01 * velocity.getX()), 0.0)
: new Pair<>(this.position.getX() + (0.01 * velocity.getX()),
this.position.getY() + (0.01 * velocity.getY())));
}
public Pair<Double> getPosition() {
return position;
}
}