Refactor Block to Brick
This commit is contained in:
parent
053ec9829f
commit
81fc6e91c9
@ -5,7 +5,7 @@ import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.graphics.GL20;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import com.me.brickbuster.entity.Ball;
|
||||
import com.me.brickbuster.entity.Block;
|
||||
import com.me.brickbuster.entity.Brick;
|
||||
import com.me.brickbuster.entity.Paddle;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -21,19 +21,19 @@ public class BrickBuster extends ApplicationAdapter {
|
||||
|
||||
private Ball ball;
|
||||
private Paddle paddle;
|
||||
private ArrayList<Block> blocks;
|
||||
private ArrayList<Brick> bricks;
|
||||
private boolean playing = false;
|
||||
|
||||
@Override
|
||||
public void create () {
|
||||
ball = new Ball(this);
|
||||
paddle = new Paddle(this);
|
||||
blocks = new ArrayList<Block>();
|
||||
bricks = new ArrayList<Brick>();
|
||||
for (int col = 0; col < 13; col++) {
|
||||
for (int row = 0; row < 10; row++) {
|
||||
int x = 15 + (col * (Block.BLOCK_WIDTH + 10));
|
||||
int y = 15 + Block.BLOCK_HEIGHT + (row * (Block.BLOCK_HEIGHT + 5));
|
||||
blocks.add(new Block(this, x, HEIGHT - y));
|
||||
int x = 15 + (col * (Brick.BLOCK_WIDTH + 10));
|
||||
int y = 15 + Brick.BLOCK_HEIGHT + (row * (Brick.BLOCK_HEIGHT + 5));
|
||||
bricks.add(new Brick(this, x, HEIGHT - y));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -45,7 +45,7 @@ public class BrickBuster extends ApplicationAdapter {
|
||||
Gdx.gl.glClearColor(0.5f,1,1,1);
|
||||
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
||||
|
||||
for (Block block : blocks) {
|
||||
for (Brick block : bricks) {
|
||||
block.render();
|
||||
}
|
||||
|
||||
@ -82,7 +82,7 @@ public class BrickBuster extends ApplicationAdapter {
|
||||
return paddle;
|
||||
}
|
||||
|
||||
public ArrayList<Block> getBlocks() {
|
||||
return blocks;
|
||||
public ArrayList<Brick> getBricks() {
|
||||
return bricks;
|
||||
}
|
||||
}
|
||||
|
@ -4,12 +4,12 @@ import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType;
|
||||
import com.me.brickbuster.BrickBuster;
|
||||
|
||||
public class Block extends Entity {
|
||||
public class Brick extends Entity {
|
||||
public static final Color BLOCK_COLOR = Color.FOREST;
|
||||
public static final int BLOCK_WIDTH = 50;
|
||||
public static final int BLOCK_HEIGHT = 15;
|
||||
|
||||
public Block(BrickBuster brickBuster, int x, int y) {
|
||||
public Brick(BrickBuster brickBuster, int x, int y) {
|
||||
super(brickBuster, x, y);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user