package entities; public class Velocity { private Pair<Double> moveValue = new Pair<>(0d, 0d); private Pair<Double> accelerationValue = new Pair<>(0d, 0d); private Position position; private Onground onground; private Pair<Double> value = new Pair<>(1d, 0d); //--------------------------------------------------------------- //--------------------------------------------------------------- public void updateByMove(Pair<Double> move) { this.moveValue = move; Pair<Double> temp_l2; if ((this.onground.getOnground() && (move.getSecond() >= 0.0))) { temp_l2 = move; } else { temp_l2 = this.value; } value = temp_l2; position.updateByVelocity(value); } //--------------------------------------------------------------- //--------------------------------------------------------------- public void updateByAcceleration(Pair<Double> acceleration) { this.accelerationValue = acceleration; Pair temp_l5; if ((this.onground.getOnground() && (this.value.getSecond() < 0.0))) { temp_l5 = new Pair((this.value.getFirst() + (0.01 * acceleration.getFirst())), 0.0); } else { temp_l5 = new Pair((this.value.getFirst() + (0.01 * acceleration.getFirst())), (this.value.getSecond() + (0.01 * acceleration.getSecond()))); } value = temp_l5; position.updateByVelocity(value); } //--------------------------------------------------------------- //--------------------------------------------------------------- public Velocity(Position position, Onground onground) { this.position = position; this.onground = onground; } //--------------------------------------------------------------- public Velocity(Pair<Double> value,Position position, Onground onground) { this.value = value; this.position = position; this.onground = onground; } //--------------------------------------------------------------- //--------------------------------------------------------------- public Pair<Double> getValue() { return value; } }