Newer
Older
JumpingGameOriginalSources / src / Acceleration.java
import java.util.*;

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

    public void updateForce(Pair<Double> force) {
        this.force = force;
        Pari<Double> temp_l3;
        if (this.onground.getOnground()) {
            temp_l3 = new Pair<>((force.getFirst() / mass), 0.0);
        } else {
            temp_l3 = new Pair<>((force.getFirst() / mass), (force.getSecond() / mass));
        }
        value = temp_l3;
        velocity.updateAcceleration(value);
    }

    public void updateMass(double mass) {
        this.mass = mass;
        Pair<Double> temp_l6;
        if (this.onground.getOnground()) {
            temp_l6 = new Pair<>((force.getFirst() / mass), 0.0);
        } else {
            temp_l6 = new Pair<>((force.getFirst() / mass), (force.getSecond() / mass));
        }
        value = temp_l6;
        velocity.updateAcceleration(value);
    }

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

    public Pair<Double> getValue() {
        return value;
    }
}