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) {
|
if (nearest.dst(new_pos.x, new_pos.y) <= RADIUS) {
|
||||||
brickIterator.remove();
|
brickIterator.remove();
|
||||||
brick.hit();
|
brick.hit();
|
||||||
if (getBrickBuster().getBricks().size() <= BLOCKS_FOR_BOOST) {
|
|
||||||
speed = BOOST_SPEED;
|
|
||||||
}
|
|
||||||
Utils.reflect(direction, segment.nor());
|
Utils.reflect(direction, segment.nor());
|
||||||
brickCollision = true;
|
brickCollision = true;
|
||||||
break;
|
break;
|
||||||
@ -126,6 +123,9 @@ public class Ball extends Entity {
|
|||||||
direction = paddleReflectAngle();
|
direction = paddleReflectAngle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setSpeed(float speed) {
|
||||||
|
this.speed = speed;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isStuck() {
|
public boolean isStuck() {
|
||||||
return isStuck;
|
return isStuck;
|
||||||
|
@ -40,6 +40,12 @@ public class Brick extends Entity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean hit() {
|
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) {
|
if (powerUpType != null) {
|
||||||
try {
|
try {
|
||||||
PowerUp powerUp = powerUpType.getConstructor(BrickBuster.class, Brick.class).newInstance(getBrickBuster(), this);
|
PowerUp powerUp = powerUpType.getConstructor(BrickBuster.class, Brick.class).newInstance(getBrickBuster(), this);
|
||||||
|
Loading…
Reference in New Issue
Block a user