Browse Source

well finished HA08

main
Nico B 2 years ago
parent
commit
bfa742d479
  1. 21
      GameProject/src/playground/BreakoutLevel2.java

21
GameProject/src/playground/BreakoutLevel2.java

@ -62,19 +62,9 @@ public class BreakoutLevel2 extends BreakoutLevelBaseAdvanced {
random = Color.GREEN;
}
double vx = Math.random();
if(vx <= 0.49) {
vx *= 240;
} else {
vx *= -240;
}
double vx = ((Math.random() * (240 - -240)) + -240);
double vy = ((Math.random() * (240 - -240)) + -240);
double vy = Math.random();
if(vy <= 0.49) {
vy *= 240;
} else {
vy *= -240;
}
FallingStar fragment = new FallingStar("fragment"+ i + getGameTime(), this, brick.getX(), brick.getY(), vx, vy, random, 5d);
LimitedTimeController time = new LimitedTimeController(getGameTime(), 2);
fragment.addController(time);
@ -88,11 +78,14 @@ public class BreakoutLevel2 extends BreakoutLevelBaseAdvanced {
@Override
protected void actionIfBallHitsEgo(GameObject ball, GameObject ego) {
if (ball.getVX() > 0 && ball.getX() <= ego.getX()- 25) {
RectObject ego1 = (RectObject) ego;
if (ball.getVX() > 0 && ball.getX() <= ego.getX() - ego1.getWidth() * 0.45) {
ball.setVX(ball.getVX() *-1);
ball.setVY(ball.getVY() * -1);
}
else if (ball.getVX() < 0 && ball.getX() >= ego.getX() + 25) {
else if (ball.getVX() < 0 && ball.getX() >= ego.getX() + ego1.getWidth() * 0.45) {
ball.setVX(ball.getVX() * -1);
ball.setVY(ball.getVY() * -1);
}

Loading…
Cancel
Save