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

import java.util.*;

public class Velocity {
	private Pair<Double> move = new Pair<>(0.0,0.0);
	private Pair<Double> acceleration = new Pair<>(0.0,0.0);
	private Position position;
	private Onground onground;
	private Pair<Double> value = new Pair<>(0.0,0.0);
	public void updateMove(Pair<Double> move) {
		this.move = move;
		Pair<Double> temp_if1;
		if ((this.onground.getValue()&&(move.getRight()>=0.0))) {
			temp_if1 = move;
		} else {
			temp_if1 = this.value;
		}
		value = temp_if1;
		position.updateVelocity(value);
	}
	public void updateAcceleration(Pair<Double> acceleration) {
		this.acceleration = acceleration;
		Pair<Double> temp_if3;
		if ((this.onground.getValue()&&(this.value.getRight()<0.0))) {
			temp_if3 = new Pair<>((this.value.getLeft()+(0.01*acceleration.getLeft())),0.0);
		} else {
			temp_if3 = new Pair<>((this.value.getLeft()+(0.01*acceleration.getLeft())),(this.value.getRight()+(0.01*acceleration.getRight())));
		}
		value = temp_if3;
		position.updateVelocity(value);
	}
	public Velocity(Position position, Onground onground) {
		this.position = position;
		this.onground = onground;
	}
	public Pair<Double> getValue() {
		return value;
	}
}