Newer
Older
JumpingGame / src / Position.java
k-fujii on 10 Sep 2021 820 bytes ・updateメソッドとsetterを分離
import java.util.*;

public class Position {
	private Map.Entry<Double, Double> velocity;
	private boolean isGround;
	private Map.Entry<Double, Double> position;

	public void setVelocity(Map.Entry<Double, Double> velocity) {
		this.velocity = velocity;
	}

	public void setGround(boolean isGround) {
		this.isGround = isGround;
	}

	public void updatePosition() {
		position = (((isGround == true) && ((this.position.getValue() + (0.01 * this.velocity.getValue())) < 0.0))
				? new AbstractMap.SimpleEntry<>((this.position.getKey() + (0.01 * this.velocity.getKey())), 0.0)
				: new AbstractMap.SimpleEntry<>((this.position.getKey() + (0.01 * this.velocity.getKey())),
						(this.position.getValue() + (0.01 * this.velocity.getValue()))));
	}

	public Map.Entry<Double, Double> getPosition() {
		return position;
	}
}