From 3fad2085b6e5dc79b8d0dbf46a9b0dd7fcd9a532 Mon Sep 17 00:00:00 2001 From: Matt Low Date: Tue, 13 Nov 2018 10:21:05 +0400 Subject: [PATCH] Refactor power up chance to be a variable --- core/src/com/me/brickbuster/BrickBuster.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/core/src/com/me/brickbuster/BrickBuster.java b/core/src/com/me/brickbuster/BrickBuster.java index 107874d..9fb6196 100644 --- a/core/src/com/me/brickbuster/BrickBuster.java +++ b/core/src/com/me/brickbuster/BrickBuster.java @@ -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, 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 powerUpType = null; - if (MathUtils.randomBoolean(0.15f)) { + if (MathUtils.randomBoolean(POWERUP_CHANCE)) { powerUpType = getWeightedPowerUp(); } bricks.add(new Brick(this, powerUpType, x, HEIGHT - y));