diff --git a/core/src/com/me/brickbuster/BrickBuster.java b/core/src/com/me/brickbuster/BrickBuster.java index e08d99d..ca6a188 100644 --- a/core/src/com/me/brickbuster/BrickBuster.java +++ b/core/src/com/me/brickbuster/BrickBuster.java @@ -78,15 +78,15 @@ public class BrickBuster extends ApplicationAdapter { long start_render = System.nanoTime(); for (Brick block : bricks) { - block.render(); + block.render(sr); } for (PowerUp powerUp : powerUps) { - powerUp.render(); + powerUp.render(sr); } for (Ball ball : balls) { - ball.render(); + ball.render(sr); } - paddle.render(); + paddle.render(sr); if (shieldActive) { sr.begin(ShapeRenderer.ShapeType.Filled); diff --git a/core/src/com/me/brickbuster/entity/Ball.java b/core/src/com/me/brickbuster/entity/Ball.java index 59c9b28..32fb261 100644 --- a/core/src/com/me/brickbuster/entity/Ball.java +++ b/core/src/com/me/brickbuster/entity/Ball.java @@ -2,6 +2,7 @@ package com.me.brickbuster.entity; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.graphics.Color; +import com.badlogic.gdx.graphics.glutils.ShapeRenderer; import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType; import com.badlogic.gdx.math.MathUtils; import com.badlogic.gdx.math.Vector2; @@ -30,11 +31,11 @@ public class Ball extends Entity { } @Override - public void render() { - getShapeRenderer().begin(ShapeType.Filled); - getShapeRenderer().setColor(BALL_COLOR); - getShapeRenderer().circle(getPos().x, getPos().y, RADIUS); - getShapeRenderer().end(); + public void render(ShapeRenderer sr) { + sr.begin(ShapeType.Filled); + sr.setColor(BALL_COLOR); + sr.circle(getPos().x, getPos().y, RADIUS); + sr.end(); } @Override diff --git a/core/src/com/me/brickbuster/entity/Brick.java b/core/src/com/me/brickbuster/entity/Brick.java index 7bd4af3..d957cd5 100644 --- a/core/src/com/me/brickbuster/entity/Brick.java +++ b/core/src/com/me/brickbuster/entity/Brick.java @@ -1,6 +1,7 @@ package com.me.brickbuster.entity; import com.badlogic.gdx.graphics.Color; +import com.badlogic.gdx.graphics.glutils.ShapeRenderer; import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType; import com.badlogic.gdx.math.Vector2; import com.me.brickbuster.BrickBuster; @@ -28,11 +29,11 @@ public class Brick extends Entity { } @Override - public void render() { - getShapeRenderer().begin(ShapeType.Filled); - getShapeRenderer().setColor(BLOCK_COLOR); - getShapeRenderer().rect(getX(), getY(), BLOCK_WIDTH, BLOCK_HEIGHT); - getShapeRenderer().end(); + public void render(ShapeRenderer sr) { + sr.begin(ShapeType.Filled); + sr.setColor(BLOCK_COLOR); + sr.rect(getX(), getY(), BLOCK_WIDTH, BLOCK_HEIGHT); + sr.end(); } @Override diff --git a/core/src/com/me/brickbuster/entity/Entity.java b/core/src/com/me/brickbuster/entity/Entity.java index c0c36d8..208dbc0 100644 --- a/core/src/com/me/brickbuster/entity/Entity.java +++ b/core/src/com/me/brickbuster/entity/Entity.java @@ -6,17 +6,15 @@ import com.me.brickbuster.BrickBuster; public abstract class Entity { - private ShapeRenderer shapeRenderer; private BrickBuster brickBuster; private Vector2 pos; public Entity(BrickBuster brickBuster, float x, float y) { - this.shapeRenderer = new ShapeRenderer(); this.brickBuster = brickBuster; this.pos = new Vector2(x, y); } - public abstract void render(); + public abstract void render(ShapeRenderer sr); public abstract void update(float dt); @@ -24,10 +22,6 @@ public abstract class Entity { return brickBuster; } - public ShapeRenderer getShapeRenderer() { - return shapeRenderer; - } - public Vector2 getPos() { return pos; } diff --git a/core/src/com/me/brickbuster/entity/Paddle.java b/core/src/com/me/brickbuster/entity/Paddle.java index 28a18a8..f4ada06 100644 --- a/core/src/com/me/brickbuster/entity/Paddle.java +++ b/core/src/com/me/brickbuster/entity/Paddle.java @@ -3,6 +3,7 @@ package com.me.brickbuster.entity; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Input; import com.badlogic.gdx.graphics.Color; +import com.badlogic.gdx.graphics.glutils.ShapeRenderer; import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType; import com.badlogic.gdx.math.Vector2; import com.me.brickbuster.BrickBuster; @@ -24,11 +25,11 @@ public class Paddle extends Entity { } @Override - public void render() { - getShapeRenderer().begin(ShapeType.Filled); - getShapeRenderer().setColor(sticky? Color.GRAY : PADDLE_COLOR); - getShapeRenderer().rect(getX() - width/2, getY(), width, PADDLE_HEIGHT); - getShapeRenderer().end(); + public void render(ShapeRenderer sr) { + sr.begin(ShapeType.Filled); + sr.setColor(sticky? Color.GRAY : PADDLE_COLOR); + sr.rect(getX() - width/2, getY(), width, PADDLE_HEIGHT); + sr.end(); } @Override diff --git a/core/src/com/me/brickbuster/entity/powerup/PowerUp.java b/core/src/com/me/brickbuster/entity/powerup/PowerUp.java index 09dcef3..63d43ae 100644 --- a/core/src/com/me/brickbuster/entity/powerup/PowerUp.java +++ b/core/src/com/me/brickbuster/entity/powerup/PowerUp.java @@ -2,6 +2,7 @@ package com.me.brickbuster.entity.powerup; import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.glutils.ShapeRenderer; +import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType; import com.badlogic.gdx.math.Vector2; import com.me.brickbuster.BrickBuster; import com.me.brickbuster.Utils; @@ -23,11 +24,11 @@ public abstract class PowerUp extends Entity { } @Override - public void render() { - getShapeRenderer().begin(ShapeRenderer.ShapeType.Filled); - getShapeRenderer().setColor(color); - getShapeRenderer().circle(getX(), getY(), RADIUS); - getShapeRenderer().end(); + public void render(ShapeRenderer sr) { + sr.begin(ShapeType.Filled); + sr.setColor(color); + sr.circle(getX(), getY(), RADIUS); + sr.end(); } @Override