Browse Source

HA08 abgeschlossen

master
fdai7303 2 years ago
parent
commit
d9c41c6e4b
  1. BIN
      GameProject.zip
  2. 36
      GameProject/src/playground/BreakoutLevel2.java

BIN
GameProject.zip

36
GameProject/src/playground/BreakoutLevel2.java

@ -40,10 +40,40 @@ public class BreakoutLevel2 extends BreakoutLevelBaseAdvanced {
@Override @Override
protected void actionIfBallHitsBrick(GameObject ball, GameObject brick) { protected void actionIfBallHitsBrick(GameObject ball, GameObject brick) {
for(int i = 0; i < 20; i++) { for(int i = 0; i < 20; i++) {
//Zufällige Farbe
gameobjects.FallingStar effect = new gameobjects.FallingStar("effect" + i, this, brick.getX(), brick.getY(), -240, 240, Color.RED, 3);
this.addObject(effect);
//Zufällige Geschwindigkeiten
int effectVX = (int)(Math.random() * 480) - 240;
int effectVY = (int)(Math.random() * 480) - 240;
//Fallingstarobject
// gameobjects.FallingStar effect = new gameobjects.FallingStar("effect" + i, this, brick.getX(), brick.getY(), effectVX, effectVY, Color.RED, 3);
// effect.addController(new controller.LimitedTimeController(getGameTime(), 2));
// this.addObject(effect);
double a = Math.random();
if(a <= 0.25) {
gameobjects.FallingStar effect0 = new gameobjects.FallingStar("effect" + i, this, brick.getX(), brick.getY(), effectVX, effectVY, Color.GREEN, 3);
effect0.addController(new controller.LimitedTimeController(getGameTime(), 2));
this.addObject(effect0);
}
if(a > 0.25 && a <= 0.5) {
gameobjects.FallingStar effect1 = new gameobjects.FallingStar("effect" + i, this, brick.getX(), brick.getY(), effectVX, effectVY, Color.BLUE, 3);
effect1.addController(new controller.LimitedTimeController(getGameTime(), 2));
this.addObject(effect1);
}
if(a > 0.5 && a <= 0.75) {
gameobjects.FallingStar effect2 = new gameobjects.FallingStar("effect" + i, this, brick.getX(), brick.getY(), effectVX, effectVY, Color.PINK, 3);
effect2.addController(new controller.LimitedTimeController(getGameTime(), 2));
this.addObject(effect2);
}
if(a > 0.75) {
gameobjects.FallingStar effect3 = new gameobjects.FallingStar("effect" + i, this, brick.getX(), brick.getY(), effectVX, effectVY, Color.YELLOW, 3);
effect3.addController(new controller.LimitedTimeController(getGameTime(), 2));
this.addObject(effect3);
}
} }
this.ball.setVY(this.ball.getVY()*-1); this.ball.setVY(this.ball.getVY()*-1);

Loading…
Cancel
Save