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

public class Position {
	private Vector2 velocity;
	private boolean ground;
	private Vector2 position;

	public void updateVelocity(Vector2 velocity) {
		this.velocity = velocity;
		position = (((ground == true) && ((this.position.getY() + (0.01 * velocity.getY())) < 0.0))
				? new Vector2(this.position.getX() + (0.01 * velocity.getX()), 0.0)
				: new Vector2(this.position.getX() + (0.01 * velocity.getX()),
						(this.position.getY() + (0.01 * velocity.getY()))));
	}

	public void updateGround(boolean ground) {
		this.ground = ground;
		position = (((ground == true) && ((this.position.getY() + (0.01 * velocity.getY())) < 0.0))
				? new Vector2(this.position.getX() + (0.01 * velocity.getX()), 0.0)
				: new Vector2(this.position.getX() + (0.01 * velocity.getX()),
						this.position.getY() + (0.01 * velocity.getY())));
	}

	public Vector2 getPosition() {
		return position;
	}
}