package server.match.objects;

import java.awt.geom.Point2D;
import java.awt.geom.Point2D.Double;
import java.awt.image.BufferedImage;

import main.Window;

public class Player extends DrawObject {

	private int score, health, speed = 10;
	private Double beginlocation;

	// Contains the logic for players
	public Player(BufferedImage image, int x, int y) {
		super(image.getSubimage(38, 0, 40, 54));
		super.setPosition(x, y);
		beginlocation = new Point2D.Double(x, y);
		health = 5;
	}

	// Walk left when key is pressed
	public void walkLeft() {
		if (getX() - speed > 10) {
			setX(getX() - speed);
		}
	}

	// Walk right when key is pressed
	public void walkRight() {
		if (getX() + getWidth() + speed < Window.WIDTH - 10) {
			setX(getX() + speed);
		}
	}

	// Reset player to start location
	public void reset() {
		setPosition(beginlocation);
		speed = 10;
	}

	// ** Getters and Setters **//

	public int getScore() {
		return score;
	}

	public void setScore(int score) {
		this.score = score;
	}

	public int getHealth() {
		return health;
	}

	public void setHealth(int health) {
		this.health = health;
	}
}
