Animation eines Kreises Zwei Bälle bewegen sich |
Animation Kreises (Ende durch Druck auf die rechte
Maustaste):
Quelltext:
import stiftUndCo.*;
public class StartBall2
{
public static void main(String[] s)
{
Ball2 meinBall2 = new Ball2();
meinBall2.führeAus();
}
}
class Ball2
{
private Bildschirm bildschirm;
private BuntStift stift;
private Maus maus;
private Tastatur tastatur;
public void führeAus()
{/* Bereitstellen, Initialisierungsteil */
bildschirm=new Bildschirm();
stift=new BuntStift();
maus = new Maus();
tastatur = new Tastatur();
stift.bewegeBis(bildschirm.breite()/2,bildschirm.hoehe()/2);
stift.zeichneKreis(20);
/*Arbeiten, Aktionsteil */
do
{
do
{
stift.radiere();
stift.zeichneKreis(20);
stift.bewegeUm(1);
stift.normal();
stift.zeichneKreis(20);
} while (stift.hPosition()< bildschirm.breite()-20);
stift.dreheUm(180);
do
{
stift.radiere();
stift.zeichneKreis(20);
stift.bewegeUm(1);
stift.normal();
stift.zeichneKreis(20);
} while (stift.hPosition()>20);
stift.dreheUm(180);
} while (! maus.istRechtsGedrueckt());
/* Aufräumen, Abbauteil */
tastatur.gibFrei();
maus.gibFrei();
stift.gibFrei();
bildschirm.gibFrei();
}
}
|