package test;
import java.awt.Graphics;

abstract public class Sprite1 {
	private double xMin, yMin, xMax, yMax;
	private double xCenter, yCenter;
	private double speed, heading;

	public Sprite1(double xMin, double xMax, double yMin, double yMax) {
		this.xMax = xMax;
		this.xMin = xMin;
		this.yMax = yMax;
		this.yMin = yMin;

		xCenter = (xMin+xMax)/2;
		yCenter = (yMin+yMax)/2;
		speed = 10;
		heading = 0;
	}

	// requires x and y to be legal coordinates
	abstract public boolean contains(double x, double y);

	// ensures that sprite is drawn on screen
	abstract public void draw(Graphics screen);

	// ensures that sprite moves according to its speed and heading
	// ensures that sprite wraps around as needed if it goes out of bounds
	public void move() {
		xCenter += speed * Math.cos(heading);
		yCenter += speed * Math.sin(heading);

		if (xCenter > xMax) {xCenter = xMin;}
		if (yCenter > yMax) {yCenter = yMin;}
		if (xCenter < xMin) {xCenter = xMax;}
		if (yCenter < yMin) {yCenter = yMax;}
	}

	public double speed() {
		return speed;
	}

	public double heading() {
		return heading;
	}

	public double xCenter() {
		return xCenter;
	}

	public double yCenter() {
		return yCenter;
	}

	public double xMin() {
		return xMin;
	}

	public double yMin() {
		return yMin;
	}

	public double xMax() {
		return xMax;
	}

	public double yMax() {
		return yMax;
	}
}
