|
|
@ -40,10 +40,40 @@ public class BreakoutLevel2 extends BreakoutLevelBaseAdvanced { |
|
|
|
|
|
|
|
@Override |
|
|
|
protected void actionIfBallHitsBrick(GameObject ball, GameObject brick) { |
|
|
|
|
|
|
|
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); |
|
|
|