Compare commits
No commits in common. "dev" and "master" have entirely different histories.
@ -1,5 +1,4 @@
|
|||||||
{
|
{
|
||||||
randomPowerUpChance: 0.15
|
|
||||||
bricks: [
|
bricks: [
|
||||||
{
|
{
|
||||||
row: 15
|
row: 15
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
{
|
{
|
||||||
randomPowerUpChance: 0.15
|
|
||||||
bricks: [
|
bricks: [
|
||||||
{
|
{
|
||||||
row: 5
|
row: 5
|
||||||
|
@ -177,8 +177,4 @@ public class Ball extends Entity implements PhysicsBody, CollisionListener {
|
|||||||
return isStuck;
|
return isStuck;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setStuck(boolean isStuck) {
|
|
||||||
this.isStuck = isStuck;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -165,11 +165,6 @@ public class Brick extends Entity implements PhysicsBody, CollisionListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float powerUpChance = ((PlayState) state).currentLevel.getRandomPowerUpChance();
|
|
||||||
if (powerUpType == null && powerUpChance > 0f && MathUtils.randomBoolean(powerUpChance)) {
|
|
||||||
powerUpType = PowerUpType.getWeightedRandom();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (powerUpType != null) {
|
if (powerUpType != null) {
|
||||||
((PlayState) state).powerUps.add(powerUpType.createInstance((PlayState) state, this));
|
((PlayState) state).powerUps.add(powerUpType.createInstance((PlayState) state, this));
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ public abstract class Entity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setPos(Vector2 pos) {
|
public void setPos(Vector2 pos) {
|
||||||
this.pos.set(pos);
|
this.pos = pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getX() {
|
public float getX() {
|
||||||
|
@ -3,7 +3,6 @@ package com.me.brickbuster.entity.powerup;
|
|||||||
import com.badlogic.gdx.graphics.Color;
|
import com.badlogic.gdx.graphics.Color;
|
||||||
import com.badlogic.gdx.math.MathUtils;
|
import com.badlogic.gdx.math.MathUtils;
|
||||||
import com.badlogic.gdx.math.Vector2;
|
import com.badlogic.gdx.math.Vector2;
|
||||||
import com.badlogic.gdx.utils.Array;
|
|
||||||
import com.me.brickbuster.entity.Ball;
|
import com.me.brickbuster.entity.Ball;
|
||||||
import com.me.brickbuster.entity.Paddle;
|
import com.me.brickbuster.entity.Paddle;
|
||||||
import com.me.brickbuster.state.PlayState;
|
import com.me.brickbuster.state.PlayState;
|
||||||
@ -11,7 +10,6 @@ import com.me.brickbuster.state.PlayState;
|
|||||||
public class MultiBallPowerUp extends PowerUp {
|
public class MultiBallPowerUp extends PowerUp {
|
||||||
|
|
||||||
private Vector2 pos;
|
private Vector2 pos;
|
||||||
private static final Array<Ball> ballsToAdd = new Array<Ball>();
|
|
||||||
|
|
||||||
public MultiBallPowerUp(PlayState state, Vector2 brick, Color color) {
|
public MultiBallPowerUp(PlayState state, Vector2 brick, Color color) {
|
||||||
super(state, brick, color);
|
super(state, brick, color);
|
||||||
@ -20,26 +18,10 @@ public class MultiBallPowerUp extends PowerUp {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void activate() {
|
public void activate() {
|
||||||
final Array<Ball> existing = ((PlayState) state).balls;
|
|
||||||
if (existing.size >= 3) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (Ball b : existing) {
|
|
||||||
Vector2 velocity = b.getBody().getLinearVelocity();
|
|
||||||
velocity.setAngleRad(velocity.angleRad() - MathUtils.PI/8);
|
|
||||||
|
|
||||||
for (int x = 0; x < 2; x++) {
|
for (int x = 0; x < 2; x++) {
|
||||||
Ball ball = new Ball((PlayState) state);
|
Ball ball = new Ball((PlayState) state);
|
||||||
ball.setX(b.getX());
|
ball.launch();
|
||||||
ball.setY(b.getY());
|
((PlayState) state).balls.add(ball);
|
||||||
ball.setStuck(false);
|
|
||||||
ball.getBody().setLinearVelocity(velocity);
|
|
||||||
ballsToAdd.add(ball);
|
|
||||||
velocity.setAngleRad(velocity.angleRad() + MathUtils.PI/4);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
existing.addAll(ballsToAdd);
|
|
||||||
ballsToAdd.clear();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,26 +1,30 @@
|
|||||||
package com.me.brickbuster.layout;
|
package com.me.brickbuster.layout;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.files.FileHandle;
|
||||||
import com.badlogic.gdx.utils.Array;
|
import com.badlogic.gdx.utils.Array;
|
||||||
|
import com.badlogic.gdx.utils.Json;
|
||||||
import com.me.brickbuster.entity.Brick;
|
import com.me.brickbuster.entity.Brick;
|
||||||
import com.me.brickbuster.state.FieldState;
|
|
||||||
import com.me.brickbuster.state.PlayState;
|
import com.me.brickbuster.state.PlayState;
|
||||||
|
|
||||||
public class FileLayout implements BrickLayout {
|
public class FileLayout implements BrickLayout {
|
||||||
|
|
||||||
private FieldState state;
|
private static final Json JSON = new Json();
|
||||||
private LevelJsonTemplate template;
|
|
||||||
private Array<Brick> bricks;
|
|
||||||
|
|
||||||
public FileLayout(FieldState state, LevelJsonTemplate template) {
|
private PlayState state;
|
||||||
|
private Array<Brick> bricks;
|
||||||
|
private FileHandle file;
|
||||||
|
|
||||||
|
public FileLayout(PlayState state, FileHandle file) {
|
||||||
this.state = state;
|
this.state = state;
|
||||||
this.template = template;
|
this.file = file;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
bricks = new Array<Brick>();
|
bricks = new Array<Brick>();
|
||||||
|
|
||||||
for (LevelJsonTemplate.BrickJsonTemplate brick : template.bricks) {
|
LevelJsonTemplate level = JSON.fromJson(LevelJsonTemplate.class, file);
|
||||||
|
for (LevelJsonTemplate.BrickJsonTemplate brick : level.bricks) {
|
||||||
final float x = PlayState.EDGE_PADDING + Brick.BRICK_WIDTH/2 + brick.col * Brick.BRICK_WIDTH;
|
final float x = PlayState.EDGE_PADDING + Brick.BRICK_WIDTH/2 + brick.col * Brick.BRICK_WIDTH;
|
||||||
final float y = PlayState.EDGE_PADDING + Brick.BRICK_HEIGHT/2 + brick.row * Brick.BRICK_HEIGHT;
|
final float y = PlayState.EDGE_PADDING + Brick.BRICK_HEIGHT/2 + brick.row * Brick.BRICK_HEIGHT;
|
||||||
|
|
||||||
|
@ -2,19 +2,14 @@ package com.me.brickbuster.layout;
|
|||||||
|
|
||||||
import com.badlogic.gdx.Gdx;
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.files.FileHandle;
|
import com.badlogic.gdx.files.FileHandle;
|
||||||
import com.badlogic.gdx.graphics.Texture;
|
|
||||||
import com.badlogic.gdx.utils.Json;
|
|
||||||
import com.me.brickbuster.state.FieldState;
|
|
||||||
import com.me.brickbuster.state.PlayState;
|
import com.me.brickbuster.state.PlayState;
|
||||||
|
|
||||||
public class FileLevelLoader implements LevelLoader {
|
public class FileLevelLoader implements LevelLoader {
|
||||||
|
|
||||||
private static final Json JSON = new Json();
|
private PlayState state;
|
||||||
|
|
||||||
private FieldState state;
|
|
||||||
private int level = 1;
|
private int level = 1;
|
||||||
|
|
||||||
public FileLevelLoader(FieldState state) {
|
public FileLevelLoader(PlayState state) {
|
||||||
this.state = state;
|
this.state = state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -22,15 +17,8 @@ public class FileLevelLoader implements LevelLoader {
|
|||||||
public Level getNextLevel() {
|
public Level getNextLevel() {
|
||||||
FileHandle file = Gdx.files.internal("levels/level_" + level + ".json");
|
FileHandle file = Gdx.files.internal("levels/level_" + level + ".json");
|
||||||
if (file.exists()) {
|
if (file.exists()) {
|
||||||
LevelJsonTemplate template = JSON.fromJson(LevelJsonTemplate.class, file);
|
|
||||||
|
|
||||||
Texture background = null;
|
|
||||||
if (template.backgroundFile != null && !"".equals(template.backgroundFile)) {
|
|
||||||
background = new Texture(Gdx.files.internal(template.backgroundFile));
|
|
||||||
}
|
|
||||||
|
|
||||||
level++;
|
level++;
|
||||||
return new Level(new FileLayout(state, template), background, template.randomPowerUpChance);
|
return new Level(new FileLayout(state, file), null, null);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -6,16 +6,16 @@ public class Level {
|
|||||||
|
|
||||||
private final BrickLayout layout;
|
private final BrickLayout layout;
|
||||||
private final Texture background;
|
private final Texture background;
|
||||||
private final float randomPowerUpChance;
|
private final Texture border;
|
||||||
|
|
||||||
public Level(BrickLayout layout) {
|
public Level(BrickLayout layout) {
|
||||||
this(layout, null, 0f);
|
this(layout, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Level(BrickLayout layout, Texture background, float randomPowerUpChance) {
|
public Level(BrickLayout layout, Texture background, Texture border) {
|
||||||
this.layout = layout;
|
this.layout = layout;
|
||||||
this.background = background;
|
this.background = background;
|
||||||
this.randomPowerUpChance = randomPowerUpChance;
|
this.border = border;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BrickLayout getLayout() {
|
public BrickLayout getLayout() {
|
||||||
@ -26,8 +26,8 @@ public class Level {
|
|||||||
return background;
|
return background;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getRandomPowerUpChance() {
|
public Texture getBorder() {
|
||||||
return randomPowerUpChance;
|
return border;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ import java.util.List;
|
|||||||
public class LevelJsonTemplate {
|
public class LevelJsonTemplate {
|
||||||
|
|
||||||
public String backgroundFile;
|
public String backgroundFile;
|
||||||
public float randomPowerUpChance;
|
public String borderFile;
|
||||||
public List<BrickJsonTemplate> bricks;
|
public List<BrickJsonTemplate> bricks;
|
||||||
|
|
||||||
public static class BrickJsonTemplate {
|
public static class BrickJsonTemplate {
|
||||||
|
@ -24,7 +24,7 @@ public abstract class FieldState extends State {
|
|||||||
@Override
|
@Override
|
||||||
public void dispose() {
|
public void dispose() {
|
||||||
super.dispose();
|
super.dispose();
|
||||||
game.assets.unload("textures.atlas");
|
textures.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@ package com.me.brickbuster.state;
|
|||||||
|
|
||||||
import com.badlogic.gdx.Gdx;
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.Input;
|
import com.badlogic.gdx.Input;
|
||||||
import com.badlogic.gdx.graphics.Color;
|
|
||||||
import com.badlogic.gdx.graphics.Texture;
|
import com.badlogic.gdx.graphics.Texture;
|
||||||
import com.badlogic.gdx.math.Vector3;
|
import com.badlogic.gdx.math.Vector3;
|
||||||
import com.me.brickbuster.BrickBuster;
|
import com.me.brickbuster.BrickBuster;
|
||||||
@ -24,7 +23,6 @@ public class MenuState extends State {
|
|||||||
public void render() {
|
public void render() {
|
||||||
game.sb.setProjectionMatrix(game.cam.combined);
|
game.sb.setProjectionMatrix(game.cam.combined);
|
||||||
game.sb.begin();
|
game.sb.begin();
|
||||||
game.sb.setColor(Color.WHITE);
|
|
||||||
game.sb.draw(playButton,
|
game.sb.draw(playButton,
|
||||||
BrickBuster.BOARD_WIDTH/2-playButton.getWidth()/2,
|
BrickBuster.BOARD_WIDTH/2-playButton.getWidth()/2,
|
||||||
BrickBuster.BOARD_HEIGHT/2-playButton.getHeight()/2);
|
BrickBuster.BOARD_HEIGHT/2-playButton.getHeight()/2);
|
||||||
|
Loading…
Reference in New Issue
Block a user