import java.awt.Color;
import java.awt.geom.*;

/**
 * A human player in Pick up the Peanuts.
 *
 * @author Jim Glenn
 * @version 0.1 1/21/2009
 */

public class Elephant extends Sprite
{
    /**
     * The size of an elephant.
     */

    public static final double DEFAULT_SIZE = 0.025;

    /**
     * Creates a new elephant at the given position.
     * The elephant will be gray.
     *
     * @param initX an x-coordinate within the world this elephant will be in
     * @param initY a y-coordinate within the world this elephant will be in
     */

    public Elephant(double initX, double initY)
    {
	super(initX, initY, DEFAULT_SIZE, Color.GRAY);
    }

    /**
     * Returns the maximum speed of this elephant.
     *
     * @return the speed
     */

    public double getMaximumSpeed()
    {
	return 0.2;
    }

    /**
     * Updates this elephant.
     *
     * @param t the time since the last update
     * @param m the model this player belongs to
     */

    public void update(double t, GameModel m)
    {
    }

    public GeneralPath getOutline()
    {
	double r = getBoundingRadius();

	double earTop = y - r * Math.cos(Math.PI / 4);
	double earXOff = r * Math.sin(Math.PI / 4);
	double earLeft = x - earXOff;
	double earRight = x + earXOff;

	double trunkY = y + r * Math.cos(Math.PI / 10);
	double trunkOff = r * Math.sin(Math.PI / 10);
	double trunkLeft = x - trunkOff;
	double trunkRight = x + trunkOff;

	// we should be able to do a little better than this very
	// crude rendering of an elephant's head

	GeneralPath outline = new GeneralPath();
	outline.moveTo((float)earLeft, (float)earTop);
	outline.lineTo((float)(earLeft + r / 4), (float)earTop);
	outline.lineTo((float)(earRight - r / 4), (float)earTop);
	outline.lineTo((float)earRight, (float)earTop);
	outline.lineTo((float)earRight, (float)(y + r / 8));
	outline.lineTo((float)(earRight - r / 4), (float)(y + r / 8));
	outline.lineTo((float)(earRight - r / 4), (float)(y + r / 2));
	outline.lineTo((float)trunkRight, (float)(y + r / 2));
	outline.lineTo((float)trunkRight, (float)trunkY);
	outline.lineTo((float)trunkLeft, (float)trunkY);
	outline.lineTo((float)trunkLeft, (float)(y + r / 2));
	outline.lineTo((float)(earLeft + r / 4), (float)(y + r / 2));
	outline.lineTo((float)(earLeft + r / 4), (float)(y + r / 8));
	outline.lineTo((float)earLeft, (float)(y + r / 8));
	outline.closePath();

	return outline;
    }

}

