Refactor power up chance to be a variable
This commit is contained in:
parent
70ece88a89
commit
3fad2085b6
@ -20,11 +20,12 @@ public class BrickBuster extends ApplicationAdapter {
|
||||
public static final int HEIGHT = 600;
|
||||
public static final String TITLE = "Brick Buster";
|
||||
|
||||
public static final int SHIELD_HEIGHT = 5;
|
||||
|
||||
public static final Vector2 HORIZONTAL_EDGE = new Vector2(1, 0);
|
||||
public static final Vector2 VERTICAL_EDGE = new Vector2(0, 1);
|
||||
|
||||
public static final int SHIELD_HEIGHT = 5;
|
||||
public static final float POWERUP_CHANCE = 0.15f;
|
||||
|
||||
private static final Map<Class<? extends PowerUp>, Integer> powerUpWeights;
|
||||
private static final int weightSum;
|
||||
|
||||
@ -55,7 +56,7 @@ public class BrickBuster extends ApplicationAdapter {
|
||||
int x = 15 + (col * (Brick.BLOCK_WIDTH + 10));
|
||||
int y = 15 + Brick.BLOCK_HEIGHT + (row * (Brick.BLOCK_HEIGHT + 10));
|
||||
Class<? extends PowerUp> powerUpType = null;
|
||||
if (MathUtils.randomBoolean(0.15f)) {
|
||||
if (MathUtils.randomBoolean(POWERUP_CHANCE)) {
|
||||
powerUpType = getWeightedPowerUp();
|
||||
}
|
||||
bricks.add(new Brick(this, powerUpType, x, HEIGHT - y));
|
||||
|
Loading…
Reference in New Issue
Block a user