Allow shields to stack.
Refactor Ball.render to keep a local instance of BrickBuster
This commit is contained in:
@ -37,7 +37,7 @@ public class BrickBuster extends ApplicationAdapter {
|
||||
private ArrayList<Brick> bricks;
|
||||
private ArrayList<PowerUp> powerUps;
|
||||
|
||||
private boolean shieldActive = false;
|
||||
private int shieldCount = 0;
|
||||
|
||||
@Override
|
||||
public void create () {
|
||||
@ -88,10 +88,10 @@ public class BrickBuster extends ApplicationAdapter {
|
||||
}
|
||||
paddle.render(sr);
|
||||
|
||||
if (shieldActive) {
|
||||
if (getShieldCount() > 0) {
|
||||
sr.begin(ShapeRenderer.ShapeType.Filled);
|
||||
sr.setColor(Color.SALMON);
|
||||
sr.rect(0, 0, WIDTH, SHIELD_HEIGHT);
|
||||
sr.rect(0, 0, WIDTH, getShieldCount() * SHIELD_HEIGHT);
|
||||
sr.end();
|
||||
}
|
||||
|
||||
@ -157,12 +157,18 @@ public class BrickBuster extends ApplicationAdapter {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setShieldActive(boolean shieldActive) {
|
||||
this.shieldActive = shieldActive;
|
||||
public int getShieldCount() {
|
||||
return shieldCount;
|
||||
}
|
||||
|
||||
public boolean isShieldActive() {
|
||||
return shieldActive;
|
||||
public void addShield() {
|
||||
shieldCount++;
|
||||
paddle.setY(paddle.getY() + SHIELD_HEIGHT);
|
||||
}
|
||||
|
||||
public void removeShield() {
|
||||
shieldCount--;
|
||||
paddle.setY(paddle.getY() - SHIELD_HEIGHT);
|
||||
}
|
||||
|
||||
public ArrayList<Ball> getBalls() {
|
||||
|
Reference in New Issue
Block a user