Newer
Older
JumpingGame / src / main / java / entities / Position.java
package entities;
import java.util.*;

public class Position {
	private Onground onground;
	private Clear clear;
	private Gameover gameover;
	private Ground ground;
	private Pair<Double> value = new Pair<>(0.0,0.0);
	public void updateVelocity(Pair<Double> velocity) {
		Pair<Double> temp_if4;
		if (((this.ground.getValue()==true)&&((this.value.getRight()+(0.01*velocity.getRight()))<0.0))) {
			temp_if4 = new Pair<>((this.value.getLeft()+(0.01*velocity.getLeft())),0.0);
		} else {
			temp_if4 = new Pair<>((this.value.getLeft()+(0.01*velocity.getLeft())),(this.value.getRight()+(0.01*velocity.getRight())));
		}
		value = temp_if4;
		onground.updatePosition(value);
		clear.updatePosition(value);
		gameover.updatePosition(value);
	}
	public Position(Onground onground, Clear clear, Gameover gameover, Ground ground) {
		this.onground = onground;
		this.clear = clear;
		this.gameover = gameover;
		this.ground = ground;
	}
	public Pair<Double> getValue() {
		return value;
	}
}