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

public class Velocity {
    private Vector2 moveValue;
    private Vector2 accelerationValue;
    private Position position;
    private Onground onground;
    private Vector2 value;

    public void updateByMove(Vector2 move) {
        this.moveValue = move;
        Vector2 temp_l2;
        if ((this.onground.getOnground() && (move.getY() >= 0.0))) {
            temp_l2 = move;
        } else {
            temp_l2 = this.value;
        }
        value = temp_l2;
        position.updateByVelocity(value);
    }

    public void updateByAcceleration(Vector2 acceleration) {
        this.accelerationValue = acceleration;
        Vector2 temp_l5;
        if ((this.onground.getOnground() && (this.value.getY() < 0.0))) {
            temp_l5 = new Vector2((this.value.getX() + (0.01 * acceleration.getX())), 0.0);
        } else {
            temp_l5 = new Vector2((this.value.getX() + (0.01 * acceleration.getX())), (this.value.getY() + (0.01 * acceleration.getY())));
        }
        value = temp_l5;
        position.updateByVelocity(value);
    }

    public Velocity(Position position, Onground onground) {
        this.position = position;
        this.onground = onground;
    }

    public Vector2 getValue() {
        return value;
    }
}