Move ball speed boost check to Brick's hit() method
This commit is contained in:
parent
1ee5a5a36c
commit
e1c7fbb53f
@ -63,9 +63,6 @@ public class Ball extends Entity {
|
||||
if (nearest.dst(new_pos.x, new_pos.y) <= RADIUS) {
|
||||
brickIterator.remove();
|
||||
brick.hit();
|
||||
if (getBrickBuster().getBricks().size() <= BLOCKS_FOR_BOOST) {
|
||||
speed = BOOST_SPEED;
|
||||
}
|
||||
Utils.reflect(direction, segment.nor());
|
||||
brickCollision = true;
|
||||
break;
|
||||
@ -126,6 +123,9 @@ public class Ball extends Entity {
|
||||
direction = paddleReflectAngle();
|
||||
}
|
||||
|
||||
public void setSpeed(float speed) {
|
||||
this.speed = speed;
|
||||
}
|
||||
|
||||
public boolean isStuck() {
|
||||
return isStuck;
|
||||
|
@ -40,6 +40,12 @@ public class Brick extends Entity {
|
||||
}
|
||||
|
||||
public boolean hit() {
|
||||
if (getBrickBuster().getBricks().size()-1 <= Ball.BLOCKS_FOR_BOOST) {
|
||||
for (Ball ball : getBrickBuster().getBalls()) {
|
||||
ball.setSpeed(Ball.BOOST_SPEED);
|
||||
}
|
||||
}
|
||||
|
||||
if (powerUpType != null) {
|
||||
try {
|
||||
PowerUp powerUp = powerUpType.getConstructor(BrickBuster.class, Brick.class).newInstance(getBrickBuster(), this);
|
||||
|
Loading…
Reference in New Issue
Block a user