Render bricks and ball using sprites instead of constructed polygons
Changed field width to 10 blocks instead of 11
BIN
core/assets/sprites/ball.png
Normal file
After Width: | Height: | Size: 12 KiB |
BIN
core/assets/sprites/brick_DIAMOND.png
Normal file
After Width: | Height: | Size: 1013 B |
BIN
core/assets/sprites/brick_DOWN_LEFT_TRIANGLE.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
core/assets/sprites/brick_DOWN_RIGHT_TRIANGLE.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
core/assets/sprites/brick_DOWN_TRIANGLE.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
core/assets/sprites/brick_FULL_DOWN_LEFT_TRIANGLE.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
core/assets/sprites/brick_FULL_HALF_DOWN_TRIANGLE.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
core/assets/sprites/brick_FULL_HALF_LEFT_TRIANGLE.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
core/assets/sprites/brick_FULL_HALF_RIGHT_TRIANGLE.png
Normal file
After Width: | Height: | Size: 963 B |
BIN
core/assets/sprites/brick_FULL_HALF_UP_TRIANGLE.png
Normal file
After Width: | Height: | Size: 1.0 KiB |
BIN
core/assets/sprites/brick_FULL_LEFT_DOWN_RIGHT_TRIANGLE.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
core/assets/sprites/brick_FULL_LEFT_UP_RIGHT_TRIANGLE.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
core/assets/sprites/brick_FULL_UP_LEFT_TRIANGLE.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
core/assets/sprites/brick_HALF_DOWN_TRIANGLE.png
Normal file
After Width: | Height: | Size: 1.0 KiB |
BIN
core/assets/sprites/brick_HALF_LEFT_SQUARE.png
Normal file
After Width: | Height: | Size: 730 B |
BIN
core/assets/sprites/brick_HALF_LEFT_TRIANGLE.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
core/assets/sprites/brick_HALF_LOWER_RECTANGLE.png
Normal file
After Width: | Height: | Size: 678 B |
BIN
core/assets/sprites/brick_HALF_RIGHT_SQUARE.png
Normal file
After Width: | Height: | Size: 732 B |
BIN
core/assets/sprites/brick_HALF_RIGHT_TRIANGLE.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
core/assets/sprites/brick_HALF_UPPER_RECTANGLE.png
Normal file
After Width: | Height: | Size: 683 B |
BIN
core/assets/sprites/brick_HALF_UP_TRIANGLE.png
Normal file
After Width: | Height: | Size: 1.0 KiB |
BIN
core/assets/sprites/brick_LEFT_DOWN_LEFT_TRIANGLE.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
core/assets/sprites/brick_LEFT_DOWN_RIGHT_TRIANGLE.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
core/assets/sprites/brick_LEFT_TRIANGLE.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
core/assets/sprites/brick_LEFT_UP_LEFT_TRIANGLE.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
core/assets/sprites/brick_LEFT_UP_RIGHT_TRIANGLE.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
core/assets/sprites/brick_RECTANGLE.png
Normal file
After Width: | Height: | Size: 534 B |
BIN
core/assets/sprites/brick_RIGHT_DOWN_LEFT_TRIANGLE.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
core/assets/sprites/brick_RIGHT_DOWN_RIGHT_TRIANGLE.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
core/assets/sprites/brick_RIGHT_TRIANGLE.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
core/assets/sprites/brick_RIGHT_UP_LEFT_TRIANGLE.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
core/assets/sprites/brick_RIGHT_UP_RIGHT_TRIANGLE.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
core/assets/sprites/brick_UP_LEFT_TRIANGLE.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
core/assets/sprites/brick_UP_RIGHT_TRIANGLE.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
core/assets/sprites/brick_UP_TRIANGLE.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
257
core/assets/textures.atlas
Normal file
@ -0,0 +1,257 @@
|
||||
|
||||
textures.png
|
||||
size: 1024,1024
|
||||
format: RGBA8888
|
||||
filter: MipMapLinearLinear,MipMapLinearLinear
|
||||
repeat: none
|
||||
ball
|
||||
rotate: false
|
||||
xy: 800, 824
|
||||
size: 128, 128
|
||||
orig: 128, 128
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
brick_DIAMOND
|
||||
rotate: false
|
||||
xy: 8, 824
|
||||
size: 256, 128
|
||||
orig: 256, 128
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
brick_DOWN_LEFT_TRIANGLE
|
||||
rotate: false
|
||||
xy: 8, 688
|
||||
size: 256, 128
|
||||
orig: 256, 128
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
brick_DOWN_RIGHT_TRIANGLE
|
||||
rotate: false
|
||||
xy: 272, 824
|
||||
size: 256, 128
|
||||
orig: 256, 128
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
brick_DOWN_TRIANGLE
|
||||
rotate: false
|
||||
xy: 8, 552
|
||||
size: 256, 128
|
||||
orig: 256, 128
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
brick_FULL_DOWN_LEFT_TRIANGLE
|
||||
rotate: false
|
||||
xy: 272, 688
|
||||
size: 256, 128
|
||||
orig: 256, 128
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
brick_FULL_HALF_DOWN_TRIANGLE
|
||||
rotate: false
|
||||
xy: 536, 824
|
||||
size: 256, 128
|
||||
orig: 256, 128
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
brick_FULL_HALF_LEFT_TRIANGLE
|
||||
rotate: false
|
||||
xy: 8, 416
|
||||
size: 256, 128
|
||||
orig: 256, 128
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
brick_FULL_HALF_RIGHT_TRIANGLE
|
||||
rotate: false
|
||||
xy: 272, 552
|
||||
size: 256, 128
|
||||
orig: 256, 128
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
brick_FULL_HALF_UP_TRIANGLE
|
||||
rotate: false
|
||||
xy: 536, 688
|
||||
size: 256, 128
|
||||
orig: 256, 128
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
brick_FULL_LEFT_DOWN_RIGHT_TRIANGLE
|
||||
rotate: false
|
||||
xy: 8, 280
|
||||
size: 256, 128
|
||||
orig: 256, 128
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
brick_FULL_LEFT_UP_RIGHT_TRIANGLE
|
||||
rotate: false
|
||||
xy: 272, 416
|
||||
size: 256, 128
|
||||
orig: 256, 128
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
brick_FULL_UP_LEFT_TRIANGLE
|
||||
rotate: false
|
||||
xy: 536, 552
|
||||
size: 256, 128
|
||||
orig: 256, 128
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
brick_HALF_DOWN_TRIANGLE
|
||||
rotate: false
|
||||
xy: 8, 144
|
||||
size: 256, 128
|
||||
orig: 256, 128
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
brick_HALF_LEFT_SQUARE
|
||||
rotate: false
|
||||
xy: 272, 280
|
||||
size: 256, 128
|
||||
orig: 256, 128
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
brick_HALF_LEFT_TRIANGLE
|
||||
rotate: false
|
||||
xy: 536, 416
|
||||
size: 256, 128
|
||||
orig: 256, 128
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
brick_HALF_LOWER_RECTANGLE
|
||||
rotate: false
|
||||
xy: 8, 8
|
||||
size: 256, 128
|
||||
orig: 256, 128
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
brick_HALF_RIGHT_SQUARE
|
||||
rotate: false
|
||||
xy: 272, 144
|
||||
size: 256, 128
|
||||
orig: 256, 128
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
brick_HALF_RIGHT_TRIANGLE
|
||||
rotate: false
|
||||
xy: 536, 280
|
||||
size: 256, 128
|
||||
orig: 256, 128
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
brick_HALF_UPPER_RECTANGLE
|
||||
rotate: false
|
||||
xy: 272, 8
|
||||
size: 256, 128
|
||||
orig: 256, 128
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
brick_HALF_UP_TRIANGLE
|
||||
rotate: false
|
||||
xy: 536, 144
|
||||
size: 256, 128
|
||||
orig: 256, 128
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
brick_LEFT_DOWN_LEFT_TRIANGLE
|
||||
rotate: false
|
||||
xy: 536, 8
|
||||
size: 256, 128
|
||||
orig: 256, 128
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
|
||||
textures2.png
|
||||
size: 1024,1024
|
||||
format: RGBA8888
|
||||
filter: MipMapLinearLinear,MipMapLinearLinear
|
||||
repeat: none
|
||||
brick_LEFT_DOWN_RIGHT_TRIANGLE
|
||||
rotate: false
|
||||
xy: 8, 688
|
||||
size: 256, 128
|
||||
orig: 256, 128
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
brick_LEFT_TRIANGLE
|
||||
rotate: false
|
||||
xy: 8, 552
|
||||
size: 256, 128
|
||||
orig: 256, 128
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
brick_LEFT_UP_LEFT_TRIANGLE
|
||||
rotate: false
|
||||
xy: 272, 688
|
||||
size: 256, 128
|
||||
orig: 256, 128
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
brick_LEFT_UP_RIGHT_TRIANGLE
|
||||
rotate: false
|
||||
xy: 8, 416
|
||||
size: 256, 128
|
||||
orig: 256, 128
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
brick_RECTANGLE
|
||||
rotate: false
|
||||
xy: 272, 552
|
||||
size: 256, 128
|
||||
orig: 256, 128
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
brick_RIGHT_DOWN_LEFT_TRIANGLE
|
||||
rotate: false
|
||||
xy: 536, 688
|
||||
size: 256, 128
|
||||
orig: 256, 128
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
brick_RIGHT_DOWN_RIGHT_TRIANGLE
|
||||
rotate: false
|
||||
xy: 8, 280
|
||||
size: 256, 128
|
||||
orig: 256, 128
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
brick_RIGHT_TRIANGLE
|
||||
rotate: false
|
||||
xy: 272, 416
|
||||
size: 256, 128
|
||||
orig: 256, 128
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
brick_RIGHT_UP_LEFT_TRIANGLE
|
||||
rotate: false
|
||||
xy: 536, 552
|
||||
size: 256, 128
|
||||
orig: 256, 128
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
brick_RIGHT_UP_RIGHT_TRIANGLE
|
||||
rotate: false
|
||||
xy: 8, 144
|
||||
size: 256, 128
|
||||
orig: 256, 128
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
brick_UP_LEFT_TRIANGLE
|
||||
rotate: false
|
||||
xy: 272, 280
|
||||
size: 256, 128
|
||||
orig: 256, 128
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
brick_UP_RIGHT_TRIANGLE
|
||||
rotate: false
|
||||
xy: 536, 416
|
||||
size: 256, 128
|
||||
orig: 256, 128
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
brick_UP_TRIANGLE
|
||||
rotate: false
|
||||
xy: 8, 8
|
||||
size: 256, 128
|
||||
orig: 256, 128
|
||||
offset: 0, 0
|
||||
index: -1
|
BIN
core/assets/textures.png
Normal file
After Width: | Height: | Size: 41 KiB |
BIN
core/assets/textures2.png
Normal file
After Width: | Height: | Size: 16 KiB |
@ -2,6 +2,7 @@ package com.me.brickbuster;
|
||||
|
||||
import com.badlogic.gdx.Game;
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.assets.AssetManager;
|
||||
import com.badlogic.gdx.graphics.GL20;
|
||||
import com.badlogic.gdx.graphics.OrthographicCamera;
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
@ -28,6 +29,8 @@ public class BrickBuster extends Game {
|
||||
public ShapeRenderer sr;
|
||||
public PolygonSpriteBatch pb;
|
||||
|
||||
public AssetManager assets;
|
||||
|
||||
@Override
|
||||
public void create () {
|
||||
cam = new OrthographicCamera();
|
||||
@ -42,6 +45,8 @@ public class BrickBuster extends Game {
|
||||
sr = new ShapeRenderer();
|
||||
pb = new PolygonSpriteBatch();
|
||||
|
||||
assets = new AssetManager();
|
||||
|
||||
setScreen(new MenuState(this));
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,8 @@ package com.me.brickbuster.entity;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
|
||||
import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType;
|
||||
import com.badlogic.gdx.math.MathUtils;
|
||||
@ -27,22 +29,29 @@ public class Ball extends Entity implements PhysicsBody, CollisionListener {
|
||||
private boolean isStuck = true;
|
||||
private boolean touchedPaddle = false;
|
||||
|
||||
private TextureRegion texture;
|
||||
|
||||
private Body body;
|
||||
|
||||
public Ball(PlayState state) {
|
||||
super(state, state.paddle.getX(), state.paddle.getY() + Paddle.PADDLE_HEIGHT + RADIUS);
|
||||
this.speed = state.bricks.size > BLOCKS_FOR_BOOST? DEFAULT_SPEED : BOOST_SPEED;
|
||||
|
||||
texture = state.textures.findRegion("ball");
|
||||
|
||||
createBody();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(ShapeRenderer sr) {
|
||||
sr.begin(ShapeType.Filled);
|
||||
sr.setColor(BALL_COLOR);
|
||||
sr.circle(pos.x * PlayState.PIXEL_PER_METER,
|
||||
pos.y * PlayState.PIXEL_PER_METER,
|
||||
RADIUS * PlayState.PIXEL_PER_METER);
|
||||
sr.end();
|
||||
SpriteBatch sb = state.getGame().sb;
|
||||
sb.begin();
|
||||
sb.setColor(Color.WHITE);
|
||||
sb.draw(texture, (pos.x - RADIUS) * PlayState.PIXEL_PER_METER,
|
||||
(pos.y - RADIUS) * PlayState.PIXEL_PER_METER,
|
||||
RADIUS*2 * PlayState.PIXEL_PER_METER,
|
||||
RADIUS*2 * PlayState.PIXEL_PER_METER);
|
||||
sb.end();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,18 +1,14 @@
|
||||
package com.me.brickbuster.entity;
|
||||
|
||||
import com.badlogic.gdx.graphics.Pixmap;
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
import com.badlogic.gdx.graphics.g2d.PolygonRegion;
|
||||
import com.badlogic.gdx.graphics.g2d.PolygonSpriteBatch;
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
|
||||
import com.badlogic.gdx.math.EarClippingTriangulator;
|
||||
import com.badlogic.gdx.math.MathUtils;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import com.badlogic.gdx.physics.box2d.Body;
|
||||
import com.badlogic.gdx.physics.box2d.BodyDef;
|
||||
import com.badlogic.gdx.physics.box2d.FixtureDef;
|
||||
import com.badlogic.gdx.physics.box2d.PolygonShape;
|
||||
import com.badlogic.gdx.utils.ShortArray;
|
||||
import com.me.brickbuster.entity.powerup.PowerUpType;
|
||||
import com.me.brickbuster.physics.CollisionListener;
|
||||
import com.me.brickbuster.physics.EntityType;
|
||||
@ -22,18 +18,13 @@ import com.me.brickbuster.state.PlayState;
|
||||
|
||||
public class Brick extends Entity implements PhysicsBody, CollisionListener {
|
||||
|
||||
public static final float BRICK_WIDTH = 4.6f;
|
||||
public static final float BRICK_HEIGHT = 2.3f;
|
||||
|
||||
private static final EarClippingTriangulator ECT = new EarClippingTriangulator();
|
||||
private static final Vector2 tmp = new Vector2();
|
||||
public static final float BRICK_WIDTH = 5.2f;
|
||||
public static final float BRICK_HEIGHT = 2.6f;
|
||||
|
||||
private BrickType type;
|
||||
private BrickShape.Shape shape;
|
||||
private PowerUpType powerUpType;
|
||||
|
||||
private Pixmap pm;
|
||||
private Texture solid;
|
||||
private TextureRegion region;
|
||||
|
||||
private Body body;
|
||||
@ -44,32 +35,20 @@ public class Brick extends Entity implements PhysicsBody, CollisionListener {
|
||||
this.type = type;
|
||||
this.shape = shape;
|
||||
this.powerUpType = powerUpType;
|
||||
this.pm = new Pixmap(1,1, Pixmap.Format.RGBA8888);
|
||||
this.pm.setColor(type.getColor());
|
||||
this.pm.fill();
|
||||
this.solid = new Texture(pm);
|
||||
this.region = new TextureRegion(solid);
|
||||
this.region = state.textures.findRegion("brick_" + shape.name());
|
||||
createBody();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(ShapeRenderer sr) {
|
||||
PolygonShape shape = (PolygonShape) body.getFixtureList().get(0).getShape();
|
||||
float[] vertices = new float[shape.getVertexCount()*2];
|
||||
for (int i = 0; i < vertices.length/2; i++) {
|
||||
shape.getVertex(i, tmp);
|
||||
Vector2 vertex = body.getWorldPoint(tmp);
|
||||
vertices[i*2] = vertex.x * PlayState.PIXEL_PER_METER;
|
||||
vertices[i*2 + 1] = vertex.y * PlayState.PIXEL_PER_METER;
|
||||
}
|
||||
ShortArray triangleIndices = ECT.computeTriangles(vertices);
|
||||
|
||||
PolygonRegion polyRegion = new PolygonRegion(region, vertices, triangleIndices.toArray());
|
||||
|
||||
PolygonSpriteBatch pb = state.getGame().pb;
|
||||
pb.begin();
|
||||
pb.draw(polyRegion, 0, 0);
|
||||
pb.end();
|
||||
SpriteBatch sb = state.getGame().sb;
|
||||
sb.setColor(type.getColor());
|
||||
float x = (getX() - BRICK_WIDTH/2) * PlayState.PIXEL_PER_METER;
|
||||
float y = (getY() - BRICK_HEIGHT/2) * PlayState.PIXEL_PER_METER;
|
||||
sb.draw(region, x, y,
|
||||
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, MathUtils.radiansToDegrees * body.getAngle());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -169,12 +148,6 @@ public class Brick extends Entity implements PhysicsBody, CollisionListener {
|
||||
body.setTransform(pos, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
solid.dispose();
|
||||
pm.dispose();
|
||||
}
|
||||
|
||||
public BrickType getType() {
|
||||
return type;
|
||||
}
|
||||
|
@ -14,55 +14,67 @@ public class BrickShape {
|
||||
|
||||
public enum Shape {
|
||||
|
||||
RECTANGLE(BOTTOM_LEFT | TOP_LEFT | TOP_RIGHT | BOTTOM_RIGHT),
|
||||
RECTANGLE(0, 0, BOTTOM_LEFT | TOP_LEFT | TOP_RIGHT | BOTTOM_RIGHT),
|
||||
|
||||
HALF_LEFT_SQUARE(BOTTOM_LEFT | TOP_LEFT | TOP_MIDDLE | BOTTOM_MIDDLE),
|
||||
HALF_RIGHT_SQUARE(BOTTOM_MIDDLE | TOP_MIDDLE | TOP_RIGHT | BOTTOM_RIGHT),
|
||||
HALF_UPPER_RECTANGLE(MIDDLE_LEFT | TOP_LEFT | TOP_RIGHT | MIDDLE_RIGHT),
|
||||
HALF_LOWER_RECTANGLE(BOTTOM_LEFT | MIDDLE_LEFT | MIDDLE_RIGHT | BOTTOM_RIGHT),
|
||||
HALF_LEFT_SQUARE(1, 0, BOTTOM_LEFT | TOP_LEFT | TOP_MIDDLE | BOTTOM_MIDDLE),
|
||||
HALF_RIGHT_SQUARE(2, 0, BOTTOM_MIDDLE | TOP_MIDDLE | TOP_RIGHT | BOTTOM_RIGHT),
|
||||
HALF_UPPER_RECTANGLE(4, 0, MIDDLE_LEFT | TOP_LEFT | TOP_RIGHT | MIDDLE_RIGHT),
|
||||
HALF_LOWER_RECTANGLE(5, 0, BOTTOM_LEFT | MIDDLE_LEFT | MIDDLE_RIGHT | BOTTOM_RIGHT),
|
||||
|
||||
DIAMOND(MIDDLE_LEFT | TOP_MIDDLE | MIDDLE_RIGHT | BOTTOM_MIDDLE),
|
||||
DIAMOND(2, 1, MIDDLE_LEFT | TOP_MIDDLE | MIDDLE_RIGHT | BOTTOM_MIDDLE),
|
||||
|
||||
UP_TRIANGLE(BOTTOM_LEFT | TOP_MIDDLE | BOTTOM_RIGHT),
|
||||
HALF_UP_TRIANGLE(BOTTOM_LEFT | CENTER | BOTTOM_RIGHT),
|
||||
FULL_HALF_UP_TRIANGE(BOTTOM_LEFT | MIDDLE_LEFT | TOP_MIDDLE | MIDDLE_RIGHT | BOTTOM_RIGHT),
|
||||
DOWN_TRIANGLE(TOP_LEFT | TOP_RIGHT | BOTTOM_MIDDLE),
|
||||
HALF_DOWN_TRIANGLE(TOP_LEFT | TOP_RIGHT | CENTER),
|
||||
FULL_HALF_DOWN_TRIANGE(MIDDLE_LEFT | TOP_LEFT | TOP_RIGHT | MIDDLE_RIGHT | BOTTOM_MIDDLE),
|
||||
LEFT_TRIANGLE(MIDDLE_LEFT | TOP_RIGHT | BOTTOM_RIGHT),
|
||||
HALF_LEFT_TRIANGLE(CENTER | TOP_RIGHT | BOTTOM_RIGHT),
|
||||
FULL_HALF_LEFT_TRIANGE(MIDDLE_LEFT | TOP_MIDDLE | TOP_RIGHT | BOTTOM_RIGHT | BOTTOM_MIDDLE),
|
||||
RIGHT_TRIANGLE(BOTTOM_LEFT | TOP_LEFT | MIDDLE_RIGHT),
|
||||
HALF_RIGHT_TRIANGLE(BOTTOM_LEFT | TOP_LEFT | CENTER),
|
||||
FULL_HALF_RIGHT_TRIANGE(BOTTOM_LEFT | TOP_LEFT | TOP_MIDDLE | MIDDLE_RIGHT | BOTTOM_MIDDLE),
|
||||
UP_TRIANGLE(2, 2, BOTTOM_LEFT | TOP_MIDDLE | BOTTOM_RIGHT),
|
||||
HALF_UP_TRIANGLE(3, 5, BOTTOM_LEFT | CENTER | BOTTOM_RIGHT),
|
||||
FULL_HALF_UP_TRIANGLE(1, 5, BOTTOM_LEFT | MIDDLE_LEFT | TOP_MIDDLE | MIDDLE_RIGHT | BOTTOM_RIGHT),
|
||||
DOWN_TRIANGLE(2, 3, TOP_LEFT | TOP_RIGHT | BOTTOM_MIDDLE),
|
||||
HALF_DOWN_TRIANGLE(2, 5, TOP_LEFT | TOP_RIGHT | CENTER),
|
||||
FULL_HALF_DOWN_TRIANGLE(0, 5, MIDDLE_LEFT | TOP_LEFT | TOP_RIGHT | MIDDLE_RIGHT | BOTTOM_MIDDLE),
|
||||
LEFT_TRIANGLE(3, 4, MIDDLE_LEFT | TOP_RIGHT | BOTTOM_RIGHT),
|
||||
HALF_LEFT_TRIANGLE(2, 4, CENTER | TOP_RIGHT | BOTTOM_RIGHT),
|
||||
FULL_HALF_LEFT_TRIANGLE(1, 3, MIDDLE_LEFT | TOP_MIDDLE | TOP_RIGHT | BOTTOM_RIGHT | BOTTOM_MIDDLE),
|
||||
RIGHT_TRIANGLE(0, 4, BOTTOM_LEFT | TOP_LEFT | MIDDLE_RIGHT),
|
||||
HALF_RIGHT_TRIANGLE(1, 4, BOTTOM_LEFT | TOP_LEFT | CENTER),
|
||||
FULL_HALF_RIGHT_TRIANGLE(0, 3, BOTTOM_LEFT | TOP_LEFT | TOP_MIDDLE | MIDDLE_RIGHT | BOTTOM_MIDDLE),
|
||||
|
||||
DOWN_RIGHT_TRIANGLE(BOTTOM_LEFT | TOP_RIGHT | BOTTOM_RIGHT),
|
||||
LEFT_DOWN_RIGHT_TRIANGLE(BOTTOM_LEFT | TOP_MIDDLE | BOTTOM_MIDDLE),
|
||||
FULL_LEFT_DOWN_RIGHT_TRIANGLE(BOTTOM_LEFT | TOP_MIDDLE | TOP_RIGHT | BOTTOM_RIGHT),
|
||||
RIGHT_DOWN_RIGHT_TRIANGLE(BOTTOM_MIDDLE | TOP_RIGHT | BOTTOM_RIGHT),
|
||||
DOWN_RIGHT_TRIANGLE(0, 1, BOTTOM_LEFT | TOP_RIGHT | BOTTOM_RIGHT),
|
||||
LEFT_DOWN_RIGHT_TRIANGLE(0, 6, BOTTOM_LEFT | TOP_MIDDLE | BOTTOM_MIDDLE),
|
||||
FULL_LEFT_DOWN_RIGHT_TRIANGLE(3, 1, BOTTOM_LEFT | TOP_MIDDLE | TOP_RIGHT | BOTTOM_RIGHT),
|
||||
RIGHT_DOWN_RIGHT_TRIANGLE(2, 6, BOTTOM_MIDDLE | TOP_RIGHT | BOTTOM_RIGHT),
|
||||
|
||||
UP_RIGHT_TRIANGLE(TOP_LEFT | TOP_RIGHT | BOTTOM_RIGHT),
|
||||
LEFT_UP_RIGHT_TRIANGLE(TOP_LEFT | TOP_MIDDLE | BOTTOM_MIDDLE),
|
||||
FULL_LEFT_UP_RIGHT_TRIANGLE(TOP_LEFT | TOP_RIGHT | BOTTOM_RIGHT | BOTTOM_MIDDLE),
|
||||
RIGHT_UP_RIGHT_TRIANGLE(TOP_MIDDLE | TOP_RIGHT | BOTTOM_RIGHT),
|
||||
UP_RIGHT_TRIANGLE(0, 2, TOP_LEFT | TOP_RIGHT | BOTTOM_RIGHT),
|
||||
LEFT_UP_RIGHT_TRIANGLE(0, 7, TOP_LEFT | TOP_MIDDLE | BOTTOM_MIDDLE),
|
||||
FULL_LEFT_UP_RIGHT_TRIANGLE(3, 0, TOP_LEFT | TOP_RIGHT | BOTTOM_RIGHT | BOTTOM_MIDDLE),
|
||||
RIGHT_UP_RIGHT_TRIANGLE(2, 7, TOP_MIDDLE | TOP_RIGHT | BOTTOM_RIGHT),
|
||||
|
||||
UP_LEFT_TRIANGLE(BOTTOM_LEFT | TOP_LEFT | TOP_RIGHT),
|
||||
LEFT_UP_LEFT_TRIANGLE(BOTTOM_LEFT | TOP_LEFT | TOP_MIDDLE),
|
||||
FULL_UP_LEFT_TRIANGLE(BOTTOM_LEFT | TOP_LEFT | TOP_RIGHT | BOTTOM_MIDDLE),
|
||||
RIGHT_UP_LEFT_TRIANGLE(BOTTOM_MIDDLE | TOP_MIDDLE | TOP_RIGHT),
|
||||
UP_LEFT_TRIANGLE(1, 2, BOTTOM_LEFT | TOP_LEFT | TOP_RIGHT),
|
||||
LEFT_UP_LEFT_TRIANGLE(1, 7, BOTTOM_LEFT | TOP_LEFT | TOP_MIDDLE),
|
||||
FULL_UP_LEFT_TRIANGLE(3, 2, BOTTOM_LEFT | TOP_LEFT | TOP_RIGHT | BOTTOM_MIDDLE),
|
||||
RIGHT_UP_LEFT_TRIANGLE(3, 7, BOTTOM_MIDDLE | TOP_MIDDLE | TOP_RIGHT),
|
||||
|
||||
DOWN_LEFT_TRIANGLE(BOTTOM_LEFT | TOP_LEFT | BOTTOM_RIGHT),
|
||||
LEFT_DOWN_LEFT_TRIANGLE(BOTTOM_LEFT | TOP_LEFT | BOTTOM_MIDDLE),
|
||||
FULL_DOWN_LEFT_TRIANGLE(BOTTOM_LEFT | TOP_LEFT | TOP_MIDDLE | BOTTOM_RIGHT),
|
||||
RIGHT_DOWN_LEFT_TRIANGLE(BOTTOM_MIDDLE | TOP_MIDDLE | BOTTOM_RIGHT),
|
||||
DOWN_LEFT_TRIANGLE(1, 1, BOTTOM_LEFT | TOP_LEFT | BOTTOM_RIGHT),
|
||||
LEFT_DOWN_LEFT_TRIANGLE(1, 6, BOTTOM_LEFT | TOP_LEFT | BOTTOM_MIDDLE),
|
||||
FULL_DOWN_LEFT_TRIANGLE(3, 3, BOTTOM_LEFT | TOP_LEFT | TOP_MIDDLE | BOTTOM_RIGHT),
|
||||
RIGHT_DOWN_LEFT_TRIANGLE(3, 6, BOTTOM_MIDDLE | TOP_MIDDLE | BOTTOM_RIGHT),
|
||||
;
|
||||
|
||||
private int row;
|
||||
private int col;
|
||||
private int mask;
|
||||
|
||||
Shape(int mask) {
|
||||
Shape(int row, int col, int mask) {
|
||||
this.row = row;
|
||||
this.col = col;
|
||||
this.mask = mask;
|
||||
}
|
||||
|
||||
public int getRow() {
|
||||
return row;
|
||||
}
|
||||
|
||||
public int getCol() {
|
||||
return col;
|
||||
}
|
||||
|
||||
public int getMask() {
|
||||
return mask;
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ import com.me.brickbuster.state.PlayState;
|
||||
public class GridLevelLoader implements LevelLoader {
|
||||
|
||||
public static final float POWER_UP_CHANCE = 0.15f;
|
||||
public static final int COLUMNS = 11;
|
||||
public static final int COLUMNS = 10;
|
||||
public static final int ROWS = 20;
|
||||
public static final int ROUNDS = 2;
|
||||
|
||||
@ -19,7 +19,7 @@ public class GridLevelLoader implements LevelLoader {
|
||||
@Override
|
||||
public Level getNextLevel() {
|
||||
if (playCount++ < ROUNDS) {
|
||||
return new Level(new GridLayout(state, COLUMNS, ROWS, POWER_UP_CHANCE));
|
||||
return new Level(new GridLayout(state, COLUMNS, ROWS, POWER_UP_CHANCE, true, true));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -46,6 +46,8 @@ public class EditorState extends FieldState {
|
||||
|
||||
@Override
|
||||
public void setup() {
|
||||
super.setup();
|
||||
|
||||
world = new World(new Vector2(), false);
|
||||
world.setContactListener(new Box2dContactListener());
|
||||
|
||||
@ -62,6 +64,7 @@ public class EditorState extends FieldState {
|
||||
|
||||
@Override
|
||||
public void render() {
|
||||
game.sb.begin();
|
||||
for (int col = 0; col < bricks.length; col++) {
|
||||
for (int row = 0; row < bricks[col].length; row++) {
|
||||
if (col == this.col && row == this.row && !blink) {
|
||||
@ -77,6 +80,7 @@ public class EditorState extends FieldState {
|
||||
if (!blink) {
|
||||
placeHolder.render(game.sr);
|
||||
}
|
||||
game.sb.end();
|
||||
|
||||
debugRenderer.render(world, game.cam.combined.cpy().scl(PlayState.PIXEL_PER_METER));
|
||||
|
||||
|
@ -1,14 +1,24 @@
|
||||
package com.me.brickbuster.state;
|
||||
|
||||
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
|
||||
import com.badlogic.gdx.physics.box2d.World;
|
||||
import com.me.brickbuster.BrickBuster;
|
||||
|
||||
public abstract class FieldState extends State {
|
||||
|
||||
public World world;
|
||||
public TextureAtlas textures;
|
||||
|
||||
public FieldState(BrickBuster game) {
|
||||
super(game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setup() {
|
||||
game.assets.load("textures.atlas", TextureAtlas.class);
|
||||
game.assets.finishLoading();
|
||||
|
||||
textures = game.assets.get("textures.atlas", TextureAtlas.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,6 +2,8 @@ package com.me.brickbuster.state;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import com.badlogic.gdx.physics.box2d.*;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
@ -19,7 +21,7 @@ public class PlayState extends FieldState {
|
||||
public static final float BOARD_WIDTH = 54f;
|
||||
public static final float BOARD_HEIGHT = 96f;
|
||||
public static final float PIXEL_PER_METER = BrickBuster.BOARD_WIDTH / BOARD_WIDTH;
|
||||
public static final float EDGE_PADDING = 1.7f;
|
||||
public static final float EDGE_PADDING = 1f;
|
||||
|
||||
public static final Vector2 lowerLeftCorner =
|
||||
new Vector2(EDGE_PADDING,0);
|
||||
@ -53,11 +55,14 @@ public class PlayState extends FieldState {
|
||||
|
||||
@Override
|
||||
public void setup() {
|
||||
super.setup();
|
||||
|
||||
// Initialize a world with no gravity
|
||||
world = new World(new Vector2(), false);
|
||||
world.setContactListener(new Box2dContactListener());
|
||||
bodies = new Array<Body>();
|
||||
|
||||
//levelLoader = new FileLevelLoader(this);
|
||||
levelLoader = new GridLevelLoader(this);
|
||||
currentLevel = levelLoader.getNextLevel();
|
||||
|
||||
@ -75,9 +80,11 @@ public class PlayState extends FieldState {
|
||||
}
|
||||
|
||||
long start = System.nanoTime();
|
||||
game.sb.begin();
|
||||
for (Brick block : bricks) {
|
||||
block.render(game.sr);
|
||||
}
|
||||
game.sb.end();
|
||||
for (PowerUp powerUp : powerUps) {
|
||||
powerUp.render(game.sr);
|
||||
}
|
||||
|