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

public class Acceleration {
    private double massValue;
    private Vector2 forceValue;
    private Velocity velocity;
    private Onground onground;
    private Vector2 value;

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

    public void updateByForce(Vector2 force) {
        this.forceValue = force;
        Vector2 temp_l1;
        if (this.onground.getOnground()) {
            temp_l1 = new Vector2((force.getX() / massValue), 0.0);
        } else {
            temp_l1 = new Vector2((force.getX() / massValue), (force.getY() / massValue));
        }
        value = temp_l1;
        velocity.updateByAcceleration(value);
    }

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

    public Vector2 getValue() {
        return value;
    }
}