projects:spacedebris:aufgabe1:loesung:start
Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
Beide Seiten der vorigen RevisionVorhergehende ÜberarbeitungNächste Überarbeitung | Vorhergehende Überarbeitung | ||
projects:spacedebris:aufgabe1:loesung:start [2021/03/21 10:26] – Martin Pabst | projects:spacedebris:aufgabe1:loesung:start [2021/12/29 11:29] (aktuell) – Externe Bearbeitung 127.0.0.1 | ||
---|---|---|---|
Zeile 25: | Zeile 25: | ||
| | ||
- | |||
- | int ships = 3; | ||
- | Text shipsText; | ||
- | Text bigText; | ||
- | |||
- | | ||
- | int lastTimeFired = 0; | ||
- | |||
| | ||
super(); | super(); | ||
spaceship = new Spaceship(); | spaceship = new Spaceship(); | ||
- | shipsText = new Text(10, 10, 40, 3); | ||
- | bigText = new Text(400, 200, 80, "" | ||
- | bigText.setAlignment(Alignment.center); | ||
- | setZustand(" | ||
} | } | ||
| | ||
- | + | | |
- | if(isKeyDown(" | + | |
- | | + | |
- | setZustand(" | + | |
- | } else if(zustand == " | + | |
- | setZustand(" | + | |
- | } | + | |
- | } | + | |
- | + | ||
- | if(zustand != " | + | |
- | | + | |
- | } | + | |
if(Math.random() < debrisRate) { | if(Math.random() < debrisRate) { | ||
| | ||
Zeile 62: | Zeile 38: | ||
} | } | ||
- | if(isKeyDown(" | + | if(isKeyDown(" |
| | ||
| | ||
- | | ||
} | } | ||
- | |||
- | CollisionPair[] pairs = bullets.getCollisionPairs(debrisGroup, | ||
- | for(int i = 0; i < pairs.length; | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | } | ||
- | |||
- | Shape[] collidingDebris = debrisGroup.getCollidingShapes(spaceship); | ||
- | |||
- | for(int i = 0; i < collidingDebris.length; | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | setZustand(" | ||
- | } | ||
- | } | ||
- | |||
Zeile 94: | Zeile 47: | ||
- | void setZustand(String neuerZustand) { | ||
- | | ||
- | if(neuerZustand == " | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | } else if(neuerZustand == " | ||
- | | ||
- | | ||
- | ships = 3; | ||
- | | ||
- | } else if(neuerZustand == " | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | } | ||
- | zustand = neuerZustand; | ||
- | } | ||
} | } | ||
Zeile 138: | Zeile 69: | ||
</ | </ | ||
<script type=" | <script type=" | ||
+ | while(true) { | ||
+ | new Debris(); | ||
+ | } | ||
+ | |||
+ | |||
+ | |||
class Debris extends Rectangle { | class Debris extends Rectangle { | ||
Zeile 163: | Zeile 100: | ||
} | } | ||
- | void explode() { | ||
- | Sprite explosion = new Sprite(getCenterX(), | ||
- | explosion.scale(8 * getWidth() * getHeight() / 40000); | ||
- | explosion.playAnimation(0, | ||
- | Sound.playSound(Sound.far_bomb); | ||
- | } | ||
} | } |
projects/spacedebris/aufgabe1/loesung/start.1616318791.txt.gz · Zuletzt geändert: 2021/12/29 11:29 (Externe Bearbeitung)