package gameObjects;

/*
 * Created on Sep 20, 2004
 *
 * To change the template for this generated file go to
 * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
 */

/**
 * @author tamer
 * 
 * To change the template for this generated type comment go to
 * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
 */
public class Ball extends GameObject implements AbsPosSettable {
    double speedX, speedY;
    boolean speedKnown = false;

    // komplett sichtbarer Ball
    public Ball(float dist, float dir, float distChange, float dirChange,
            int time) {
        super(dist, dir, distChange, dirChange, time);
    }

    // nicht komplett sichtbarer Ball
    public Ball(float dist, float dir, int time) {
        super(dist, dir, time);
    }

    /**
     * @param i
     */
    public void setAbsX(double i) {
        super.setAbsX(i);
    }

    /**
     * @param i
     */
    public void setAbsY(double i) {
        super.setAbsY(i);
    }

    public String toString() {        
        String returnString =
            "Ball (x: " + super.getAbsX() 
            + ", y: " + super.getAbsY()
        	+ "dist: "+ super.getDist()
        	+ "dir: " + super.getDir()
        	+ "zuletzt gesehen: " + super.getLastSeenTime();
        try {

            returnString += 
                ", distChange: " + super.getDistChange()
                + ", dirChange: " + super.getDirChange();                                        
        } catch (ObjectInvisibleException e) {}
        if (isSpeedKnown())
            returnString +=
                ", speedX: " + speedX
        		+ ", speedY: " + speedY
        		+ ", speed: " + getSpeed();
        return returnString + ")";    
    }

    /**
     * @return Returns the speed.
     */
    public double getSpeed() {
        return Math.sqrt(speedX * speedX + speedY * speedY);
    }

    /**
     * @return Returns the speedX.
     */
    public double getSpeedX() {
        return speedX;
    }

    /**
     *  
     */
    public void setSpeedVector(double speedX, double speedY) {
        this.speedX = speedX;
        this.speedY = speedY;
        speedKnown = true;
    }

    /**
     * @return Returns the speedY.
     */
    public double getSpeedY() {
        return speedY;
    }

    /**
     * @return True, falls Geschwindigkeit per setSpeedVector(double X, double
     *         Y) eingetragen wurde, ansonsten false
     */
    public boolean isSpeedKnown() {
        return speedKnown;
    }

}