diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2024-07-15 15:27:27 +0200 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2024-07-15 15:27:27 +0200 |
| commit | d95a61580feb5f548b5b5ae8a60f6f17c1639594 (patch) | |
| tree | 6251dc024c144b66a8a24859a04a1997cfd8f74e /Auto.java | |
| parent | a6b9d2c97bc1c8edbea516fd7071b7ad84d179c2 (diff) | |
| download | rennbahn-d95a61580feb5f548b5b5ae8a60f6f17c1639594.tar.gz rennbahn-d95a61580feb5f548b5b5ae8a60f6f17c1639594.zip | |
extend the car to explode wehen clicked mutliple times
Diffstat (limited to 'Auto.java')
| -rw-r--r-- | Auto.java | 21 |
1 files changed, 18 insertions, 3 deletions
@@ -21,6 +21,7 @@ public class Auto extends Actor pruefeTastatur(); bewegen(); pruefeKollision(); + pruefeMaus(); } @@ -77,9 +78,23 @@ public class Auto extends Actor void pruefeKollision() { if (isTouching(Rakete.class)) { - getWorld().addObject(new Explosion(), getX(), getY()); - removeTouching(Rakete.class); - getWorld().removeObject(this); + explodieren(); + } + } + + private void explodieren() { + getWorld().addObject(new Explosion(), getX(), getY()); + removeTouching(Rakete.class); + getWorld().removeObject(this); + } + + int clicked = 0; + private void pruefeMaus() { + if (Greenfoot.mouseClicked(this)) { + clicked++; + if (clicked == 3) { + explodieren(); + } } } } |
