began work on debug spawning system
This commit is contained in:
parent
4894d6eea8
commit
5776586458
@ -61,19 +61,23 @@ public class EntityController {
|
||||
}
|
||||
}
|
||||
|
||||
public void free(Entity entity, Entities type) {
|
||||
switch (type) {
|
||||
public void free(Entity entity) {
|
||||
switch (entity.getEntityType()) {
|
||||
case BAR_BEAT:
|
||||
break;
|
||||
case SHARDS:
|
||||
break;
|
||||
case VOID_CIRCLE:
|
||||
VoidCircle voidCircle = (VoidCircle) entity;
|
||||
voidCircle.remove();
|
||||
ACTIVE_ENEMIES.removeValue(entity, true);
|
||||
VOID_CIRCLE_POOL.free((VoidCircle) entity);
|
||||
VOID_CIRCLE_POOL.free(voidCircle);
|
||||
break;
|
||||
case LASER:
|
||||
Laser laser = (Laser) entity;
|
||||
laser.remove();
|
||||
ACTIVE_ALLIES.removeValue(entity, true);
|
||||
LASER_POOL.free((Laser) entity);
|
||||
LASER_POOL.free(laser);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -4,6 +4,7 @@ import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.InputMultiplexer;
|
||||
import com.badlogic.gdx.ScreenAdapter;
|
||||
import com.badlogic.gdx.graphics.GL20;
|
||||
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
|
||||
|
||||
import zero1hd.polyjet.Polyjet;
|
||||
import zero1hd.polyjet.ui.stages.CreativeStage;
|
||||
@ -14,10 +15,14 @@ public class CreativeDebugScreen extends ScreenAdapter {
|
||||
GamePlayArea gamePlayArea;
|
||||
InputMultiplexer inputs;
|
||||
|
||||
ShapeRenderer shapes;
|
||||
|
||||
public CreativeDebugScreen(Polyjet core, MainMenu mainMenu) {
|
||||
creative = new CreativeStage(core, mainMenu);
|
||||
gamePlayArea = new GamePlayArea(core);
|
||||
|
||||
shapes = new ShapeRenderer();
|
||||
|
||||
gamePlayArea = new GamePlayArea(core.getAssetManager(), shapes);
|
||||
inputs = new InputMultiplexer(creative, gamePlayArea);
|
||||
}
|
||||
|
||||
@ -34,7 +39,10 @@ public class CreativeDebugScreen extends ScreenAdapter {
|
||||
|
||||
gamePlayArea.getViewport().apply();
|
||||
gamePlayArea.act();
|
||||
|
||||
shapes.begin();
|
||||
gamePlayArea.draw();
|
||||
shapes.end();
|
||||
|
||||
creative.getViewport().apply();
|
||||
creative.act();
|
||||
@ -44,7 +52,6 @@ public class CreativeDebugScreen extends ScreenAdapter {
|
||||
|
||||
@Override
|
||||
public void resize(int width, int height) {
|
||||
// TODO Auto-generated method stub
|
||||
super.resize(width, height);
|
||||
}
|
||||
}
|
||||
|
@ -36,17 +36,15 @@ public class CreativeStage extends Stage implements MiniListener {
|
||||
|
||||
AudioAnalyzer analyzer;
|
||||
Window toolbox;
|
||||
Polyjet core;
|
||||
|
||||
public CreativeStage(final Polyjet core, final MainMenu mainMenu) {
|
||||
this.core = core;
|
||||
musicSelector = new MusicSelector("Select Audio File", core.getDefaultSkin(), core.getPrefs().getString("music dir"), "default");
|
||||
musicSelector.miniSender.addListener(this);
|
||||
musicSelector.refresh();
|
||||
|
||||
fpsViewer = new FPSWindow("FPS", core.getDefaultSkin());
|
||||
|
||||
beatViewer = new BeatViewer("Beat", core.getDefaultSkin(), core);
|
||||
beatViewer = new BeatViewer("Beat", core.getDefaultSkin());
|
||||
|
||||
graphViewer = new GraphWindow("Peak Values", core.getDefaultSkin());
|
||||
volumeWindow = new VolumeWindow("Volume adjustments", core.getDefaultSkin(), core.getPrefs());
|
||||
|
@ -10,6 +10,7 @@ import zero1hd.polyjet.Polyjet;
|
||||
import zero1hd.polyjet.controls.KeyMap;
|
||||
import zero1hd.polyjet.entity.CollisionDetector;
|
||||
import zero1hd.polyjet.entity.Entities;
|
||||
import zero1hd.polyjet.entity.Entity;
|
||||
import zero1hd.polyjet.entity.EntityController;
|
||||
import zero1hd.polyjet.entity.ally.Laser;
|
||||
import zero1hd.polyjet.entity.ally.PolyJetEntity;
|
||||
@ -40,6 +41,20 @@ public class GamePlayArea extends Stage {
|
||||
public void act(float delta) {
|
||||
collisionDetector.collisionCheck();
|
||||
|
||||
while (entityController.ACTIVE_ALLIES.iterator().hasNext()) {
|
||||
Entity entity = entityController.ACTIVE_ALLIES.iterator().next();
|
||||
if (entity.isDead()) {
|
||||
entityController.free(entity);
|
||||
}
|
||||
}
|
||||
|
||||
while (entityController.ACTIVE_ENEMIES.iterator().hasNext()) {
|
||||
Entity entity = entityController.ACTIVE_ENEMIES.iterator().next();
|
||||
if (entity.isDead()) {
|
||||
entityController.free(entity);
|
||||
}
|
||||
}
|
||||
|
||||
if (polyjet.getX() <= 1) {
|
||||
polyjet.moveLeft = false;
|
||||
polyjet.setX(1f);
|
||||
@ -106,6 +121,7 @@ public class GamePlayArea extends Stage {
|
||||
if (keycode == KeyMap.shoot) {
|
||||
Laser laser = (Laser) entityController.retrieveEntity(Entities.LASER);
|
||||
laser.init(polyjet.getX() + (polyjet.getWidth()-laser.getWidth())/2, polyjet.getY() + polyjet.getHeight()+0.25f, 30f);
|
||||
addActor(laser);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -9,7 +9,6 @@ import com.badlogic.gdx.scenes.scene2d.ui.Skin;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Window;
|
||||
|
||||
import zero1hd.polyjet.Polyjet;
|
||||
import zero1hd.polyjet.audio.AudioAnalyzer;
|
||||
import zero1hd.polyjet.audio.AudioData;
|
||||
|
||||
@ -20,7 +19,7 @@ public class BeatViewer extends Window {
|
||||
Texture lightOn;
|
||||
private AudioAnalyzer data;
|
||||
|
||||
public BeatViewer(String title, Skin skin, Polyjet core) {
|
||||
public BeatViewer(String title, Skin skin) {
|
||||
super(title, skin);
|
||||
defaults().space(5f);
|
||||
setSize(64, 100);
|
||||
@ -34,11 +33,11 @@ public class BeatViewer extends Window {
|
||||
|
||||
|
||||
WidgetGroup bassBar = new WidgetGroup();
|
||||
final Image bgBassBar = new Image(core.getDefaultSkin().getPatch("bar-empty"));
|
||||
final Image bgBassBar = new Image(skin.getPatch("bar-empty"));
|
||||
bgBassBar.setHeight(50f);
|
||||
bassBar.setSize(bgBassBar.getWidth(), bgBassBar.getHeight());
|
||||
|
||||
final Image bassBarFill = new Image(core.getDefaultSkin().getPatch("bar-fill")) {
|
||||
final Image bassBarFill = new Image(skin.getPatch("bar-fill")) {
|
||||
@Override
|
||||
public void act(float delta) {
|
||||
try {
|
||||
@ -57,10 +56,10 @@ public class BeatViewer extends Window {
|
||||
add(bassBar).minSize(bassBar.getWidth(), bassBar.getHeight());
|
||||
|
||||
WidgetGroup UMBar = new WidgetGroup();
|
||||
final Image bgUMBar = new Image(core.getDefaultSkin().getPatch("bar-empty"));
|
||||
final Image bgUMBar = new Image(skin.getPatch("bar-empty"));
|
||||
bgUMBar.setHeight(50f);
|
||||
UMBar.setSize(bgUMBar.getWidth(), bgUMBar.getHeight());
|
||||
Image UMBarFill = new Image(core.getDefaultSkin().getPatch("bar-fill")) {
|
||||
Image UMBarFill = new Image(skin.getPatch("bar-fill")) {
|
||||
@Override
|
||||
public void act(float delta) {
|
||||
try {
|
||||
@ -91,7 +90,6 @@ public class BeatViewer extends Window {
|
||||
addAction(Actions.sequence(Actions.alpha(1f), Actions.fadeOut(0.15f)));
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
// TODO: handle exception
|
||||
}
|
||||
super.act(delta);
|
||||
}
|
||||
|
62
core/src/zero1hd/polyjet/ui/windows/SpawnerWindow.java
Executable file
62
core/src/zero1hd/polyjet/ui/windows/SpawnerWindow.java
Executable file
@ -0,0 +1,62 @@
|
||||
package zero1hd.polyjet.ui.windows;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.scenes.scene2d.Stage;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextField;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Window;
|
||||
|
||||
import zero1hd.polyjet.entity.Entities;
|
||||
import zero1hd.polyjet.entity.Entity;
|
||||
import zero1hd.polyjet.entity.EntityController;
|
||||
import zero1hd.polyjet.entity.ally.Laser;
|
||||
import zero1hd.polyjet.entity.enemies.VoidCircle;
|
||||
|
||||
public class SpawnerWindow extends Window {
|
||||
private TextField spawnName;
|
||||
private TextField modifier;
|
||||
private EntityController ec;
|
||||
private Stage stage;
|
||||
|
||||
public SpawnerWindow(String title, Skin skin, EntityController ec, Stage stageForEntities) {
|
||||
super(title, skin);
|
||||
spawnName = new TextField("", skin);
|
||||
modifier = new TextField("0;0;0", skin);
|
||||
this.ec = ec;
|
||||
stage = stageForEntities;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean remove() {
|
||||
spawnName.setText("");
|
||||
return super.remove();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void act(float delta) {
|
||||
if (Gdx.input.isTouched() && !spawnName.getText().isEmpty()) {
|
||||
Entity entity = ec.retrieveEntity(Entities.valueOf(spawnName.getText()));
|
||||
switch(entity.getEntityType()) {
|
||||
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;
|
||||
|
||||
}
|
||||
}
|
||||
super.act(delta);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user