From e2c0bad9e0c8e2bf0b4b1993856a75a985767e0f Mon Sep 17 00:00:00 2001 From: Matt Low Date: Tue, 13 Nov 2018 18:58:55 +0400 Subject: [PATCH] Altered powerup weights (decreased glue, increased multi ball) Allow bricks to have their colour changed. --- core/src/com/me/brickbuster/entity/Brick.java | 16 ++++++++++++---- .../brickbuster/entity/powerup/PowerUpType.java | 4 ++-- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/core/src/com/me/brickbuster/entity/Brick.java b/core/src/com/me/brickbuster/entity/Brick.java index 8092e84..504a569 100644 --- a/core/src/com/me/brickbuster/entity/Brick.java +++ b/core/src/com/me/brickbuster/entity/Brick.java @@ -4,24 +4,32 @@ import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.glutils.ShapeRenderer; import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType; import com.badlogic.gdx.math.Vector2; -import com.me.brickbuster.entity.powerup.PowerUp; import com.me.brickbuster.entity.powerup.PowerUpType; import com.me.brickbuster.state.PlayState; public class Brick extends Entity { - public static final Color BLOCK_COLOR = Color.FOREST; + public static final Color DEFAULT_COLOR = Color.FOREST; public static final int BRICK_WIDTH = 200; public static final int BRICK_HEIGHT = 100; private PowerUpType powerUpType; + private Color color; private Vector2[] vertices; public Brick(PlayState state, PowerUpType powerUpType, int x, int y) { + this(state, powerUpType, true, x, y); + } + + public Brick(PlayState state, PowerUpType powerUpType, boolean hidePowerup, int x, int y) { + this(state, powerUpType, DEFAULT_COLOR, hidePowerup, x, y); + } + + public Brick(PlayState state, PowerUpType powerUpType, Color color, boolean hidePowerUp, int x, int y) { super(state, x, y); this.powerUpType = powerUpType; - + this.color = powerUpType != null && !hidePowerUp? powerUpType.getColor() : color; this.vertices = new Vector2[] { new Vector2(x, y), new Vector2(x + BRICK_WIDTH, y), @@ -33,7 +41,7 @@ public class Brick extends Entity { @Override public void render(ShapeRenderer sr) { sr.begin(ShapeType.Filled); - sr.setColor(BLOCK_COLOR); + sr.setColor(color); sr.rect(getX(), getY(), BRICK_WIDTH, BRICK_HEIGHT); sr.end(); } diff --git a/core/src/com/me/brickbuster/entity/powerup/PowerUpType.java b/core/src/com/me/brickbuster/entity/powerup/PowerUpType.java index 284ff40..415dbcb 100644 --- a/core/src/com/me/brickbuster/entity/powerup/PowerUpType.java +++ b/core/src/com/me/brickbuster/entity/powerup/PowerUpType.java @@ -8,9 +8,9 @@ import com.me.brickbuster.state.PlayState; public enum PowerUpType { - GLUE(GluePowerUp.class, Color.WHITE, 30), + GLUE(GluePowerUp.class, Color.WHITE, 20), LONGER_PADDLE(LongerPaddlePowerUp.class, Color.OLIVE, 40), - MULTI_BALL(MultiBallPowerUp.class, Color.ROYAL, 20), + MULTI_BALL(MultiBallPowerUp.class, Color.ROYAL, 30), SHIELD(ShieldPowerUp.class, Color.SALMON, 40), ;