diff --git a/core/src/com/me/brickbuster/entity/Brick.java b/core/src/com/me/brickbuster/entity/Brick.java index a385d02..59edee9 100644 --- a/core/src/com/me/brickbuster/entity/Brick.java +++ b/core/src/com/me/brickbuster/entity/Brick.java @@ -4,7 +4,6 @@ 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.MathUtils; -import com.badlogic.gdx.math.Rectangle; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.physics.box2d.Body; import com.badlogic.gdx.physics.box2d.BodyDef; @@ -47,8 +46,9 @@ public class Brick extends Entity implements PhysicsBody, CollisionListener { public void render(ShapeRenderer sr) { sr.begin(ShapeType.Filled); sr.setColor(color); - sr.rect(pos.x * PlayState.PIXEL_PER_METER, pos.y * PlayState.PIXEL_PER_METER, - 0f, 0f, + sr.rect((pos.x - BRICK_WIDTH/2) * PlayState.PIXEL_PER_METER, + (pos.y - BRICK_HEIGHT/2) * PlayState.PIXEL_PER_METER, + BRICK_WIDTH/2 * PlayState.PIXEL_PER_METER, BRICK_HEIGHT/2 * PlayState.PIXEL_PER_METER, BRICK_WIDTH * PlayState.PIXEL_PER_METER, BRICK_HEIGHT * PlayState.PIXEL_PER_METER, 1f, 1f, body.getAngle() * MathUtils.radiansToDegrees); @@ -76,7 +76,7 @@ public class Brick extends Entity implements PhysicsBody, CollisionListener { PolygonShape brickShape = new PolygonShape(); brickShape.setAsBox(BRICK_WIDTH/2, BRICK_HEIGHT/2, - new Vector2(BRICK_WIDTH/2,BRICK_HEIGHT/2), 0); + Vector2.Zero, 0); FixtureDef brickFixture = new FixtureDef(); brickFixture.shape = brickShape; diff --git a/core/src/com/me/brickbuster/entity/powerup/PowerUpType.java b/core/src/com/me/brickbuster/entity/powerup/PowerUpType.java index 415dbcb..7003392 100644 --- a/core/src/com/me/brickbuster/entity/powerup/PowerUpType.java +++ b/core/src/com/me/brickbuster/entity/powerup/PowerUpType.java @@ -42,9 +42,7 @@ public enum PowerUpType { } public PowerUp createInstance(PlayState state, Brick brick) { - return createInstance(state, - new Vector2(brick.getX()+Brick.BRICK_WIDTH/2, - brick.getY()+Brick.BRICK_HEIGHT/2)); + return createInstance(state, new Vector2(brick.getX(), brick.getY())); } public PowerUp createInstance(PlayState state, Vector2 pos) { diff --git a/core/src/com/me/brickbuster/state/PlayState.java b/core/src/com/me/brickbuster/state/PlayState.java index 9e68fad..7738d40 100644 --- a/core/src/com/me/brickbuster/state/PlayState.java +++ b/core/src/com/me/brickbuster/state/PlayState.java @@ -95,19 +95,19 @@ public class PlayState extends State { powerUps = new Array(); paddle = new Paddle(this); - float brick_padding = ((BrickBuster.BOARD_WIDTH/PIXEL_PER_METER) - COLUMNS * Brick.BRICK_WIDTH) / (COLUMNS + 1); + float brick_padding = (BOARD_WIDTH - COLUMNS * Brick.BRICK_WIDTH) / (COLUMNS + 1); bricks = new Array(); for (int col = 0; col < COLUMNS; col++) { - for (int row = 0; row < ROWS; row++) { - float x = brick_padding + (col * (Brick.BRICK_WIDTH + brick_padding)); - float y = brick_padding + Brick.BRICK_HEIGHT + (row * (Brick.BRICK_HEIGHT + brick_padding)); + for (int row = ROWS-1; row >= 0; row--) { + float x = brick_padding + Brick.BRICK_WIDTH/2 + (col * (Brick.BRICK_WIDTH + brick_padding)); + float y = brick_padding + Brick.BRICK_HEIGHT/2 + (row * (Brick.BRICK_HEIGHT + brick_padding)); PowerUpType powerUpType = null; if (MathUtils.randomBoolean(POWERUP_CHANCE)) { powerUpType = PowerUpType.getWeightedRandom(); } - bricks.add(new Brick(this, powerUpType, x, BrickBuster.BOARD_HEIGHT/PIXEL_PER_METER - y)); + bricks.add(new Brick(this, powerUpType, x, BOARD_HEIGHT - y)); } }