successfully added debug spawning system and finished void circle enemy
This commit is contained in:
parent
70bf120a5f
commit
b17cc61839
@ -154,6 +154,13 @@ default-slider-knob
|
|||||||
orig: 9, 18
|
orig: 9, 18
|
||||||
offset: 0, 0
|
offset: 0, 0
|
||||||
index: -1
|
index: -1
|
||||||
|
vertical-slider-knob
|
||||||
|
rotate: false
|
||||||
|
xy: 27, 1
|
||||||
|
size: 13, 5
|
||||||
|
orig: 13, 5
|
||||||
|
offset: 0, 0
|
||||||
|
index: -1
|
||||||
default-splitpane
|
default-splitpane
|
||||||
rotate: false
|
rotate: false
|
||||||
xy: 17, 1
|
xy: 17, 1
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 4.4 KiB |
@ -194,6 +194,10 @@ public class Polyjet extends Game {
|
|||||||
SliderStyle defaultSlider = new SliderStyle(getDefaultSkin().getDrawable("default-slider"), getDefaultSkin().getDrawable("default-slider-knob"));
|
SliderStyle defaultSlider = new SliderStyle(getDefaultSkin().getDrawable("default-slider"), getDefaultSkin().getDrawable("default-slider-knob"));
|
||||||
getDefaultSkin().add("default-horizontal", defaultSlider);
|
getDefaultSkin().add("default-horizontal", defaultSlider);
|
||||||
|
|
||||||
|
SliderStyle vertSlider = new SliderStyle(defaultSlider);
|
||||||
|
vertSlider.knob = getDefaultSkin().getDrawable("vertical-slider-knob");
|
||||||
|
getDefaultSkin().add("default-vertical", vertSlider);
|
||||||
|
|
||||||
ButtonStyle infoButton = new ButtonStyle();
|
ButtonStyle infoButton = new ButtonStyle();
|
||||||
infoButton.up = getDefaultSkin().getDrawable("holo-pane");
|
infoButton.up = getDefaultSkin().getDrawable("holo-pane");
|
||||||
infoButton.down = getDefaultSkin().getDrawable("holo-pane-down");
|
infoButton.down = getDefaultSkin().getDrawable("holo-pane-down");
|
||||||
@ -207,6 +211,10 @@ public class Polyjet extends Game {
|
|||||||
TextFieldStyle defaultTextField = new TextFieldStyle(getDefaultSkin().getFont("sub-font"), getDefaultSkin().getColor("default"), getDefaultSkin().getDrawable("cursor"), getDefaultSkin().getDrawable("selection"), getDefaultSkin().getDrawable("textfield"));
|
TextFieldStyle defaultTextField = new TextFieldStyle(getDefaultSkin().getFont("sub-font"), getDefaultSkin().getColor("default"), getDefaultSkin().getDrawable("cursor"), getDefaultSkin().getDrawable("selection"), getDefaultSkin().getDrawable("textfield"));
|
||||||
getDefaultSkin().add("default", defaultTextField);
|
getDefaultSkin().add("default", defaultTextField);
|
||||||
|
|
||||||
|
TextFieldStyle uiTextField = new TextFieldStyle(defaultTextField);
|
||||||
|
uiTextField.font = getDefaultSkin().getFont("window-font");
|
||||||
|
getDefaultSkin().add("ui", uiTextField);
|
||||||
|
|
||||||
WindowStyle defaultWindow = new WindowStyle(getDefaultSkin().getFont("window-font"), getDefaultSkin().getColor("default"), getDefaultSkin().getDrawable("default-window"));
|
WindowStyle defaultWindow = new WindowStyle(getDefaultSkin().getFont("window-font"), getDefaultSkin().getColor("default"), getDefaultSkin().getDrawable("default-window"));
|
||||||
getDefaultSkin().add("default", defaultWindow);
|
getDefaultSkin().add("default", defaultWindow);
|
||||||
|
|
||||||
@ -215,7 +223,7 @@ public class Polyjet extends Game {
|
|||||||
tintedWindow.background = getDefaultSkin().getDrawable("tinted-window");
|
tintedWindow.background = getDefaultSkin().getDrawable("tinted-window");
|
||||||
getDefaultSkin().add("tinted", tintedWindow);
|
getDefaultSkin().add("tinted", tintedWindow);
|
||||||
|
|
||||||
ListStyle defaultList = new ListStyle(getDefaultSkin().getFont("sub-font"), getDefaultSkin().getColor("inverse"), getDefaultSkin().getColor("default"), getDefaultSkin().getDrawable("selection"));
|
ListStyle defaultList = new ListStyle(getDefaultSkin().getFont("window-font"), getDefaultSkin().getColor("inverse"), getDefaultSkin().getColor("default"), getDefaultSkin().getDrawable("selection"));
|
||||||
getDefaultSkin().add("default", defaultList);
|
getDefaultSkin().add("default", defaultList);
|
||||||
|
|
||||||
ScrollPaneStyle defaultScrollPane = new ScrollPaneStyle();
|
ScrollPaneStyle defaultScrollPane = new ScrollPaneStyle();
|
||||||
|
@ -7,25 +7,24 @@ public class CollisionDetector {
|
|||||||
Array<Entity> firstGroup;
|
Array<Entity> firstGroup;
|
||||||
Array<Entity> secondGroup;
|
Array<Entity> secondGroup;
|
||||||
|
|
||||||
private boolean debug = true;
|
|
||||||
|
|
||||||
public CollisionDetector(Array<Entity> firstGroup, Array<Entity> secondGroup) {
|
public CollisionDetector(Array<Entity> firstGroup, Array<Entity> secondGroup) {
|
||||||
this.firstGroup = firstGroup;
|
this.firstGroup = firstGroup;
|
||||||
this.secondGroup = secondGroup;
|
this.secondGroup = secondGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void collisionCheck() {
|
public void collisionCheck() {
|
||||||
if (debug) {
|
if ((firstGroup.size != 0) && (secondGroup.size != 0)) {
|
||||||
Gdx.app.debug("collision check", "First group size: " + firstGroup.size);
|
for (int f = 0; f < firstGroup.size; f++) {
|
||||||
Gdx.app.debug("collision check", "Second group size: " + secondGroup.size);
|
Entity fe = firstGroup.get(f);
|
||||||
}
|
for (int s = 0; s < secondGroup.size; s++) {
|
||||||
|
Entity se = secondGroup.get(s);
|
||||||
|
|
||||||
for (int firstEID = 0; firstEID < firstGroup.size; firstEID++) {
|
if (fe.getHitZone().overlaps(se.getHitZone())) {
|
||||||
for (int secondEID = 0; secondEID < secondGroup.size; secondEID++) {
|
Gdx.app.debug("Collision Detector", "Collision between entities: " + fe.getEntityType() + " and " + se.getEntityType());
|
||||||
if (firstGroup.get(firstEID).getHitZone().overlaps(secondGroup.get(secondEID).getHitZone())) {
|
|
||||||
firstGroup.get(firstEID).collided(secondGroup.get(secondEID));
|
fe.collided(se);
|
||||||
secondGroup.get(secondEID).collided(firstGroup.get(firstEID));
|
se.collided(fe);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,21 +14,23 @@ public class EntityController {
|
|||||||
AssetManager assets;
|
AssetManager assets;
|
||||||
ShapeRenderer shapes;
|
ShapeRenderer shapes;
|
||||||
|
|
||||||
public final Array<Entity> ACTIVE_ALLIES;
|
public Array<Entity> activeAllies;
|
||||||
public final Array<Entity> ACTIVE_ENEMIES;
|
public Array<Entity> activeEnemies;
|
||||||
//Enemy pool declaration;
|
//Enemy pool declaration;
|
||||||
private final Pool<VoidCircle> VOID_CIRCLE_POOL;
|
private Pool<VoidCircle> voidCirclePool;
|
||||||
|
|
||||||
//Ally pool declaration;
|
//Ally pool declaration;
|
||||||
private final Pool<Laser> LASER_POOL;
|
private Pool<Laser> laserPool;
|
||||||
public EntityController(ShapeRenderer shapeRenderer, AssetManager assetManager) {
|
public EntityController(AssetManager assetManager, ShapeRenderer shapeRenderer) {
|
||||||
ACTIVE_ALLIES = new Array<Entity>();
|
activeAllies = new Array<Entity>();
|
||||||
ACTIVE_ENEMIES = new Array<Entity>();
|
activeEnemies = new Array<Entity>();
|
||||||
this.assets = assetManager;
|
this.assets = assetManager;
|
||||||
|
|
||||||
this.shapes = shapeRenderer;
|
this.shapes = shapeRenderer;
|
||||||
|
shapes.setAutoShapeType(true);
|
||||||
|
|
||||||
//Enemy pool initialization;
|
//Enemy pool initialization;
|
||||||
VOID_CIRCLE_POOL = new Pool<VoidCircle>() {
|
voidCirclePool = new Pool<VoidCircle>() {
|
||||||
@Override
|
@Override
|
||||||
protected VoidCircle newObject() {
|
protected VoidCircle newObject() {
|
||||||
return new VoidCircle(shapes);
|
return new VoidCircle(shapes);
|
||||||
@ -36,7 +38,7 @@ public class EntityController {
|
|||||||
};
|
};
|
||||||
|
|
||||||
//Ally pool initialization;
|
//Ally pool initialization;
|
||||||
LASER_POOL = new Pool<Laser>() {
|
laserPool = new Pool<Laser>() {
|
||||||
@Override
|
@Override
|
||||||
protected Laser newObject() {
|
protected Laser newObject() {
|
||||||
return new Laser(assets.get("laser.png", Texture.class));
|
return new Laser(assets.get("laser.png", Texture.class));
|
||||||
@ -46,19 +48,18 @@ public class EntityController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Entity retrieveEntity(Entities entity) {
|
public Entity retrieveEntity(Entities entity) {
|
||||||
Gdx.app.debug("EntityController", "spawning entity " + entity.name());
|
|
||||||
switch (entity) {
|
switch (entity) {
|
||||||
case VOID_CIRCLE:
|
case VOID_CIRCLE:
|
||||||
VoidCircle voidCircle = VOID_CIRCLE_POOL.obtain();
|
VoidCircle voidCircle = voidCirclePool.obtain();
|
||||||
ACTIVE_ENEMIES.add(voidCircle);
|
activeEnemies.add(voidCircle);
|
||||||
return voidCircle;
|
return voidCircle;
|
||||||
case BAR_BEAT:
|
case BAR_BEAT:
|
||||||
return null;
|
return null;
|
||||||
case SHARDS:
|
case SHARDS:
|
||||||
return null;
|
return null;
|
||||||
case LASER:
|
case LASER:
|
||||||
Laser laser = LASER_POOL.obtain();
|
Laser laser = laserPool.obtain();
|
||||||
ACTIVE_ALLIES.add(laser);
|
activeAllies.add(laser);
|
||||||
return laser;
|
return laser;
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
@ -74,14 +75,14 @@ public class EntityController {
|
|||||||
case VOID_CIRCLE:
|
case VOID_CIRCLE:
|
||||||
VoidCircle voidCircle = (VoidCircle) entity;
|
VoidCircle voidCircle = (VoidCircle) entity;
|
||||||
voidCircle.remove();
|
voidCircle.remove();
|
||||||
ACTIVE_ENEMIES.removeValue(entity, true);
|
activeEnemies.removeValue(entity, true);
|
||||||
VOID_CIRCLE_POOL.free(voidCircle);
|
voidCirclePool.free(voidCircle);
|
||||||
break;
|
break;
|
||||||
case LASER:
|
case LASER:
|
||||||
Laser laser = (Laser) entity;
|
Laser laser = (Laser) entity;
|
||||||
laser.remove();
|
laser.remove();
|
||||||
ACTIVE_ALLIES.removeValue(entity, true);
|
activeAllies.removeValue(entity, true);
|
||||||
LASER_POOL.free(laser);
|
laserPool.free(laser);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package zero1hd.polyjet.entity.ally;
|
package zero1hd.polyjet.entity.ally;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.graphics.Texture;
|
import com.badlogic.gdx.graphics.Texture;
|
||||||
import com.badlogic.gdx.graphics.g2d.Batch;
|
import com.badlogic.gdx.graphics.g2d.Batch;
|
||||||
import com.badlogic.gdx.math.Rectangle;
|
import com.badlogic.gdx.math.Rectangle;
|
||||||
@ -18,13 +19,15 @@ public class Laser extends Actor implements Entity, Poolable {
|
|||||||
|
|
||||||
public Laser(Texture laserTexture) {
|
public Laser(Texture laserTexture) {
|
||||||
this.laserTexture = laserTexture;
|
this.laserTexture = laserTexture;
|
||||||
|
setSize(0.25f, 1f);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init(float x, float y, float rate) {
|
public void init(float x, float y, float rate) {
|
||||||
|
Gdx.app.debug("Laser", "Pos: " + x + "," + y);
|
||||||
|
|
||||||
setX(x);
|
setX(x);
|
||||||
setY(y);
|
setY(y);
|
||||||
this.rate = rate;
|
this.rate = rate;
|
||||||
setSize(0.25f, 1f);
|
|
||||||
hitBox = new Rectangle();
|
hitBox = new Rectangle();
|
||||||
hitBox.setSize(getWidth(), getHeight());
|
hitBox.setSize(getWidth(), getHeight());
|
||||||
}
|
}
|
||||||
@ -51,7 +54,6 @@ public class Laser extends Actor implements Entity, Poolable {
|
|||||||
public void reset() {
|
public void reset() {
|
||||||
setX(0);
|
setX(0);
|
||||||
setY(0);
|
setY(0);
|
||||||
setSize(0, 0);
|
|
||||||
rate = 0;
|
rate = 0;
|
||||||
hitBox.set(0, 0, 0, 0);
|
hitBox.set(0, 0, 0, 0);
|
||||||
dead = false;
|
dead = false;
|
||||||
|
@ -6,6 +6,7 @@ import com.badlogic.gdx.graphics.g2d.Batch;
|
|||||||
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.Rectangle;
|
import com.badlogic.gdx.math.Rectangle;
|
||||||
|
import com.badlogic.gdx.math.Vector2;
|
||||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||||
import com.badlogic.gdx.utils.Pool.Poolable;
|
import com.badlogic.gdx.utils.Pool.Poolable;
|
||||||
|
|
||||||
@ -13,6 +14,7 @@ import zero1hd.polyjet.entity.Entities;
|
|||||||
import zero1hd.polyjet.entity.Entity;
|
import zero1hd.polyjet.entity.Entity;
|
||||||
|
|
||||||
public class VoidCircle extends Actor implements Entity, Poolable {
|
public class VoidCircle extends Actor implements Entity, Poolable {
|
||||||
|
private float warnTime;
|
||||||
private float timer;
|
private float timer;
|
||||||
private float endRadius;
|
private float endRadius;
|
||||||
private float currentRadius;
|
private float currentRadius;
|
||||||
@ -21,24 +23,29 @@ public class VoidCircle extends Actor implements Entity, Poolable {
|
|||||||
private float growthRate;
|
private float growthRate;
|
||||||
private boolean done;
|
private boolean done;
|
||||||
private boolean begin;
|
private boolean begin;
|
||||||
|
private Vector2 center;
|
||||||
public VoidCircle(ShapeRenderer shapeRenderer) {
|
public VoidCircle(ShapeRenderer shapeRenderer) {
|
||||||
hitBox = new Rectangle();
|
hitBox = new Rectangle();
|
||||||
this.shapeRenderer = shapeRenderer;
|
this.shapeRenderer = shapeRenderer;
|
||||||
|
center = new Vector2();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init(float endRadius, float x, float y, float growthRate, float warningTime) {
|
public void init(float endRadius, float x, float y, float growthRate, float warningTime) {
|
||||||
Gdx.app.debug("Void Circle", "Initiated.");
|
|
||||||
timer = warningTime;
|
timer = warningTime;
|
||||||
|
warnTime = warningTime;
|
||||||
this.endRadius = endRadius;
|
this.endRadius = endRadius;
|
||||||
setSize(2*endRadius, 2*endRadius);
|
setSize(2f*endRadius, 2f*endRadius);
|
||||||
setX(x);
|
setX(x - getWidth()/2f);
|
||||||
setY(y);
|
setY(y - getWidth()/2f);
|
||||||
this.growthRate = growthRate;
|
this.growthRate = growthRate;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void act(float delta) {
|
public void act(float delta) {
|
||||||
hitBox.setPosition(getX(), getY());
|
center.x = getX()+getWidth()/2f;
|
||||||
|
center.y = getY()+getHeight()/2f;
|
||||||
|
hitBox.setCenter(center.x, center.y);
|
||||||
|
|
||||||
if (timer > 0) {
|
if (timer > 0) {
|
||||||
timer -= delta;
|
timer -= delta;
|
||||||
} else {
|
} else {
|
||||||
@ -57,6 +64,7 @@ public VoidCircle(ShapeRenderer shapeRenderer) {
|
|||||||
super.act(delta);
|
super.act(delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Batch batch, float parentAlpha) {
|
public void draw(Batch batch, float parentAlpha) {
|
||||||
batch.end();
|
batch.end();
|
||||||
@ -64,11 +72,12 @@ public VoidCircle(ShapeRenderer shapeRenderer) {
|
|||||||
if (begin) {
|
if (begin) {
|
||||||
shapeRenderer.set(ShapeType.Filled);
|
shapeRenderer.set(ShapeType.Filled);
|
||||||
shapeRenderer.setColor(Color.BLACK);
|
shapeRenderer.setColor(Color.BLACK);
|
||||||
shapeRenderer.circle(getX(), getY(), currentRadius);
|
shapeRenderer.circle(center.x, center.y, currentRadius, 48);
|
||||||
|
} else {
|
||||||
|
shapeRenderer.set(ShapeType.Line);
|
||||||
|
shapeRenderer.setColor(1 - timer/warnTime, 1 - timer/warnTime, 1 - timer/warnTime, 1f);
|
||||||
|
shapeRenderer.circle(center.x, center.y, endRadius, 48);
|
||||||
}
|
}
|
||||||
shapeRenderer.set(ShapeType.Line);
|
|
||||||
shapeRenderer.setColor(Color.RED);
|
|
||||||
shapeRenderer.circle(getX(), getY(), endRadius);
|
|
||||||
shapeRenderer.end();
|
shapeRenderer.end();
|
||||||
batch.begin();
|
batch.begin();
|
||||||
|
|
||||||
@ -85,18 +94,15 @@ public VoidCircle(ShapeRenderer shapeRenderer) {
|
|||||||
endRadius = 0;
|
endRadius = 0;
|
||||||
done = false;
|
done = false;
|
||||||
begin = false;
|
begin = false;
|
||||||
|
warnTime = 0;
|
||||||
|
center.set(0, 0);
|
||||||
|
setSize(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCurrentRadius(float currentRadius) {
|
public void growCurrentRadius(float radius) {
|
||||||
this.currentRadius = currentRadius;
|
currentRadius += radius;
|
||||||
hitBox.setSize(2*(currentRadius*currentRadius));
|
float length = (float) Math.sqrt(2*(currentRadius*currentRadius));
|
||||||
hitBox.setCenter(getX(), getY());
|
hitBox.setSize(length, length);
|
||||||
}
|
|
||||||
|
|
||||||
public void growCurrentRadius(float currentRadius) {
|
|
||||||
this.currentRadius += currentRadius;
|
|
||||||
hitBox.setSize(2*(currentRadius*currentRadius));
|
|
||||||
hitBox.setCenter(getX(), getY());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -4,7 +4,6 @@ import com.badlogic.gdx.Gdx;
|
|||||||
import com.badlogic.gdx.InputMultiplexer;
|
import com.badlogic.gdx.InputMultiplexer;
|
||||||
import com.badlogic.gdx.ScreenAdapter;
|
import com.badlogic.gdx.ScreenAdapter;
|
||||||
import com.badlogic.gdx.graphics.GL20;
|
import com.badlogic.gdx.graphics.GL20;
|
||||||
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
|
|
||||||
|
|
||||||
import zero1hd.polyjet.Polyjet;
|
import zero1hd.polyjet.Polyjet;
|
||||||
import zero1hd.polyjet.ui.stages.CreativeStage;
|
import zero1hd.polyjet.ui.stages.CreativeStage;
|
||||||
@ -15,15 +14,10 @@ public class CreativeDebugScreen extends ScreenAdapter {
|
|||||||
GamePlayArea gamePlayArea;
|
GamePlayArea gamePlayArea;
|
||||||
InputMultiplexer inputs;
|
InputMultiplexer inputs;
|
||||||
|
|
||||||
ShapeRenderer shapes;
|
|
||||||
|
|
||||||
public CreativeDebugScreen(Polyjet core, MainMenu mainMenu) {
|
public CreativeDebugScreen(Polyjet core, MainMenu mainMenu) {
|
||||||
gamePlayArea = new GamePlayArea(core.getAssetManager(), shapes);
|
gamePlayArea = new GamePlayArea(core.getAssetManager());
|
||||||
creative = new CreativeStage(core, mainMenu, gamePlayArea);
|
creative = new CreativeStage(core, mainMenu, gamePlayArea);
|
||||||
|
|
||||||
shapes = new ShapeRenderer();
|
|
||||||
shapes.setAutoShapeType(true);
|
|
||||||
|
|
||||||
inputs = new InputMultiplexer(creative, gamePlayArea);
|
inputs = new InputMultiplexer(creative, gamePlayArea);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,7 +31,8 @@ public class CreativeDebugScreen extends ScreenAdapter {
|
|||||||
public void render(float delta) {
|
public void render(float delta) {
|
||||||
Gdx.gl.glClearColor(1f, 1f, 1f, 1f);
|
Gdx.gl.glClearColor(1f, 1f, 1f, 1f);
|
||||||
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);
|
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);
|
||||||
|
Gdx.gl.glLineWidth(1f);
|
||||||
|
|
||||||
gamePlayArea.getViewport().apply();
|
gamePlayArea.getViewport().apply();
|
||||||
gamePlayArea.act();
|
gamePlayArea.act();
|
||||||
gamePlayArea.draw();
|
gamePlayArea.draw();
|
||||||
@ -55,7 +50,6 @@ public class CreativeDebugScreen extends ScreenAdapter {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dispose() {
|
public void dispose() {
|
||||||
shapes.dispose();
|
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,6 @@ import com.badlogic.gdx.InputProcessor;
|
|||||||
import com.badlogic.gdx.ScreenAdapter;
|
import com.badlogic.gdx.ScreenAdapter;
|
||||||
import com.badlogic.gdx.graphics.Color;
|
import com.badlogic.gdx.graphics.Color;
|
||||||
import com.badlogic.gdx.graphics.GL20;
|
import com.badlogic.gdx.graphics.GL20;
|
||||||
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
|
|
||||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||||
import com.badlogic.gdx.scenes.scene2d.Stage;
|
import com.badlogic.gdx.scenes.scene2d.Stage;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Image;
|
import com.badlogic.gdx.scenes.scene2d.ui.Image;
|
||||||
@ -38,11 +37,8 @@ public class GameScreen extends ScreenAdapter implements InputProcessor {
|
|||||||
|
|
||||||
private AudioData music;
|
private AudioData music;
|
||||||
|
|
||||||
private ShapeRenderer shapeRenderer;
|
|
||||||
|
|
||||||
public GameScreen(Polyjet polyJet) {
|
public GameScreen(Polyjet polyJet) {
|
||||||
core = polyJet;
|
core = polyJet;
|
||||||
shapeRenderer = new ShapeRenderer();
|
|
||||||
|
|
||||||
// Overlay stuff
|
// Overlay stuff
|
||||||
overlay = new Stage();
|
overlay = new Stage();
|
||||||
@ -101,7 +97,7 @@ public class GameScreen extends ScreenAdapter implements InputProcessor {
|
|||||||
(Gdx.graphics.getHeight() - pauseMenu.getHeight()) / 2);
|
(Gdx.graphics.getHeight() - pauseMenu.getHeight()) / 2);
|
||||||
|
|
||||||
// Continue to add things to input multiplexer
|
// Continue to add things to input multiplexer
|
||||||
gameArea = new GamePlayArea(polyJet.getAssetManager(), shapeRenderer);
|
gameArea = new GamePlayArea(polyJet.getAssetManager());
|
||||||
|
|
||||||
inputs = new InputMultiplexer();
|
inputs = new InputMultiplexer();
|
||||||
inputs.addProcessor(this);
|
inputs.addProcessor(this);
|
||||||
@ -123,6 +119,7 @@ public class GameScreen extends ScreenAdapter implements InputProcessor {
|
|||||||
public void render(float delta) {
|
public void render(float delta) {
|
||||||
Gdx.gl.glClearColor(1f, 1f, 1f, 1f);
|
Gdx.gl.glClearColor(1f, 1f, 1f, 1f);
|
||||||
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);
|
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);
|
||||||
|
Gdx.gl.glLineWidth(1f);
|
||||||
gameArea.getViewport().apply();
|
gameArea.getViewport().apply();
|
||||||
|
|
||||||
gameArea.draw();
|
gameArea.draw();
|
||||||
|
@ -56,7 +56,6 @@ public class CreativeStage extends Stage implements MiniListener {
|
|||||||
@Override
|
@Override
|
||||||
public void changed(ChangeEvent event, Actor actor) {
|
public void changed(ChangeEvent event, Actor actor) {
|
||||||
dispose();
|
dispose();
|
||||||
musicSelector.getSelectedMusic().reset();
|
|
||||||
core.setScreen(mainMenu);
|
core.setScreen(mainMenu);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -200,7 +199,9 @@ public class CreativeStage extends Stage implements MiniListener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dispose() {
|
public void dispose() {
|
||||||
musicSelector.getSelectedMusic().dispose();
|
if (musicSelector.getSelectedMusic() != null) {
|
||||||
|
musicSelector.getSelectedMusic().dispose();
|
||||||
|
}
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,7 +10,6 @@ import zero1hd.polyjet.Polyjet;
|
|||||||
import zero1hd.polyjet.controls.KeyMap;
|
import zero1hd.polyjet.controls.KeyMap;
|
||||||
import zero1hd.polyjet.entity.CollisionDetector;
|
import zero1hd.polyjet.entity.CollisionDetector;
|
||||||
import zero1hd.polyjet.entity.Entities;
|
import zero1hd.polyjet.entity.Entities;
|
||||||
import zero1hd.polyjet.entity.Entity;
|
|
||||||
import zero1hd.polyjet.entity.EntityController;
|
import zero1hd.polyjet.entity.EntityController;
|
||||||
import zero1hd.polyjet.entity.ally.Laser;
|
import zero1hd.polyjet.entity.ally.Laser;
|
||||||
import zero1hd.polyjet.entity.ally.PolyJetEntity;
|
import zero1hd.polyjet.entity.ally.PolyJetEntity;
|
||||||
@ -19,6 +18,8 @@ import zero1hd.polyjet.entity.ally.PolyJetEntity;
|
|||||||
public class GamePlayArea extends Stage {
|
public class GamePlayArea extends Stage {
|
||||||
public PolyJetEntity polyjet;
|
public PolyJetEntity polyjet;
|
||||||
|
|
||||||
|
public ShapeRenderer shapes;
|
||||||
|
|
||||||
public EntityController entityController;
|
public EntityController entityController;
|
||||||
private CollisionDetector collisionDetector;
|
private CollisionDetector collisionDetector;
|
||||||
|
|
||||||
@ -27,13 +28,15 @@ public class GamePlayArea extends Stage {
|
|||||||
private int score;
|
private int score;
|
||||||
|
|
||||||
Texture basicLaserTexture;
|
Texture basicLaserTexture;
|
||||||
public GamePlayArea(AssetManager assetManager, ShapeRenderer shapeRenderer) {
|
public GamePlayArea(AssetManager assetManager) {
|
||||||
super(new FitViewport(Polyjet.GAME_AREA_WIDTH, Polyjet.GAME_AREA_HEIGHT));
|
super(new FitViewport(Polyjet.GAME_AREA_WIDTH, Polyjet.GAME_AREA_HEIGHT));
|
||||||
|
|
||||||
polyjet = new PolyJetEntity(assetManager, 48f, "standard");
|
polyjet = new PolyJetEntity(assetManager, 48f, "standard");
|
||||||
|
|
||||||
entityController = new EntityController(shapeRenderer, assetManager);
|
shapes = new ShapeRenderer();
|
||||||
collisionDetector = new CollisionDetector(entityController.ACTIVE_ALLIES, entityController.ACTIVE_ENEMIES);
|
shapes.setProjectionMatrix(getCamera().combined);
|
||||||
|
entityController = new EntityController(assetManager, shapes);
|
||||||
|
collisionDetector = new CollisionDetector(entityController.activeAllies, entityController.activeEnemies);
|
||||||
addActor(polyjet);
|
addActor(polyjet);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,17 +44,15 @@ public class GamePlayArea extends Stage {
|
|||||||
public void act(float delta) {
|
public void act(float delta) {
|
||||||
collisionDetector.collisionCheck();
|
collisionDetector.collisionCheck();
|
||||||
|
|
||||||
while (entityController.ACTIVE_ALLIES.iterator().hasNext()) {
|
for (int i = 0; i < entityController.activeAllies.size; i ++) {
|
||||||
Entity entity = entityController.ACTIVE_ALLIES.iterator().next();
|
if (entityController.activeAllies.get(i).isDead()) {
|
||||||
if (entity.isDead()) {
|
entityController.free(entityController.activeAllies.get(i));
|
||||||
entityController.free(entity);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while (entityController.ACTIVE_ENEMIES.iterator().hasNext()) {
|
for (int i = 0; i < entityController.activeEnemies.size; i++) {
|
||||||
Entity entity = entityController.ACTIVE_ENEMIES.iterator().next();
|
if (entityController.activeEnemies.get(i).isDead()) {
|
||||||
if (entity.isDead()) {
|
entityController.free(entityController.activeEnemies.get(i));
|
||||||
entityController.free(entity);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,7 +121,7 @@ public class GamePlayArea extends Stage {
|
|||||||
}
|
}
|
||||||
if (keycode == KeyMap.shoot) {
|
if (keycode == KeyMap.shoot) {
|
||||||
Laser laser = (Laser) entityController.retrieveEntity(Entities.LASER);
|
Laser laser = (Laser) entityController.retrieveEntity(Entities.LASER);
|
||||||
laser.init(polyjet.getX() + (polyjet.getWidth()-laser.getWidth())/2, polyjet.getY() + polyjet.getHeight()+0.25f, 30f);
|
laser.init(polyjet.getX() + (polyjet.getWidth()-laser.getWidth())/2f, polyjet.getY() + polyjet.getHeight()+0.25f, 30f);
|
||||||
addActor(laser);
|
addActor(laser);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -80,7 +80,7 @@ public class MusicController extends Window {
|
|||||||
|
|
||||||
add(fastForward);
|
add(fastForward);
|
||||||
|
|
||||||
info = new TextField(null, skin) {
|
info = new TextField(null, skin, "ui") {
|
||||||
@Override
|
@Override
|
||||||
public void act(float delta) {
|
public void act(float delta) {
|
||||||
if (audiofile != null && audiofile.getPlaybackMusic().isPlaying()) {
|
if (audiofile != null && audiofile.getPlaybackMusic().isPlaying()) {
|
||||||
|
@ -87,6 +87,10 @@ public class MusicSelector extends Window {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public AudioData getSelectedMusic() {
|
public AudioData getSelectedMusic() {
|
||||||
return Audio.getAudioData(selectedMusic);
|
if (selectedMusic != null) {
|
||||||
|
return Audio.getAudioData(selectedMusic);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,13 @@
|
|||||||
package zero1hd.polyjet.ui.windows;
|
package zero1hd.polyjet.ui.windows;
|
||||||
|
|
||||||
import com.badlogic.gdx.Gdx;
|
import com.badlogic.gdx.Gdx;
|
||||||
|
import com.badlogic.gdx.Input.Keys;
|
||||||
|
import com.badlogic.gdx.math.Vector2;
|
||||||
import com.badlogic.gdx.scenes.scene2d.Stage;
|
import com.badlogic.gdx.scenes.scene2d.Stage;
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.ui.List;
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
|
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.TextField;
|
import com.badlogic.gdx.scenes.scene2d.ui.Slider;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Window;
|
import com.badlogic.gdx.scenes.scene2d.ui.Window;
|
||||||
|
|
||||||
import zero1hd.polyjet.entity.Entities;
|
import zero1hd.polyjet.entity.Entities;
|
||||||
@ -13,52 +17,67 @@ import zero1hd.polyjet.entity.ally.Laser;
|
|||||||
import zero1hd.polyjet.entity.enemies.VoidCircle;
|
import zero1hd.polyjet.entity.enemies.VoidCircle;
|
||||||
|
|
||||||
public class SpawnerWindow extends Window {
|
public class SpawnerWindow extends Window {
|
||||||
private TextField spawnName;
|
|
||||||
private TextField modifier;
|
|
||||||
private EntityController ec;
|
private EntityController ec;
|
||||||
private Stage stage;
|
private Stage stage;
|
||||||
|
|
||||||
|
private List<Entities> listOfEntities;
|
||||||
|
private ScrollPane scroller;
|
||||||
|
|
||||||
|
private Slider mod1;
|
||||||
|
private Slider mod2;
|
||||||
|
private Slider mod3;
|
||||||
public SpawnerWindow(String title, Skin skin, EntityController ec, Stage stageForEntities) {
|
public SpawnerWindow(String title, Skin skin, EntityController ec, Stage stageForEntities) {
|
||||||
super(title, skin);
|
super(title, skin);
|
||||||
spawnName = new TextField("", skin);
|
|
||||||
modifier = new TextField("0;0;0", skin);
|
|
||||||
|
|
||||||
add(spawnName, modifier);
|
|
||||||
this.ec = ec;
|
this.ec = ec;
|
||||||
stage = stageForEntities;
|
stage = stageForEntities;
|
||||||
setWidth(spawnName.getWidth()+modifier.getWidth()+30f);
|
|
||||||
setHeight(spawnName.getHeight()+35f);
|
mod1 = new Slider(0.1f, 50f, 0.01f, true, skin);
|
||||||
|
mod2 = new Slider(0.1f, 15f, 0.01f, true, skin);
|
||||||
|
mod3 = new Slider(0.1f, 15f, 0.01f, true, skin);
|
||||||
|
|
||||||
|
listOfEntities = new List<>(skin);
|
||||||
|
listOfEntities.setItems(Entities.values());
|
||||||
|
|
||||||
|
scroller = new ScrollPane(listOfEntities);
|
||||||
|
add(scroller).expandY().fillY().spaceRight(15f);
|
||||||
|
add(mod1, mod2, mod3);
|
||||||
|
|
||||||
|
setSize(300f, 375f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean remove() {
|
public boolean remove() {
|
||||||
spawnName.setText("");
|
|
||||||
return super.remove();
|
return super.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Vector2 coords = new Vector2();
|
||||||
@Override
|
@Override
|
||||||
public void act(float delta) {
|
public void act(float delta) {
|
||||||
if (Gdx.input.isTouched() && !spawnName.getText().isEmpty()) {
|
if (Gdx.input.justTouched() && Gdx.input.isKeyPressed(Keys.SHIFT_LEFT)) {
|
||||||
Entity entity = ec.retrieveEntity(Entities.valueOf(spawnName.getText()));
|
coords.set(Gdx.input.getX(), Gdx.input.getY());
|
||||||
switch(entity.getEntityType()) {
|
stage.screenToStageCoordinates(coords);
|
||||||
case BAR_BEAT:
|
|
||||||
break;
|
|
||||||
case LASER:
|
|
||||||
Laser laser = (Laser) entity;
|
|
||||||
laser.init(Gdx.input.getX(), Gdx.input.getY(), Float.valueOf(modifier.getText().split(";")[0]));
|
|
||||||
stage.addActor(laser);
|
|
||||||
break;
|
|
||||||
case SHARDS:
|
|
||||||
break;
|
|
||||||
case VOID_CIRCLE:
|
|
||||||
VoidCircle voidCircle = (VoidCircle) entity;
|
|
||||||
voidCircle.init(Float.valueOf(modifier.getText().split(";")[0]), Gdx.input.getX(), Gdx.input.getY(), Float.valueOf(modifier.getText().split(";")[1]), Float.valueOf(modifier.getText().split(";")[2]));
|
|
||||||
stage.addActor(voidCircle);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
|
|
||||||
|
Entity entity;
|
||||||
|
if ((entity = ec.retrieveEntity(listOfEntities.getSelected())) != null) {
|
||||||
|
switch(entity.getEntityType()) {
|
||||||
|
case BAR_BEAT:
|
||||||
|
break;
|
||||||
|
case LASER:
|
||||||
|
Laser laser = (Laser) entity;
|
||||||
|
laser.init(coords.x, coords.y, mod1.getValue());
|
||||||
|
stage.addActor(laser);
|
||||||
|
break;
|
||||||
|
case SHARDS:
|
||||||
|
break;
|
||||||
|
case VOID_CIRCLE:
|
||||||
|
VoidCircle voidCircle = (VoidCircle) entity;
|
||||||
|
voidCircle.init(mod3.getValue(), coords.x, coords.y, mod1.getValue(), mod2.getValue());
|
||||||
|
stage.addActor(voidCircle);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
super.act(delta);
|
super.act(delta);
|
||||||
|
Loading…
Reference in New Issue
Block a user