Newer
Older
JumpingGame / src / Position.java
k-fujii on 6 Sep 2021 1 KB initial commit
import java.util.*;

public class Position {
	private Map.Entry<Double, Double> velocity;
	private boolean ground;
	private Map.Entry<Double, Double> position;
	public void updateVelocity(Map.Entry<Double, Double> velocity) {
		this.velocity = velocity;
		position = (((ground==true)&&((this.position.getValue()+(0.01*velocity.getValue()))<0.0)) ? new AbstractMap.SimpleEntry<>((this.position.getKey()+(0.01*velocity.getKey())), 0.0) : new AbstractMap.SimpleEntry<>((this.position.getKey()+(0.01*velocity.getKey())), (this.position.getValue()+(0.01*velocity.getValue()))));
	}
	public void updateGround(boolean ground) {
		this.ground = ground;
		position = (((ground==true)&&((this.position.getValue()+(0.01*velocity.getValue()))<0.0)) ? new AbstractMap.SimpleEntry<>((this.position.getKey()+(0.01*velocity.getKey())), 0.0) : new AbstractMap.SimpleEntry<>((this.position.getKey()+(0.01*velocity.getKey())), (this.position.getValue()+(0.01*velocity.getValue()))));
	}
	public Map.Entry<Double, Double> getPosition() {
		return position;
	}
}