Newer
Older
JumpingGame / src / main / java / resources / Acceleration.java
package resources;

public class Acceleration {
    private double massValue;
    private Pair<Double> forceValue;
    private Velocity velocity;
    private Onground onground;
    private Pair<Double> value;

    public void updateByMass(double mass) {
        this.massValue = mass;
        Pair temp_l0;
        if (this.onground.getOnground()) {
            temp_l0 = new Pair((forceValue.getFirst() / mass), 0.0);
        } else {
            temp_l0 = new Pair((forceValue.getFirst() / mass), (forceValue.getSecond() / mass));
        }
        value = temp_l0;
        velocity.updateByAcceleration(value);
    }

    public void updateByForce(Pair<Double> force) {
        this.forceValue = force;
        Pair temp_l1;
        if (this.onground.getOnground()) {
            temp_l1 = new Pair((force.getFirst() / massValue), 0.0);
        } else {
            temp_l1 = new Pair((force.getFirst() / massValue), (force.getSecond() / massValue));
        }
        value = temp_l1;
        velocity.updateByAcceleration(value);
    }

    public Acceleration(Velocity velocity, Onground onground) {
        this.velocity = velocity;
        this.onground = onground;
    }

    public Pair getValue() {
        return value;
    }
}