Compare commits
	
		
			11 Commits
		
	
	
		
			box2d
			...
			9df81ee854
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 9df81ee854 | |||
| e116f1064d | |||
| 4fa5841fb2 | |||
| f70dc67878 | |||
| 64e00c1a1a | |||
| cb90c949ff | |||
| 998286de8d | |||
| 9eac3353b6 | |||
| adebc42c16 | |||
| 74aa10de04 | |||
| b44b48097c | 
| @ -6,6 +6,7 @@ import com.badlogic.gdx.graphics.GL20; | |||||||
| import com.badlogic.gdx.graphics.OrthographicCamera; | import com.badlogic.gdx.graphics.OrthographicCamera; | ||||||
| import com.badlogic.gdx.graphics.Texture; | import com.badlogic.gdx.graphics.Texture; | ||||||
| import com.badlogic.gdx.graphics.g2d.BitmapFont; | import com.badlogic.gdx.graphics.g2d.BitmapFont; | ||||||
|  | import com.badlogic.gdx.graphics.g2d.PolygonSpriteBatch; | ||||||
| import com.badlogic.gdx.graphics.g2d.SpriteBatch; | import com.badlogic.gdx.graphics.g2d.SpriteBatch; | ||||||
| import com.badlogic.gdx.graphics.glutils.ShapeRenderer; | import com.badlogic.gdx.graphics.glutils.ShapeRenderer; | ||||||
| import com.badlogic.gdx.utils.viewport.FitViewport; | import com.badlogic.gdx.utils.viewport.FitViewport; | ||||||
| @ -25,6 +26,7 @@ public class BrickBuster extends Game { | |||||||
| 	public BitmapFont font; | 	public BitmapFont font; | ||||||
| 	public SpriteBatch sb; | 	public SpriteBatch sb; | ||||||
| 	public ShapeRenderer sr; | 	public ShapeRenderer sr; | ||||||
|  | 	public PolygonSpriteBatch pb; | ||||||
|  |  | ||||||
| 	@Override | 	@Override | ||||||
| 	public void create () { | 	public void create () { | ||||||
| @ -38,6 +40,7 @@ public class BrickBuster extends Game { | |||||||
|  |  | ||||||
| 		sb = new SpriteBatch(); | 		sb = new SpriteBatch(); | ||||||
| 		sr = new ShapeRenderer(); | 		sr = new ShapeRenderer(); | ||||||
|  | 		pb = new PolygonSpriteBatch(); | ||||||
|  |  | ||||||
| 		setScreen(new MenuState(this)); | 		setScreen(new MenuState(this)); | ||||||
| 	} | 	} | ||||||
| @ -56,6 +59,7 @@ public class BrickBuster extends Game { | |||||||
|  |  | ||||||
| 		sb.setProjectionMatrix(cam.combined); | 		sb.setProjectionMatrix(cam.combined); | ||||||
| 		sr.setProjectionMatrix(cam.combined); | 		sr.setProjectionMatrix(cam.combined); | ||||||
|  | 		pb.setProjectionMatrix(cam.combined); | ||||||
|  |  | ||||||
| 		super.resize(width, height); | 		super.resize(width, height); | ||||||
| 	} | 	} | ||||||
|  | |||||||
| @ -6,11 +6,9 @@ import com.badlogic.gdx.graphics.glutils.ShapeRenderer; | |||||||
| import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType; | import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType; | ||||||
| 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.physics.box2d.Body; | import com.badlogic.gdx.physics.box2d.*; | ||||||
| import com.badlogic.gdx.physics.box2d.BodyDef; |  | ||||||
| import com.badlogic.gdx.physics.box2d.CircleShape; |  | ||||||
| import com.badlogic.gdx.physics.box2d.FixtureDef; |  | ||||||
| import com.me.brickbuster.physics.CollisionListener; | import com.me.brickbuster.physics.CollisionListener; | ||||||
|  | import com.me.brickbuster.physics.EntityType; | ||||||
| import com.me.brickbuster.physics.PhysicsBody; | import com.me.brickbuster.physics.PhysicsBody; | ||||||
| import com.me.brickbuster.state.PlayState; | import com.me.brickbuster.state.PlayState; | ||||||
|  |  | ||||||
| @ -22,6 +20,9 @@ public class Ball extends Entity implements PhysicsBody, CollisionListener { | |||||||
| 	public static final float BOOST_SPEED = 55; | 	public static final float BOOST_SPEED = 55; | ||||||
| 	public static final int BLOCKS_FOR_BOOST = 39; | 	public static final int BLOCKS_FOR_BOOST = 39; | ||||||
|  |  | ||||||
|  | 	public static final float MINIMUM_ANGLE = MathUtils.PI/16; | ||||||
|  | 	public static final float CORRECTION_IMPULSE = 3f; | ||||||
|  |  | ||||||
| 	private float speed; | 	private float speed; | ||||||
| 	private boolean isStuck = true; | 	private boolean isStuck = true; | ||||||
| 	private boolean touchedPaddle = false; | 	private boolean touchedPaddle = false; | ||||||
| @ -30,7 +31,7 @@ public class Ball extends Entity implements PhysicsBody, CollisionListener { | |||||||
|  |  | ||||||
| 	public Ball(PlayState state) { | 	public Ball(PlayState state) { | ||||||
| 		super(state, state.paddle.getX(), state.paddle.getY() + Paddle.PADDLE_HEIGHT + RADIUS); | 		super(state, state.paddle.getX(), state.paddle.getY() + Paddle.PADDLE_HEIGHT + RADIUS); | ||||||
| 		this.speed = state.bricks.size() > BLOCKS_FOR_BOOST? DEFAULT_SPEED : BOOST_SPEED; | 		this.speed = state.bricks.size > BLOCKS_FOR_BOOST? DEFAULT_SPEED : BOOST_SPEED; | ||||||
| 		createBody(); | 		createBody(); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| @ -58,11 +59,19 @@ public class Ball extends Entity implements PhysicsBody, CollisionListener { | |||||||
| 			touchedPaddle = false; | 			touchedPaddle = false; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		if (getY() + RADIUS < 0) { | 		if (pos.y + RADIUS < 0) { | ||||||
| 			deleted = true; | 			deleted = true; | ||||||
|  | 			return; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		body.setLinearVelocity(body.getLinearVelocity().nor().scl(speed)); | 		Vector2 velocity = body.getLinearVelocity(); | ||||||
|  | 		body.setLinearVelocity(velocity.nor().scl(speed)); | ||||||
|  |  | ||||||
|  | 		float rad = velocity.angleRad(); | ||||||
|  | 		if (Math.abs(rad) < MINIMUM_ANGLE || Math.abs(rad) > MathUtils.PI - MINIMUM_ANGLE) { | ||||||
|  | 			Vector2 impulse = new Vector2(0, rad > 0? CORRECTION_IMPULSE : -CORRECTION_IMPULSE); | ||||||
|  | 			body.applyLinearImpulse(impulse, pos, true); | ||||||
|  | 		} | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	@Override | 	@Override | ||||||
| @ -83,6 +92,12 @@ public class Ball extends Entity implements PhysicsBody, CollisionListener { | |||||||
| 		ballFixture.shape = ballShape; | 		ballFixture.shape = ballShape; | ||||||
| 		ballFixture.restitution = 1f; | 		ballFixture.restitution = 1f; | ||||||
| 		ballFixture.friction = 0f; | 		ballFixture.friction = 0f; | ||||||
|  | 		ballFixture.density = 1f; | ||||||
|  |  | ||||||
|  | 		ballFixture.filter.categoryBits = EntityType.BALL; | ||||||
|  | 		ballFixture.filter.maskBits = EntityType.BOUNDARY | EntityType.BRICK | ||||||
|  | 						| EntityType.PADDLE | EntityType.POWER_UP | ||||||
|  | 						| EntityType.SHIELD; | ||||||
|  |  | ||||||
| 		body = state.world.createBody(ballBody); | 		body = state.world.createBody(ballBody); | ||||||
| 		body.createFixture(ballFixture); | 		body.createFixture(ballFixture); | ||||||
| @ -107,10 +122,9 @@ public class Ball extends Entity implements PhysicsBody, CollisionListener { | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	public Vector2 paddleReflectAngle() { | 	public Vector2 paddleReflectAngle() { | ||||||
| 		float trim = state.paddle.getWidth() * 0.10f; | 		float rel = (pos.x - state.paddle.getX()) + (state.paddle.getWidth()/2); | ||||||
| 		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())); | ||||||
|  | 		newAngle = MathUtils.clamp(newAngle, MINIMUM_ANGLE, MathUtils.PI-MINIMUM_ANGLE); | ||||||
| 		return new Vector2(MathUtils.cos(newAngle), MathUtils.sin(newAngle)); | 		return new Vector2(MathUtils.cos(newAngle), MathUtils.sin(newAngle)); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| @ -122,7 +136,6 @@ public class Ball extends Entity implements PhysicsBody, CollisionListener { | |||||||
| 			// launch at random angle between 135 and 45 degrees | 			// launch at random angle between 135 and 45 degrees | ||||||
| 			float angle = MathUtils.random(MathUtils.PI/2) + MathUtils.PI/4; | 			float angle = MathUtils.random(MathUtils.PI/2) + MathUtils.PI/4; | ||||||
| 			direction = new Vector2(MathUtils.cos(angle), MathUtils.sin(angle)); | 			direction = new Vector2(MathUtils.cos(angle), MathUtils.sin(angle)); | ||||||
|  |  | ||||||
| 		} | 		} | ||||||
| 		body.setLinearVelocity(direction.scl(speed)); | 		body.setLinearVelocity(direction.scl(speed)); | ||||||
| 		isStuck = false; | 		isStuck = false; | ||||||
|  | |||||||
| @ -1,15 +1,22 @@ | |||||||
| package com.me.brickbuster.entity; | package com.me.brickbuster.entity; | ||||||
|  |  | ||||||
| import com.badlogic.gdx.graphics.Color; | import com.badlogic.gdx.graphics.Color; | ||||||
|  | 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.TextureRegion; | ||||||
| import com.badlogic.gdx.graphics.glutils.ShapeRenderer; | import com.badlogic.gdx.graphics.glutils.ShapeRenderer; | ||||||
| import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType; | import com.badlogic.gdx.math.EarClippingTriangulator; | ||||||
| import com.badlogic.gdx.math.Vector2; | import com.badlogic.gdx.math.Vector2; | ||||||
| import com.badlogic.gdx.physics.box2d.Body; | import com.badlogic.gdx.physics.box2d.Body; | ||||||
| import com.badlogic.gdx.physics.box2d.BodyDef; | import com.badlogic.gdx.physics.box2d.BodyDef; | ||||||
| import com.badlogic.gdx.physics.box2d.FixtureDef; | import com.badlogic.gdx.physics.box2d.FixtureDef; | ||||||
| import com.badlogic.gdx.physics.box2d.PolygonShape; | import com.badlogic.gdx.physics.box2d.PolygonShape; | ||||||
|  | import com.badlogic.gdx.utils.ShortArray; | ||||||
| import com.me.brickbuster.entity.powerup.PowerUpType; | import com.me.brickbuster.entity.powerup.PowerUpType; | ||||||
| import com.me.brickbuster.physics.CollisionListener; | import com.me.brickbuster.physics.CollisionListener; | ||||||
|  | import com.me.brickbuster.physics.EntityType; | ||||||
| import com.me.brickbuster.physics.PhysicsBody; | import com.me.brickbuster.physics.PhysicsBody; | ||||||
| import com.me.brickbuster.state.PlayState; | import com.me.brickbuster.state.PlayState; | ||||||
|  |  | ||||||
| @ -19,8 +26,17 @@ public class Brick extends Entity implements PhysicsBody, CollisionListener { | |||||||
| 	public static final float BRICK_WIDTH = 5f; | 	public static final float BRICK_WIDTH = 5f; | ||||||
| 	public static final float BRICK_HEIGHT = 2.5f; | 	public static final float BRICK_HEIGHT = 2.5f; | ||||||
|  |  | ||||||
|  | 	private static final EarClippingTriangulator ECT = new EarClippingTriangulator(); | ||||||
|  | 	private static final Vector2 tmp = new Vector2(); | ||||||
|  |  | ||||||
|  | 	private BrickType type; | ||||||
|  | 	private BrickShape shape; | ||||||
| 	private PowerUpType powerUpType; | 	private PowerUpType powerUpType; | ||||||
|  |  | ||||||
| 	private Color color; | 	private Color color; | ||||||
|  | 	private Pixmap pm; | ||||||
|  | 	private Texture solid; | ||||||
|  | 	private TextureRegion region; | ||||||
|  |  | ||||||
| 	private Body body; | 	private Body body; | ||||||
| 	private boolean hitByBall = false; | 	private boolean hitByBall = false; | ||||||
| @ -29,26 +45,46 @@ public class Brick extends Entity implements PhysicsBody, CollisionListener { | |||||||
| 		this(state, powerUpType, true, x, y); | 		this(state, powerUpType, true, x, y); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	public Brick(PlayState state, PowerUpType powerUpType, boolean hidePowerup, float x, float y) { | 	public Brick(PlayState state, BrickShape shape, PowerUpType powerUpType, float x, float y) { | ||||||
| 		this(state, powerUpType, DEFAULT_COLOR, hidePowerup, x, y); | 		this(state, BrickType.STANDARD_10, shape, powerUpType, DEFAULT_COLOR, true,     x, y); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	public Brick(PlayState state, PowerUpType powerUpType, Color color, boolean hidePowerUp, float x, float y) { | 	public Brick(PlayState state, PowerUpType powerUpType, boolean hidePowerup, float x, float y) { | ||||||
|  | 		this(state, BrickType.STANDARD_10, BrickShape.RECTANGLE, powerUpType, DEFAULT_COLOR, hidePowerup, x, y); | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	public Brick(PlayState state, BrickType type, BrickShape shape, PowerUpType powerUpType, Color color, boolean hidePowerUp, float x, float y) { | ||||||
| 		super(state, x, y); | 		super(state, x, y); | ||||||
|  | 		this.type = type; | ||||||
|  | 		this.shape = shape; | ||||||
| 		this.powerUpType = powerUpType; | 		this.powerUpType = powerUpType; | ||||||
| 		this.color = powerUpType != null && !hidePowerUp? powerUpType.getColor() : color; | 		this.color = powerUpType != null && !hidePowerUp? powerUpType.getColor() : color; | ||||||
|  | 		this.pm = new Pixmap(1,1, Pixmap.Format.RGBA8888); | ||||||
|  | 		pm.setColor(color); | ||||||
|  | 		pm.fill(); | ||||||
|  | 		this.solid = new Texture(pm); | ||||||
|  | 		this.region = new TextureRegion(solid); | ||||||
| 		createBody(); | 		createBody(); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	@Override | 	@Override | ||||||
| 	public void render(ShapeRenderer sr) { | 	public void render(ShapeRenderer sr) { | ||||||
| 		sr.begin(ShapeType.Filled); | 		PolygonShape shape = (PolygonShape) body.getFixtureList().get(0).getShape(); | ||||||
| 		sr.setColor(color); | 		float[] vertices = new float[shape.getVertexCount()*2]; | ||||||
| 		sr.rect(getX() * PlayState.PIXEL_PER_METER, | 		for (int i = 0; i < vertices.length/2; i++) { | ||||||
| 				getY() * PlayState.PIXEL_PER_METER, | 			shape.getVertex(i, tmp); | ||||||
| 				BRICK_WIDTH * PlayState.PIXEL_PER_METER, | 			Vector2 vertex = body.getWorldPoint(tmp); | ||||||
| 				BRICK_HEIGHT * PlayState.PIXEL_PER_METER); | 			vertices[i*2] = vertex.x * PlayState.PIXEL_PER_METER; | ||||||
| 		sr.end(); | 			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(); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	@Override | 	@Override | ||||||
| @ -71,12 +107,88 @@ public class Brick extends Entity implements PhysicsBody, CollisionListener { | |||||||
| 		brickBody.position.set(pos.cpy()); | 		brickBody.position.set(pos.cpy()); | ||||||
|  |  | ||||||
| 		PolygonShape brickShape = new PolygonShape(); | 		PolygonShape brickShape = new PolygonShape(); | ||||||
| 		brickShape.setAsBox(BRICK_WIDTH/2, BRICK_HEIGHT/2, |  | ||||||
| 				new Vector2(BRICK_WIDTH/2,BRICK_HEIGHT/2), 0); | 		switch (shape) { | ||||||
|  | 			case DIAMOND: | ||||||
|  | 				brickShape.set(new float[] { | ||||||
|  | 						-BRICK_WIDTH/2, 0,  // Left | ||||||
|  | 						0, BRICK_HEIGHT/2,  // Up | ||||||
|  | 						BRICK_WIDTH/2, 0,   // Right | ||||||
|  | 						0, -BRICK_HEIGHT/2  // Down | ||||||
|  | 				}); | ||||||
|  | 				break; | ||||||
|  | 			case DOWN_RIGHT_TRIANGLE: | ||||||
|  | 				brickShape.set(new float[] { | ||||||
|  | 						BRICK_WIDTH/2, BRICK_HEIGHT/2,   // Top right | ||||||
|  | 						BRICK_WIDTH/2, -BRICK_HEIGHT/2,  // Bottom right | ||||||
|  | 						-BRICK_WIDTH/2, -BRICK_HEIGHT/2, // Bottom left | ||||||
|  | 				}); | ||||||
|  | 				break; | ||||||
|  | 			case UP_RIGHT_TRIANGLE: | ||||||
|  | 				brickShape.set(new float[] { | ||||||
|  | 						BRICK_WIDTH/2, BRICK_HEIGHT/2,   // Top right | ||||||
|  | 						BRICK_WIDTH/2, -BRICK_HEIGHT/2,  // Bottom right | ||||||
|  | 						-BRICK_WIDTH/2, BRICK_HEIGHT/2,  // Top left | ||||||
|  | 				}); | ||||||
|  | 				break; | ||||||
|  | 			case UP_LEFT_TRIANGLE: | ||||||
|  | 				brickShape.set(new float[] { | ||||||
|  | 						-BRICK_WIDTH/2, BRICK_HEIGHT/2,  // Top left | ||||||
|  | 						BRICK_WIDTH/2, BRICK_HEIGHT/2,   // Top right | ||||||
|  | 						-BRICK_WIDTH/2, -BRICK_HEIGHT/2, // Bottom left | ||||||
|  | 				}); | ||||||
|  | 				break; | ||||||
|  | 			case DOWN_LEFT_TRIANGLE: | ||||||
|  | 				brickShape.set(new float[] { | ||||||
|  | 						-BRICK_WIDTH/2, BRICK_HEIGHT/2,  // Top left | ||||||
|  | 						BRICK_WIDTH/2, -BRICK_HEIGHT/2,  // Bottom right | ||||||
|  | 						-BRICK_WIDTH/2, -BRICK_HEIGHT/2, // Bottom left | ||||||
|  | 				}); | ||||||
|  | 				break; | ||||||
|  | 			case HALF_LOWER: | ||||||
|  | 				brickShape.set(new float[] { | ||||||
|  | 						-BRICK_WIDTH/2, 0,                  // Top left | ||||||
|  | 						BRICK_WIDTH/2, 0,                   // Top right | ||||||
|  | 						BRICK_WIDTH/2, -BRICK_HEIGHT/2,     // Bottom right | ||||||
|  | 						-BRICK_WIDTH/2, -BRICK_HEIGHT/2,    // Bottom left | ||||||
|  | 				}); | ||||||
|  | 				break; | ||||||
|  | 			case HALF_UPPER: | ||||||
|  | 				brickShape.set(new float[] { | ||||||
|  | 						-BRICK_WIDTH/2, BRICK_HEIGHT/2,     // Top left | ||||||
|  | 						BRICK_WIDTH/2, BRICK_HEIGHT/2,      // Top right | ||||||
|  | 						BRICK_WIDTH/2, 0,                   // Bottom right | ||||||
|  | 						-BRICK_WIDTH/2, 0,                  // Bottom left | ||||||
|  | 				}); | ||||||
|  | 				break; | ||||||
|  | 			case HALF_LEFT: | ||||||
|  | 				brickShape.set(new float[] { | ||||||
|  | 						-BRICK_WIDTH/2, BRICK_HEIGHT/2,     // Top left | ||||||
|  | 						0, BRICK_HEIGHT/2,                  // Top right | ||||||
|  | 						0, -BRICK_HEIGHT/2,                 // Bottom right | ||||||
|  | 						-BRICK_WIDTH/2, -BRICK_HEIGHT/2,    // Bottom left | ||||||
|  | 				}); | ||||||
|  | 				break; | ||||||
|  | 			case HALF_RIGHT: | ||||||
|  | 				brickShape.set(new float[] { | ||||||
|  | 						0, BRICK_HEIGHT/2,                  // Top left | ||||||
|  | 						BRICK_WIDTH/2, BRICK_HEIGHT/2,      // Top right | ||||||
|  | 						BRICK_WIDTH/2, -BRICK_HEIGHT/2,     // Bottom right | ||||||
|  | 						0, -BRICK_HEIGHT/2,                 // Bottom left | ||||||
|  | 				}); | ||||||
|  | 				break; | ||||||
|  | 			default: | ||||||
|  | 				brickShape.setAsBox(BRICK_WIDTH/2, BRICK_HEIGHT/2, Vector2.Zero, 0f); | ||||||
|  | 		} | ||||||
|  |  | ||||||
|  |  | ||||||
| 		FixtureDef brickFixture = new FixtureDef(); | 		FixtureDef brickFixture = new FixtureDef(); | ||||||
| 		brickFixture.shape = brickShape; | 		brickFixture.shape = brickShape; | ||||||
| 		brickFixture.friction = 0f; | 		brickFixture.friction = 0f; | ||||||
|  | 		brickFixture.density = 0.5f; | ||||||
|  |  | ||||||
|  | 		brickFixture.filter.categoryBits = EntityType.BRICK; | ||||||
|  | 		brickFixture.filter.maskBits = EntityType.BALL | EntityType.BRICK | EntityType.BOUNDARY; | ||||||
|  |  | ||||||
| 		body = state.world.createBody(brickBody); | 		body = state.world.createBody(brickBody); | ||||||
| 		body.createFixture(brickFixture); | 		body.createFixture(brickFixture); | ||||||
| @ -96,8 +208,14 @@ public class Brick extends Entity implements PhysicsBody, CollisionListener { | |||||||
| 	public void endContact(Entity contacted) { | 	public void endContact(Entity contacted) { | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | 	@Override | ||||||
|  | 	public void dispose() { | ||||||
|  | 		solid.dispose(); | ||||||
|  | 		pm.dispose(); | ||||||
|  | 	} | ||||||
|  |  | ||||||
| 	public boolean hit() { | 	public boolean hit() { | ||||||
| 		if (state.bricks.size()-1 <= Ball.BLOCKS_FOR_BOOST) { | 		if (state.bricks.size-1 <= Ball.BLOCKS_FOR_BOOST) { | ||||||
| 			for (Ball ball : state.balls) { | 			for (Ball ball : state.balls) { | ||||||
| 				ball.setSpeed(Ball.BOOST_SPEED); | 				ball.setSpeed(Ball.BOOST_SPEED); | ||||||
| 			} | 			} | ||||||
|  | |||||||
							
								
								
									
										17
									
								
								core/src/com/me/brickbuster/entity/BrickShape.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								core/src/com/me/brickbuster/entity/BrickShape.java
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,17 @@ | |||||||
|  | package com.me.brickbuster.entity; | ||||||
|  |  | ||||||
|  | public enum BrickShape { | ||||||
|  |  | ||||||
|  | 	RECTANGLE, | ||||||
|  | 	DIAMOND, | ||||||
|  | 	DOWN_RIGHT_TRIANGLE, | ||||||
|  | 	UP_RIGHT_TRIANGLE, | ||||||
|  | 	UP_LEFT_TRIANGLE, | ||||||
|  | 	DOWN_LEFT_TRIANGLE, | ||||||
|  | 	HALF_UPPER, | ||||||
|  | 	HALF_LOWER, | ||||||
|  | 	HALF_LEFT, | ||||||
|  | 	HALF_RIGHT, | ||||||
|  | 	; | ||||||
|  |  | ||||||
|  | } | ||||||
							
								
								
									
										19
									
								
								core/src/com/me/brickbuster/entity/BrickType.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								core/src/com/me/brickbuster/entity/BrickType.java
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,19 @@ | |||||||
|  | package com.me.brickbuster.entity; | ||||||
|  |  | ||||||
|  | public enum BrickType { | ||||||
|  |  | ||||||
|  | 	STANDARD_10, | ||||||
|  | 	STANDARD_20, | ||||||
|  | 	STANDARD_30, | ||||||
|  | 	STANDARD_40, | ||||||
|  | 	STANDARD_50, | ||||||
|  | 	STANDARD_60, | ||||||
|  | 	STANDARD_70, | ||||||
|  | 	STANDARD_80, | ||||||
|  | 	EXPLOSIVE, | ||||||
|  | 	HARD, | ||||||
|  | 	HARDER, | ||||||
|  | 	UNBREAKABLE | ||||||
|  | 	; | ||||||
|  |  | ||||||
|  | } | ||||||
| @ -23,6 +23,8 @@ public abstract class Entity { | |||||||
|  |  | ||||||
| 	public abstract void update(float dt); | 	public abstract void update(float dt); | ||||||
|  |  | ||||||
|  | 	public void dispose() {} | ||||||
|  |  | ||||||
| 	public Vector2 getPos() { | 	public Vector2 getPos() { | ||||||
| 		return pos; | 		return pos; | ||||||
| 	} | 	} | ||||||
|  | |||||||
| @ -5,12 +5,14 @@ import com.badlogic.gdx.Input; | |||||||
| import com.badlogic.gdx.graphics.Color; | import com.badlogic.gdx.graphics.Color; | ||||||
| import com.badlogic.gdx.graphics.glutils.ShapeRenderer; | import com.badlogic.gdx.graphics.glutils.ShapeRenderer; | ||||||
| import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType; | import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType; | ||||||
|  | import com.badlogic.gdx.math.MathUtils; | ||||||
| import com.badlogic.gdx.math.Vector2; | import com.badlogic.gdx.math.Vector2; | ||||||
| import com.badlogic.gdx.physics.box2d.Body; | import com.badlogic.gdx.physics.box2d.Body; | ||||||
| import com.badlogic.gdx.physics.box2d.BodyDef; | import com.badlogic.gdx.physics.box2d.BodyDef; | ||||||
| import com.badlogic.gdx.physics.box2d.EdgeShape; | import com.badlogic.gdx.physics.box2d.EdgeShape; | ||||||
| import com.badlogic.gdx.physics.box2d.FixtureDef; | import com.badlogic.gdx.physics.box2d.FixtureDef; | ||||||
| import com.me.brickbuster.physics.CollisionListener; | import com.me.brickbuster.physics.CollisionListener; | ||||||
|  | import com.me.brickbuster.physics.EntityType; | ||||||
| import com.me.brickbuster.physics.PhysicsBody; | import com.me.brickbuster.physics.PhysicsBody; | ||||||
| import com.me.brickbuster.state.PlayState; | import com.me.brickbuster.state.PlayState; | ||||||
| import net.dermetfan.utils.Pair; | import net.dermetfan.utils.Pair; | ||||||
| @ -48,29 +50,27 @@ public class Paddle extends Entity implements PhysicsBody { | |||||||
|  |  | ||||||
| 	@Override | 	@Override | ||||||
| 	public void update(float dt) { | 	public void update(float dt) { | ||||||
|  | 		float displacement = PADDLE_SPEED * dt; | ||||||
|  | 		float adjust = 0; | ||||||
| 		if (Gdx.input.isKeyPressed(Input.Keys.LEFT)) { | 		if (Gdx.input.isKeyPressed(Input.Keys.LEFT)) { | ||||||
| 			if (pos.x - width/2 - PADDLE_SPEED * dt < 0) { | 			if (pos.x - width / 2 - displacement < PlayState.EDGE_PADDING) { | ||||||
| 				setX(width/2); | 				adjust = -(pos.x - width/2 - PlayState.EDGE_PADDING); | ||||||
| 				return; | 			} else { | ||||||
| 			} | 				adjust = -displacement; | ||||||
| 			setX(pos.x - PADDLE_SPEED * dt); |  | ||||||
|  |  | ||||||
| 			for (Ball ball : state.balls) { |  | ||||||
| 				if (ball.isStuck()) { |  | ||||||
| 					ball.setX(ball.getX() - PADDLE_SPEED * dt); |  | ||||||
| 				} |  | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 		if (Gdx.input.isKeyPressed(Input.Keys.RIGHT)) { | 		if (Gdx.input.isKeyPressed(Input.Keys.RIGHT)) { | ||||||
| 			if (pos.x + width/2 + PADDLE_SPEED * dt > PlayState.BOARD_WIDTH) { | 			if (pos.x + width / 2 + displacement > PlayState.BOARD_WIDTH-PlayState.EDGE_PADDING) { | ||||||
| 				setX(PlayState.BOARD_WIDTH - width/2); | 				adjust = PlayState.BOARD_WIDTH - PlayState.EDGE_PADDING - width/2 - pos.x; | ||||||
| 				return; | 			} else { | ||||||
|  | 				adjust = displacement; | ||||||
| 			} | 			} | ||||||
| 			setX(pos.x + PADDLE_SPEED * dt); | 		} | ||||||
|  | 		if (!MathUtils.isZero(adjust)) { | ||||||
|  | 			setX(pos.x + adjust); | ||||||
| 			for (Ball ball : state.balls) { | 			for (Ball ball : state.balls) { | ||||||
| 				if (ball.isStuck()) { | 				if (ball.isStuck()) { | ||||||
| 					ball.setX(ball.getX() + PADDLE_SPEED * dt); | 					ball.setX(ball.getX() + adjust); | ||||||
| 				} | 				} | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| @ -88,7 +88,9 @@ public class Paddle extends Entity implements PhysicsBody { | |||||||
|  |  | ||||||
| 		FixtureDef paddleFixture = new FixtureDef(); | 		FixtureDef paddleFixture = new FixtureDef(); | ||||||
| 		paddleFixture.shape = paddleShape; | 		paddleFixture.shape = paddleShape; | ||||||
| 		//paddleFixture.isSensor = true; |  | ||||||
|  | 		paddleFixture.filter.categoryBits = EntityType.PADDLE; | ||||||
|  | 		paddleFixture.filter.maskBits = EntityType.BALL | EntityType.POWER_UP; | ||||||
|  |  | ||||||
| 		body = state.world.createBody(paddleBody); | 		body = state.world.createBody(paddleBody); | ||||||
| 		body.createFixture(paddleFixture); | 		body.createFixture(paddleFixture); | ||||||
|  | |||||||
| @ -8,6 +8,7 @@ import com.badlogic.gdx.physics.box2d.BodyDef; | |||||||
| import com.badlogic.gdx.physics.box2d.FixtureDef; | import com.badlogic.gdx.physics.box2d.FixtureDef; | ||||||
| import com.badlogic.gdx.physics.box2d.PolygonShape; | import com.badlogic.gdx.physics.box2d.PolygonShape; | ||||||
| import com.me.brickbuster.entity.powerup.PowerUpType; | import com.me.brickbuster.entity.powerup.PowerUpType; | ||||||
|  | import com.me.brickbuster.physics.EntityType; | ||||||
| import com.me.brickbuster.physics.PhysicsBody; | import com.me.brickbuster.physics.PhysicsBody; | ||||||
| import com.me.brickbuster.state.PlayState; | import com.me.brickbuster.state.PlayState; | ||||||
|  |  | ||||||
| @ -53,6 +54,9 @@ public class Shield extends Entity implements PhysicsBody { | |||||||
| 		brickFixture.shape = brickShape; | 		brickFixture.shape = brickShape; | ||||||
| 		brickFixture.friction = 0f; | 		brickFixture.friction = 0f; | ||||||
|  |  | ||||||
|  | 		brickFixture.filter.categoryBits = EntityType.SHIELD; | ||||||
|  | 		brickFixture.filter.maskBits = EntityType.BALL; | ||||||
|  |  | ||||||
| 		body = state.world.createBody(brickBody); | 		body = state.world.createBody(brickBody); | ||||||
| 		body.createFixture(brickFixture); | 		body.createFixture(brickFixture); | ||||||
| 		body.setUserData(this); | 		body.setUserData(this); | ||||||
|  | |||||||
| @ -9,9 +9,11 @@ import com.badlogic.gdx.physics.box2d.BodyDef; | |||||||
| import com.badlogic.gdx.physics.box2d.CircleShape; | import com.badlogic.gdx.physics.box2d.CircleShape; | ||||||
| import com.badlogic.gdx.physics.box2d.FixtureDef; | import com.badlogic.gdx.physics.box2d.FixtureDef; | ||||||
| import com.me.brickbuster.Utils; | import com.me.brickbuster.Utils; | ||||||
|  | import com.me.brickbuster.entity.Ball; | ||||||
| import com.me.brickbuster.entity.Entity; | import com.me.brickbuster.entity.Entity; | ||||||
| import com.me.brickbuster.entity.Paddle; | import com.me.brickbuster.entity.Paddle; | ||||||
| import com.me.brickbuster.physics.CollisionListener; | import com.me.brickbuster.physics.CollisionListener; | ||||||
|  | import com.me.brickbuster.physics.EntityType; | ||||||
| import com.me.brickbuster.physics.PhysicsBody; | import com.me.brickbuster.physics.PhysicsBody; | ||||||
| import com.me.brickbuster.state.PlayState; | import com.me.brickbuster.state.PlayState; | ||||||
| import net.dermetfan.utils.Pair; | import net.dermetfan.utils.Pair; | ||||||
| @ -72,6 +74,9 @@ public abstract class PowerUp extends Entity implements PhysicsBody, CollisionLi | |||||||
| 		ballFixture.shape = ballShape; | 		ballFixture.shape = ballShape; | ||||||
| 		ballFixture.isSensor = true; | 		ballFixture.isSensor = true; | ||||||
|  |  | ||||||
|  | 		ballFixture.filter.categoryBits = EntityType.POWER_UP; | ||||||
|  | 		ballFixture.filter.maskBits = EntityType.PADDLE | EntityType.BALL; | ||||||
|  |  | ||||||
| 		body = state.world.createBody(ballBody); | 		body = state.world.createBody(ballBody); | ||||||
| 		body.createFixture(ballFixture); | 		body.createFixture(ballFixture); | ||||||
| 		body.setUserData(this); | 		body.setUserData(this); | ||||||
| @ -83,7 +88,7 @@ public abstract class PowerUp extends Entity implements PhysicsBody, CollisionLi | |||||||
|  |  | ||||||
| 	@Override | 	@Override | ||||||
| 	public void beginContact(Entity contacted) { | 	public void beginContact(Entity contacted) { | ||||||
| 		if (contacted instanceof Paddle) { | 		if (contacted instanceof Paddle || contacted instanceof Ball) { | ||||||
| 			isCaught = true; | 			isCaught = true; | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  | |||||||
| @ -42,9 +42,7 @@ public enum PowerUpType { | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	public PowerUp createInstance(PlayState state, Brick brick) { | 	public PowerUp createInstance(PlayState state, Brick brick) { | ||||||
| 		return createInstance(state, | 		return createInstance(state, new Vector2(brick.getX(), brick.getY())); | ||||||
| 				new Vector2(brick.getX()+Brick.BRICK_WIDTH/2, |  | ||||||
| 							brick.getY()+Brick.BRICK_HEIGHT/2)); |  | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	public PowerUp createInstance(PlayState state, Vector2 pos) { | 	public PowerUp createInstance(PlayState state, Vector2 pos) { | ||||||
|  | |||||||
							
								
								
									
										12
									
								
								core/src/com/me/brickbuster/physics/EntityType.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								core/src/com/me/brickbuster/physics/EntityType.java
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,12 @@ | |||||||
|  | package com.me.brickbuster.physics; | ||||||
|  |  | ||||||
|  | public final class EntityType { | ||||||
|  |  | ||||||
|  | 	public static final short BOUNDARY = 0x1; | ||||||
|  | 	public static final short BALL = 0x1 << 1; | ||||||
|  | 	public static final short BRICK = 0x1 << 2; | ||||||
|  | 	public static final short PADDLE = 0x1 << 3; | ||||||
|  | 	public static final short POWER_UP = 0x1 << 4; | ||||||
|  | 	public static final short SHIELD = 0x1 << 5; | ||||||
|  |  | ||||||
|  | } | ||||||
| @ -11,10 +11,9 @@ import com.me.brickbuster.entity.*; | |||||||
| import com.me.brickbuster.entity.powerup.PowerUp; | import com.me.brickbuster.entity.powerup.PowerUp; | ||||||
| import com.me.brickbuster.entity.powerup.PowerUpType; | import com.me.brickbuster.entity.powerup.PowerUpType; | ||||||
| import com.me.brickbuster.physics.Box2dContactListener; | import com.me.brickbuster.physics.Box2dContactListener; | ||||||
|  | import com.me.brickbuster.physics.EntityType; | ||||||
|  |  | ||||||
| import java.util.ArrayList; |  | ||||||
| import java.util.Iterator; | import java.util.Iterator; | ||||||
| import java.util.List; |  | ||||||
|  |  | ||||||
| public class PlayState extends State { | public class PlayState extends State { | ||||||
|  |  | ||||||
| @ -42,11 +41,11 @@ public class PlayState extends State { | |||||||
| 	public Body playArea; | 	public Body playArea; | ||||||
| 	public Array<Body> bodies; | 	public Array<Body> bodies; | ||||||
|  |  | ||||||
| 	public List<PowerUp> powerUps; | 	public Array<PowerUp> powerUps; | ||||||
| 	public Paddle paddle; | 	public Paddle paddle; | ||||||
| 	public List<Ball> balls; | 	public Array<Ball> balls; | ||||||
| 	public List<Brick> bricks; | 	public Array<Brick> bricks; | ||||||
| 	public List<Shield> shields; | 	public Array<Shield> shields; | ||||||
|  |  | ||||||
| 	private float updateTime = 0f; | 	private float updateTime = 0f; | ||||||
|  |  | ||||||
| @ -62,6 +61,8 @@ public class PlayState extends State { | |||||||
| 		// Initialize a world with no gravity | 		// Initialize a world with no gravity | ||||||
| 		world = new World(new Vector2(), false); | 		world = new World(new Vector2(), false); | ||||||
| 		world.setContactListener(new Box2dContactListener()); | 		world.setContactListener(new Box2dContactListener()); | ||||||
|  | 		bodies = new Array<Body>(); | ||||||
|  |  | ||||||
|  |  | ||||||
| 		// define a playArea body with position set to 0 | 		// define a playArea body with position set to 0 | ||||||
| 		BodyDef playAreaDef = new BodyDef(); | 		BodyDef playAreaDef = new BodyDef(); | ||||||
| @ -70,53 +71,58 @@ public class PlayState extends State { | |||||||
|  |  | ||||||
| 		EdgeShape screenEdge = new EdgeShape(); | 		EdgeShape screenEdge = new EdgeShape(); | ||||||
|  |  | ||||||
|  | 		FixtureDef playAreaFixture = new FixtureDef(); | ||||||
|  | 		playAreaFixture.shape = screenEdge; | ||||||
|  |  | ||||||
|  | 		playAreaFixture.filter.categoryBits = EntityType.BOUNDARY; | ||||||
|  | 		playAreaFixture.filter.maskBits = EntityType.BALL | EntityType.BRICK; | ||||||
|  |  | ||||||
| 		playArea = world.createBody(playAreaDef); | 		playArea = world.createBody(playAreaDef); | ||||||
| 		// Right edge | 		// Right edge | ||||||
| 		screenEdge.set(lowerRightCorner, upperRightCorner); | 		screenEdge.set(lowerRightCorner, upperRightCorner); | ||||||
| 		playArea.createFixture(screenEdge, 0f); | 		playArea.createFixture(playAreaFixture); | ||||||
| 		// Top edge | 		// Top edge | ||||||
| 		screenEdge.set(upperRightCorner, upperLeftCorner); | 		screenEdge.set(upperRightCorner, upperLeftCorner); | ||||||
| 		playArea.createFixture(screenEdge, 0f); | 		playArea.createFixture(playAreaFixture); | ||||||
| 		// Left edge | 		// Left edge | ||||||
| 		screenEdge.set(upperLeftCorner, lowerLeftCorner); | 		screenEdge.set(upperLeftCorner, lowerLeftCorner); | ||||||
| 		playArea.createFixture(screenEdge, 0f); | 		playArea.createFixture(playAreaFixture); | ||||||
| 		// Bottom edge | 		// Bottom edge | ||||||
| 		//screenEdge.set(lowerLeftCorner, lowerRightCorner); | 		//screenEdge.set(lowerLeftCorner, lowerRightCorner); | ||||||
| 		//playArea.createFixture(screenEdge, 0f); | 		//playArea.createFixture(playAreaFixture); | ||||||
| 		screenEdge.dispose(); | 		screenEdge.dispose(); | ||||||
|  |  | ||||||
| 		powerUps = new ArrayList<PowerUp>(); | 		powerUps = new Array<PowerUp>(); | ||||||
| 		paddle = new Paddle(this); | 		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 ArrayList<Brick>(); | 		bricks = new Array<Brick>(); | ||||||
| 		for (int col = 0; col < COLUMNS; col++) { | 		for (int col = 0; col < COLUMNS; col++) { | ||||||
| 			for (int row = 0; row < ROWS; row++) { | 			for (int row = ROWS-1; row >= 0; row--) { | ||||||
| 				float x = brick_padding + (col * (Brick.BRICK_WIDTH + brick_padding)); | 				float x = brick_padding + Brick.BRICK_WIDTH/2 + (col * (Brick.BRICK_WIDTH + brick_padding)); | ||||||
| 				float y = brick_padding + Brick.BRICK_HEIGHT + (row * (Brick.BRICK_HEIGHT + brick_padding)); | 				float y = brick_padding + Brick.BRICK_HEIGHT/2 + (row * (Brick.BRICK_HEIGHT + brick_padding)); | ||||||
|  |  | ||||||
| 				PowerUpType powerUpType = null; | 				PowerUpType powerUpType = null; | ||||||
| 				if (MathUtils.randomBoolean(POWERUP_CHANCE)) { | 				if (MathUtils.randomBoolean(POWERUP_CHANCE)) { | ||||||
| 					powerUpType = PowerUpType.getWeightedRandom(); | 					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)); | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		balls = new ArrayList<Ball>(); | 		balls = new Array<Ball>(); | ||||||
| 		balls.add(new Ball(this)); | 		balls.add(new Ball(this)); | ||||||
|  |  | ||||||
| 		shields = new ArrayList<Shield>(); | 		shields = new Array<Shield>(); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	@Override | 	@Override | ||||||
| 	public void render() { | 	public void render() { | ||||||
| 		Array<Body> bodies = new Array<Body>(); |  | ||||||
| 		world.getBodies(bodies); | 		world.getBodies(bodies); | ||||||
| 		for (Body b : bodies) { | 		for (Body b : bodies) { | ||||||
| 			Entity e = (Entity) b.getUserData(); | 			Entity e = (Entity) b.getUserData(); | ||||||
| 			if (e instanceof Ball || e instanceof PowerUp) { | 			if (e instanceof Ball || e instanceof PowerUp || e instanceof Brick) { | ||||||
| 				e.setPos(b.getPosition()); | 				e.setPos(b.getPosition()); | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| @ -159,7 +165,7 @@ public class PlayState extends State { | |||||||
| 				world.destroyBody(ball.getBody()); | 				world.destroyBody(ball.getBody()); | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 		if (balls.isEmpty()) { | 		if (balls.size == 0) { | ||||||
| 			ballReset(); | 			ballReset(); | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| @ -189,7 +195,7 @@ public class PlayState extends State { | |||||||
| 				world.destroyBody(brick.getBody()); | 				world.destroyBody(brick.getBody()); | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 		if (bricks.isEmpty()) { | 		if (bricks.size == 0) { | ||||||
| 			game.setScreen(new MenuState(game)); | 			game.setScreen(new MenuState(game)); | ||||||
| 			dispose(); | 			dispose(); | ||||||
| 			return; | 			return; | ||||||
| @ -202,9 +208,10 @@ public class PlayState extends State { | |||||||
| 	@Override | 	@Override | ||||||
| 	public void dispose() { | 	public void dispose() { | ||||||
| 		super.dispose(); | 		super.dispose(); | ||||||
|  |  | ||||||
| 		world.dispose(); | 		world.dispose(); | ||||||
|  |  | ||||||
|  | 		bodies.clear(); | ||||||
|  |  | ||||||
| 		powerUps.clear(); | 		powerUps.clear(); | ||||||
| 		powerUps = null; | 		powerUps = null; | ||||||
| 		balls.clear(); | 		balls.clear(); | ||||||
| @ -215,7 +222,7 @@ public class PlayState extends State { | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	public int getShieldCount() { | 	public int getShieldCount() { | ||||||
| 		return shields.size(); | 		return shields.size; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	public void addShield() { | 	public void addShield() { | ||||||
|  | |||||||
| @ -26,6 +26,10 @@ public abstract class State extends ScreenAdapter { | |||||||
| 		this.disposed = true; | 		this.disposed = true; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | 	public BrickBuster getGame() { | ||||||
|  | 		return game; | ||||||
|  | 	} | ||||||
|  |  | ||||||
| 	public abstract void setup(); | 	public abstract void setup(); | ||||||
|  |  | ||||||
| 	public abstract void render(); | 	public abstract void render(); | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user