background shader render progress, replacing shape renderers with texture (haven't created said textures yet)

This commit is contained in:
2017-06-10 12:34:08 -05:00
parent d036900399
commit cf07c14f86
11 changed files with 106 additions and 75 deletions

View File

@@ -2,7 +2,6 @@ package zero1hd.polyjet.entity;
import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.Pool;
@@ -15,7 +14,6 @@ import zero1hd.polyjet.entity.enemies.VoidCircle;
public class EntityController {
AssetManager assets;
public ShapeRenderer shapes;
public Array<Entity> activeAllies;
public Array<Entity> activeEnemies;
@@ -30,19 +28,16 @@ public class EntityController {
//Ally pool declaration;
private Pool<Laser> laserPool;
public EntityController(AssetManager assetManager, ShapeRenderer shapeRenderer) {
public EntityController(AssetManager assetManager) {
activeAllies = new Array<Entity>();
activeEnemies = new Array<Entity>();
this.assets = assetManager;
this.shapes = shapeRenderer;
shapes.setAutoShapeType(true);
//Enemy pool initialization;
voidCirclePool = new Pool<VoidCircle>() {
@Override
protected VoidCircle newObject() {
return new VoidCircle(shapes);
return new VoidCircle(assets.get("void_circle.png", Texture.class));
}
};
pelletPool = new Pool<Pellet>() {

View File

@@ -1,9 +1,9 @@
package zero1hd.polyjet.entity.enemies;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.scenes.scene2d.Actor;
@@ -18,16 +18,16 @@ public class VoidCircle extends Actor implements Entity, Poolable {
private float endRadius;
private float currentRadius;
private Rectangle hitBox;
private ShapeRenderer shapeRenderer;
private Sprite voidCircleTexture;
private float growthRate;
private boolean done;
private boolean begin;
private Vector2 center;
public VoidCircle(ShapeRenderer shapeRenderer) {
public VoidCircle(Texture voidTexture) {
hitBox = new Rectangle();
this.shapeRenderer = shapeRenderer;
center = new Vector2();
voidCircleTexture = new Sprite(voidTexture);
}
public void init(float endRadius, float x, float y, float growthRate, float warningTime) {
@@ -43,6 +43,7 @@ public VoidCircle(ShapeRenderer shapeRenderer) {
@Override
public void act(float delta) {
toFront();
voidCircleTexture.setCenter(getX()+center.x, getY()+center.y);
hitBox.setCenter(getX()+center.x, getY()+center.y);
if (timer > 0) {
@@ -66,21 +67,16 @@ public VoidCircle(ShapeRenderer shapeRenderer) {
@Override
public void draw(Batch batch, float parentAlpha) {
batch.end();
shapeRenderer.begin();
if (begin) {
shapeRenderer.set(ShapeType.Filled);
shapeRenderer.setColor(Color.BLACK);
shapeRenderer.circle(getX()+center.x, getY()+center.y, currentRadius, 48);
voidCircleTexture.setSize(2*currentRadius, 2*currentRadius);
voidCircleTexture.setCenter(getX()+center.x, getY()+center.y);
} else {
shapeRenderer.set(ShapeType.Line);
shapeRenderer.setColor(1 - timer/warnTime, 1 - timer/warnTime, 1 - timer/warnTime, 1f);
shapeRenderer.circle(getX()+center.x, getY()+center.y, endRadius, 48);
voidCircleTexture.setSize(2*endRadius, 2*endRadius);
voidCircleTexture.setColor(1f,0f,0f,0.5f);
voidCircleTexture.draw(batch);
}
shapeRenderer.end();
batch.begin();
batch.setColor(Color.WHITE);
super.draw(batch, parentAlpha);
}
@@ -95,6 +91,7 @@ public VoidCircle(ShapeRenderer shapeRenderer) {
begin = false;
warnTime = 0;
center.set(0, 0);
voidCircleTexture.setPosition(0, 0);
setSize(0, 0);
}