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

public class Acceleration {
	private double mass;
	private Vector2 force;
	private Velocity velocity;
	private Onground onground;
	private Vector2 acceleration;

	public void updateMass(double mass) {
		this.mass = mass;
		acceleration = (this.onground.getOnground() ? new AbstractMap.SimpleEntry<>((force.getKey() / mass), 0.0)
				: new Vector2((force.getX() / mass), (force.getY() / mass)));
		velocity.updateAcceleration(acceleration);
	}

	public void updateForce(Vector2 force) {
		this.force = force;
		acceleration = (this.onground.getOnground() ? new Vector2((force.getX() / mass), 0.0)
				: new Vector2((force.getX() / mass), (force.getY() / mass)));
		velocity.updateAcceleration(acceleration);
	}

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

	public Vector2 getAcceleration() {
		return acceleration;
	}
}