import sum.kern.*;
/**
* @Ruben
* @version
*/
public class Kugel
{
// Bezugsobjekte
private Stift hatStift;
private Bildschirm kenntBildschirm;
// Attribute
int zgroesse;
double zgeschwindigkeit;
double zwinkel;
// Konstruktor
public Kugel(int groesse, double geschwindigkeit, int hPosition, int vPosition)
{
zgeschwindigkeit = geschwindigkeit;
zgroesse = groesse;
hatStift = new Stift();
hatStift.bewegeBis(hPosition, vPosition);
}
// Dienste
public void gibFrei()
{
hatStift.gibFrei();
}
public void zeichne()
{
hatStift.zeichneKreis(zgroesse);
}
public void loesche()
{
hatStift.radiere();
this.zeichne();
hatStift.normal();
}
public double hPosition()
{
return hatStift.hPosition();
}
public double vPosition()
{
return hatStift.vPosition();
}
private boolean linkerRand()
{
if(this.hPosition() <= 102 + zgroesse){
return true;
}else{
return false;
}
}
private boolean rechterRand()
{
if(this.hPosition() >= 899 - zgroesse){
return true;
}else{
return false;
}
}
private boolean obererRand()
{
if(this.vPosition() <= 201 + zgroesse){
return true;
}else{
return false;
}
}
private boolean untererRand()
{
if(this.vPosition() >= 499 - zgroesse){
return true;
}else{
return false;
}
}
public void setzeRichtung(double pRichtung){
hatStift.dreheBis(pRichtung);
}
public void bewege()
{
this.loesche();
hatStift.bewegeUm(zgeschwindigkeit);
if(this.rechterRand() == true || this.linkerRand() == true){
hatStift.dreheBis(180 - hatStift.winkel());
}
else if (this.obererRand() == true || this.untererRand() == true)
{
hatStift.dreheBis(360 - hatStift.winkel());
}
this.zeichne();
}
}