From d3eb876960698598ec969f91f35f1ab483024e81 Mon Sep 17 00:00:00 2001 From: Matt Low Date: Mon, 12 Nov 2018 11:33:22 +0400 Subject: [PATCH] Refactor powerups, move to new package. Decrease long paddle chance to 8% --- core/src/com/me/brickbuster/BrickBuster.java | 5 ++++- core/src/com/me/brickbuster/entity/Brick.java | 1 + .../com/me/brickbuster/entity/{ => powerup}/GluePowerUp.java | 3 ++- .../entity/{ => powerup}/LongerPaddlePowerUp.java | 4 +++- .../src/com/me/brickbuster/entity/{ => powerup}/PowerUp.java | 4 +++- 5 files changed, 13 insertions(+), 4 deletions(-) rename core/src/com/me/brickbuster/entity/{ => powerup}/GluePowerUp.java (79%) rename core/src/com/me/brickbuster/entity/{ => powerup}/LongerPaddlePowerUp.java (77%) rename core/src/com/me/brickbuster/entity/{ => powerup}/PowerUp.java (91%) diff --git a/core/src/com/me/brickbuster/BrickBuster.java b/core/src/com/me/brickbuster/BrickBuster.java index e26f994..a515082 100644 --- a/core/src/com/me/brickbuster/BrickBuster.java +++ b/core/src/com/me/brickbuster/BrickBuster.java @@ -6,6 +6,9 @@ import com.badlogic.gdx.graphics.GL20; import com.badlogic.gdx.math.MathUtils; import com.badlogic.gdx.math.Vector2; import com.me.brickbuster.entity.*; +import com.me.brickbuster.entity.powerup.GluePowerUp; +import com.me.brickbuster.entity.powerup.LongerPaddlePowerUp; +import com.me.brickbuster.entity.powerup.PowerUp; import java.util.ArrayList; import java.util.Iterator; @@ -39,7 +42,7 @@ public class BrickBuster extends ApplicationAdapter { if (MathUtils.randomBoolean(0.08f)) { powerUpType = GluePowerUp.class; } - else if (MathUtils.randomBoolean(0.25f)) { + else if (MathUtils.randomBoolean(0.08f)) { powerUpType = LongerPaddlePowerUp.class; } bricks.add(new Brick(this, powerUpType, x, HEIGHT - y)); diff --git a/core/src/com/me/brickbuster/entity/Brick.java b/core/src/com/me/brickbuster/entity/Brick.java index f866239..29e3fa0 100644 --- a/core/src/com/me/brickbuster/entity/Brick.java +++ b/core/src/com/me/brickbuster/entity/Brick.java @@ -4,6 +4,7 @@ import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType; import com.badlogic.gdx.math.Vector2; import com.me.brickbuster.BrickBuster; +import com.me.brickbuster.entity.powerup.PowerUp; public class Brick extends Entity { public static final Color BLOCK_COLOR = Color.FOREST; diff --git a/core/src/com/me/brickbuster/entity/GluePowerUp.java b/core/src/com/me/brickbuster/entity/powerup/GluePowerUp.java similarity index 79% rename from core/src/com/me/brickbuster/entity/GluePowerUp.java rename to core/src/com/me/brickbuster/entity/powerup/GluePowerUp.java index c043c07..a61af04 100644 --- a/core/src/com/me/brickbuster/entity/GluePowerUp.java +++ b/core/src/com/me/brickbuster/entity/powerup/GluePowerUp.java @@ -1,7 +1,8 @@ -package com.me.brickbuster.entity; +package com.me.brickbuster.entity.powerup; import com.badlogic.gdx.graphics.Color; import com.me.brickbuster.BrickBuster; +import com.me.brickbuster.entity.Brick; public class GluePowerUp extends PowerUp { diff --git a/core/src/com/me/brickbuster/entity/LongerPaddlePowerUp.java b/core/src/com/me/brickbuster/entity/powerup/LongerPaddlePowerUp.java similarity index 77% rename from core/src/com/me/brickbuster/entity/LongerPaddlePowerUp.java rename to core/src/com/me/brickbuster/entity/powerup/LongerPaddlePowerUp.java index d2ad861..7b1825e 100644 --- a/core/src/com/me/brickbuster/entity/LongerPaddlePowerUp.java +++ b/core/src/com/me/brickbuster/entity/powerup/LongerPaddlePowerUp.java @@ -1,7 +1,9 @@ -package com.me.brickbuster.entity; +package com.me.brickbuster.entity.powerup; import com.badlogic.gdx.graphics.Color; import com.me.brickbuster.BrickBuster; +import com.me.brickbuster.entity.Brick; +import com.me.brickbuster.entity.Paddle; public class LongerPaddlePowerUp extends PowerUp { public LongerPaddlePowerUp(BrickBuster brickBuster, Brick brick) { diff --git a/core/src/com/me/brickbuster/entity/PowerUp.java b/core/src/com/me/brickbuster/entity/powerup/PowerUp.java similarity index 91% rename from core/src/com/me/brickbuster/entity/PowerUp.java rename to core/src/com/me/brickbuster/entity/powerup/PowerUp.java index c6258af..09dcef3 100644 --- a/core/src/com/me/brickbuster/entity/PowerUp.java +++ b/core/src/com/me/brickbuster/entity/powerup/PowerUp.java @@ -1,10 +1,12 @@ -package com.me.brickbuster.entity; +package com.me.brickbuster.entity.powerup; import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.glutils.ShapeRenderer; import com.badlogic.gdx.math.Vector2; import com.me.brickbuster.BrickBuster; import com.me.brickbuster.Utils; +import com.me.brickbuster.entity.Brick; +import com.me.brickbuster.entity.Entity; import net.dermetfan.utils.Pair; public abstract class PowerUp extends Entity {