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

public class Acceleration {
	private Pair<Double> force = new Pair<>(0.0,0.0);
	private double mass = 1.0;
	private Velocity velocity;
	private Onground onground;
	private Pair<Double> value = new Pair<>(0.0,0.0);
	public void updateForce(Pair<Double> force) {
		this.force = force;
		Pair<Double> temp_if1;
		if (this.onground.getValue()) {
			temp_if1 = new Pair<>((force.getLeft()/mass),0.0);
		} else {
			temp_if1 = new Pair<>((force.getLeft()/mass),(force.getRight()/mass));
		}
		value = temp_if1;
		velocity.updateAcceleration(value);
	}
	public void updateMass(double mass) {
		this.mass = mass;
		Pair<Double> temp_if5;
		if (this.onground.getValue()) {
			temp_if5 = new Pair<>((force.getLeft()/mass),0.0);
		} else {
			temp_if5 = new Pair<>((force.getLeft()/mass),(force.getRight()/mass));
		}
		value = temp_if5;
		velocity.updateAcceleration(value);
	}
	public Acceleration(Velocity velocity, Onground onground) {
		this.velocity = velocity;
		this.onground = onground;
	}
	public Pair<Double> getValue() {
		return value;
	}
}