aboutsummaryrefslogtreecommitdiff
path: root/Info/10/2/Baelle/BlueJ_Projekt/Ball.java
blob: 61c92965d1bb059dc5e9e4538805e51f161a7f32 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
public class Ball extends Kreis implements Zeichenfenster.AktionsEmpfaenger {
    static final double BESCHLEUNIGUNG = 5;
    double geschwindigkeit = 0;
    
    public Ball() {
        super();
        Zeichenfenster.AktionsEmpfängerEintragen(this);
    }
    
    public Ball(int x, int y) {
        this();
        super.PositionSetzen(x, y);
    }
    
    public void Ausführen() {
        // Der Ball liegt
        if (y == 600-radius) {
            return;
        }
        // Der Ball faellt
        geschwindigkeit += BESCHLEUNIGUNG; // Beschleunigung
        int ny = y + (int)geschwindigkeit;
        if (ny >= 600-radius) { // Der Ball ist aufgeschlagen
            ny = 600-radius;
            geschwindigkeit = 0;
        }

        super.PositionSetzen(x, ny);
    }
    public void SonderTaste(int sondertaste) {}
    public void Taste(char taste) {}
    public void Geklickt(int x, int y , int anzahl) {}
}