Antwort
Und Spieler1
import sum.kern.*;
import sum.werkzeuge.*;
/**
* @author
* @version
*/
public class Spieler1
{
// Objekte
Buntstift hatBuntstift;
Rechner hatRechner;
Bildschirm kenntBildschirm;
double zWinkel;
// Konstruktor
public Spieler1(Bildschirm pBildschirm, double pWinkel)
{
kenntBildschirm = pBildschirm;
hatBuntstift = new Buntstift();
hatRechner = new Rechner();
hatBuntstift.bewegeBis(hatRechner.ganzeZufallszahl(1, kenntBildschirm.breite() -10), hatRechner.ganzeZufallszahl(1, kenntBildschirm.hoehe() -10));
hatBuntstift.setzeFuellmuster(Muster.GEFUELLT);
hatBuntstift.setzeFarbe(Farbe.SCHWARZ);
zWinkel = pWinkel;
}
// Dienste
public void zeichne()
{
hatBuntstift.zeichneKreis(3);
hatBuntstift.hoch();
hatBuntstift.bewegeUm(-1);
hatBuntstift.runter();
hatBuntstift.setzeFarbe(Farbe.ROT);
hatBuntstift.zeichneKreis(3);
hatBuntstift.hoch();
hatBuntstift.bewegeUm(1);
hatBuntstift.runter();
hatBuntstift.setzeFarbe(Farbe.SCHWARZ);
hatBuntstift.zeichneKreis(3);
}
public void gibFrei()
{
hatBuntstift.gibFrei();
}
public void nachRechts()
{
hatBuntstift.dreheUm(-5);
this.bewege();
}
public void nachLinks()
{
hatBuntstift.dreheUm(5);
this.bewege();
}
public void bewege()
{
hatBuntstift.normal();
hatBuntstift.bewegeUm(0.3);
this.zeichne();
}
public void loesche()
{
hatBuntstift.radiere();
this.zeichne();
}
public double hPosition()
{
return hatBuntstift.hPosition();
}
public double vPosition()
{
return hatBuntstift.vPosition();
}
public boolean amOberenRand()
{
return this.vPosition() <= 1 ;
}
public boolean amLinkenRand()
{
return this.hPosition() <= 1;
}
private double Winkel()
{
return this.Winkel();
}
public boolean amRechtenRand()
{
return this.hPosition() > (kenntBildschirm.breite() - 1);
}
public boolean amUnterenRand()
{
return this.vPosition() > (kenntBildschirm.hoehe() - 1);
}
}