/*
 * Created on Nov 22, 2004
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package jone;
import java.awt.geom.Point2D;
import java.awt.*;
import java.util.Random;

import javax.swing.*;
/**
 * @author brian
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public abstract class Critter {
	
	protected Point2D.Double position;
	
	
	/* should this be magnitude of acceleration */
	
	//protected Point2D.Double acceleration;
	protected double health;
	public abstract void draw(Graphics g);
	public void respawn(Critter [] critters)
	{
		Random random = RandomSingleton.getDefaultInstance();
		//this.numSpawnsSinceStartOfEpoch++;//i should reset this
		boolean done = true;
		//GrassPatch [] grasses = (GrassPatch []) critters;
		do {
			this.position = new Point2D.Double(random.nextDouble(),random.nextDouble());
			int i = 0;
			done = true;
			while(done && critters != null && i < critters.length) {
				if(critters[i].position.distance(this.position) < critters[i].getRadius() && 
						critters[i] != this) {
					done = false;
				}
				i++;
			}
		}while(!done);
	}
	public abstract void init();
	public abstract double getWeight();
	public double getRadius() { return 0.05;};
	public void setPosition(double x, double y)
	{
		position = new Point2D.Double(x,y);
	}
	public Point2D.Double getPosition() { return position; }
	//public Point2D.Double getAcceleration(){ return acceleration; }
	/*public double getRadius()
	{
		return radius;
	}
	protected double radius;
	public void setRadius(double r)
	{
		radius = r;
	}*/
}
