diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2024-07-12 23:07:39 +0200 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2024-07-12 23:13:11 +0200 |
| commit | 3b632e8a598bfcd75fd88d13e6d575996d98cf8b (patch) | |
| tree | 347b11cba6bbb7358ab1940c01a6f812a100814f /Schild.java | |
| download | spaceinvaders-3b632e8a598bfcd75fd88d13e6d575996d98cf8b.tar.gz spaceinvaders-3b632e8a598bfcd75fd88d13e6d575996d98cf8b.zip | |
initial commit
Diffstat (limited to 'Schild.java')
| -rw-r--r-- | Schild.java | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/Schild.java b/Schild.java new file mode 100644 index 0000000..2438356 --- /dev/null +++ b/Schild.java @@ -0,0 +1,27 @@ +import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot und MouseInfo) + +/** + * Ein Schild blockt Projektile und wird danach zerstoert. + */ +public class Schild extends Actor +{ + /** + * Act - prueft ob das Schild etwas anderes beruehrt. Diese Methode wird aufgerufen, + * sobald der 'Act' oder 'Run' Button in der Umgebung angeklickt werden. + */ + public void act() + { + pruefeKollision(); + } + + private void pruefeKollision() + { + if (isTouching(Lazer.class) || isTouching(Laser.class)) + { + removeTouching(Laser.class); + removeTouching(Lazer.class); + removeTouching(Schild.class); + getWorld().removeObject(this); // Zerstoere das Schild selbst + } + } +} |
