Scale entity units to new board units.
Rename Brick.BLOCK_ to Brick.BRICK_
This commit is contained in:
parent
1fe82cb5b2
commit
409735d94e
@ -15,10 +15,10 @@ import java.util.Iterator;
|
|||||||
|
|
||||||
public class Ball extends Entity {
|
public class Ball extends Entity {
|
||||||
|
|
||||||
public static final int RADIUS = 12;
|
public static final int RADIUS = 45;
|
||||||
public static final Color BALL_COLOR = Color.CHARTREUSE;
|
public static final Color BALL_COLOR = Color.CHARTREUSE;
|
||||||
public static final float DEFAULT_SPEED = 350;
|
public static final float DEFAULT_SPEED = 1400;
|
||||||
public static final float BOOST_SPEED = 450;
|
public static final float BOOST_SPEED = 1800;
|
||||||
public static final int BLOCKS_FOR_BOOST = 39;
|
public static final int BLOCKS_FOR_BOOST = 39;
|
||||||
|
|
||||||
public Vector2 direction;
|
public Vector2 direction;
|
||||||
@ -101,7 +101,9 @@ public class Ball extends Entity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Vector2 paddleReflectAngle() {
|
public Vector2 paddleReflectAngle() {
|
||||||
float rel = MathUtils.clamp((pos.x - state.paddle.getX()) + (state.paddle.getWidth()/2), 5, state.paddle.getWidth()-5);
|
int trim = (int) (state.paddle.getWidth() * 0.10);
|
||||||
|
float rel = MathUtils.clamp((pos.x - state.paddle.getX()) + (state.paddle.getWidth()/2),
|
||||||
|
trim, state.paddle.getWidth()-trim);
|
||||||
float newAngle = MathUtils.PI - (MathUtils.PI * (rel / state.paddle.getWidth()));
|
float newAngle = MathUtils.PI - (MathUtils.PI * (rel / state.paddle.getWidth()));
|
||||||
return new Vector2(MathUtils.cos(newAngle), MathUtils.sin(newAngle));
|
return new Vector2(MathUtils.cos(newAngle), MathUtils.sin(newAngle));
|
||||||
}
|
}
|
||||||
|
@ -10,8 +10,8 @@ import com.me.brickbuster.state.PlayState;
|
|||||||
public class Brick extends Entity {
|
public class Brick extends Entity {
|
||||||
|
|
||||||
public static final Color BLOCK_COLOR = Color.FOREST;
|
public static final Color BLOCK_COLOR = Color.FOREST;
|
||||||
public static final int BLOCK_WIDTH = 50;
|
public static final int BRICK_WIDTH = 200;
|
||||||
public static final int BLOCK_HEIGHT = 20;
|
public static final int BRICK_HEIGHT = 100;
|
||||||
|
|
||||||
private Class<? extends PowerUp> powerUpType;
|
private Class<? extends PowerUp> powerUpType;
|
||||||
|
|
||||||
@ -23,9 +23,9 @@ public class Brick extends Entity {
|
|||||||
|
|
||||||
this.vertices = new Vector2[] {
|
this.vertices = new Vector2[] {
|
||||||
new Vector2(x, y),
|
new Vector2(x, y),
|
||||||
new Vector2(x + BLOCK_WIDTH, y),
|
new Vector2(x + BRICK_WIDTH, y),
|
||||||
new Vector2(x + BLOCK_WIDTH, y + BLOCK_HEIGHT),
|
new Vector2(x + BRICK_WIDTH, y + BRICK_HEIGHT),
|
||||||
new Vector2(x, y + BLOCK_HEIGHT)
|
new Vector2(x, y + BRICK_HEIGHT)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -33,7 +33,7 @@ public class Brick extends Entity {
|
|||||||
public void render(ShapeRenderer sr) {
|
public void render(ShapeRenderer sr) {
|
||||||
sr.begin(ShapeType.Filled);
|
sr.begin(ShapeType.Filled);
|
||||||
sr.setColor(BLOCK_COLOR);
|
sr.setColor(BLOCK_COLOR);
|
||||||
sr.rect(getX(), getY(), BLOCK_WIDTH, BLOCK_HEIGHT);
|
sr.rect(getX(), getY(), BRICK_WIDTH, BRICK_HEIGHT);
|
||||||
sr.end();
|
sr.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,10 +13,10 @@ import net.dermetfan.utils.Pair;
|
|||||||
public class Paddle extends Entity {
|
public class Paddle extends Entity {
|
||||||
|
|
||||||
public static final Color PADDLE_COLOR = Color.BLACK;
|
public static final Color PADDLE_COLOR = Color.BLACK;
|
||||||
public static final int DEFAULT_WIDTH = 100;
|
public static final int DEFAULT_WIDTH = 300;
|
||||||
public static final int PADDLE_HEIGHT = 10;
|
public static final int PADDLE_HEIGHT = 30;
|
||||||
public static final int PADDLE_Y = 15;
|
public static final int PADDLE_Y = 50;
|
||||||
public static final int PADDLE_SPEED = 375;
|
public static final int PADDLE_SPEED = 1500;
|
||||||
|
|
||||||
private int width = DEFAULT_WIDTH;
|
private int width = DEFAULT_WIDTH;
|
||||||
private boolean sticky = false;
|
private boolean sticky = false;
|
||||||
|
@ -13,8 +13,8 @@ public class LongerPaddlePowerUp extends PowerUp {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void activate() {
|
public void activate() {
|
||||||
if (state.paddle.getWidth() < 250) {
|
if (state.paddle.getWidth() < Paddle.DEFAULT_WIDTH*2.5) {
|
||||||
state.paddle.setWidth(state.paddle.getWidth() + 50);
|
state.paddle.setWidth(state.paddle.getWidth() + Paddle.DEFAULT_WIDTH/2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,14 +12,14 @@ import net.dermetfan.utils.Pair;
|
|||||||
|
|
||||||
public abstract class PowerUp extends Entity {
|
public abstract class PowerUp extends Entity {
|
||||||
|
|
||||||
public static final int RADIUS = 10;
|
public static final int RADIUS = 45;
|
||||||
public static final int FALL_SPEED = 100;
|
public static final int FALL_SPEED = 600;
|
||||||
|
|
||||||
private Color color;
|
private Color color;
|
||||||
private boolean isCaught;
|
private boolean isCaught;
|
||||||
|
|
||||||
public PowerUp(PlayState state, Brick brick, Color color) {
|
public PowerUp(PlayState state, Brick brick, Color color) {
|
||||||
super(state, brick.getX() + Brick.BLOCK_WIDTH/2, brick.getY() + Brick.BLOCK_HEIGHT/2);
|
super(state, brick.getX() + Brick.BRICK_WIDTH/2, brick.getY() + Brick.BRICK_HEIGHT/2);
|
||||||
this.color = color;
|
this.color = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,9 +14,12 @@ import java.util.*;
|
|||||||
|
|
||||||
public class PlayState extends State {
|
public class PlayState extends State {
|
||||||
|
|
||||||
public static final int SHIELD_HEIGHT = 5;
|
public static final int SHIELD_HEIGHT = 30;
|
||||||
public static final float POWERUP_CHANCE = 0.15f;
|
public static final float POWERUP_CHANCE = 0.15f;
|
||||||
|
|
||||||
|
public static final int COLUMNS = 9;
|
||||||
|
public static final int ROWS = 8;
|
||||||
|
|
||||||
public static final Map<Class<? extends PowerUp>, Integer> powerUpWeights;
|
public static final Map<Class<? extends PowerUp>, Integer> powerUpWeights;
|
||||||
private static final int weightSum;
|
private static final int weightSum;
|
||||||
|
|
||||||
@ -38,15 +41,18 @@ public class PlayState extends State {
|
|||||||
powerUps = new ArrayList<PowerUp>();
|
powerUps = new ArrayList<PowerUp>();
|
||||||
paddle = new Paddle(this);
|
paddle = new Paddle(this);
|
||||||
|
|
||||||
|
int brick_padding = (BrickBuster.BOARD_WIDTH - COLUMNS * Brick.BRICK_WIDTH) / (COLUMNS + 1);
|
||||||
bricks = new ArrayList<Brick>();
|
bricks = new ArrayList<Brick>();
|
||||||
for (int col = 0; col < 13; col++) {
|
for (int col = 0; col < COLUMNS; col++) {
|
||||||
for (int row = 0; row < 7; row++) {
|
for (int row = 0; row < ROWS; row++) {
|
||||||
int x = 15 + (col * (Brick.BLOCK_WIDTH + 10));
|
int x = brick_padding + (col * (Brick.BRICK_WIDTH + brick_padding));
|
||||||
int y = 15 + Brick.BLOCK_HEIGHT + (row * (Brick.BLOCK_HEIGHT + 10));
|
int y = brick_padding + Brick.BRICK_HEIGHT + (row * (Brick.BRICK_HEIGHT + brick_padding));
|
||||||
|
|
||||||
Class<? extends PowerUp> powerUpType = null;
|
Class<? extends PowerUp> powerUpType = null;
|
||||||
if (MathUtils.randomBoolean(POWERUP_CHANCE)) {
|
if (MathUtils.randomBoolean(POWERUP_CHANCE)) {
|
||||||
powerUpType = getWeightedPowerUp();
|
powerUpType = getWeightedPowerUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
bricks.add(new Brick(this, powerUpType, x, BrickBuster.BOARD_HEIGHT - y));
|
bricks.add(new Brick(this, powerUpType, x, BrickBuster.BOARD_HEIGHT - y));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -80,7 +86,7 @@ public class PlayState extends State {
|
|||||||
game.sb.begin();
|
game.sb.begin();
|
||||||
game.font.setColor(Color.GRAY);
|
game.font.setColor(Color.GRAY);
|
||||||
game.font.draw(game.sb, String.format("FPS: %d Update: %.2f ms Render: %.2f ms",
|
game.font.draw(game.sb, String.format("FPS: %d Update: %.2f ms Render: %.2f ms",
|
||||||
Gdx.graphics.getFramesPerSecond(), updateTime/1000000f, renderTime/1000000f), 0, 13);
|
Gdx.graphics.getFramesPerSecond(), updateTime/1000000f, renderTime/1000000f), 10, BrickBuster.BOARD_HEIGHT-10);
|
||||||
game.sb.end();
|
game.sb.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user