basic ground work for entity coordinators added

This commit is contained in:
Harrison Deng 2017-08-02 02:05:16 -05:00
parent bb5782a34f
commit a72bd104f0
21 changed files with 263 additions and 127 deletions

View File

@ -2,24 +2,27 @@ package zero1hd.rhythmbullet.audio.map;
import java.util.HashMap; import java.util.HashMap;
import zero1hd.rhythmbullet.entity.EntityIndex; import zero1hd.rhythmbullet.entity.Entity;
import zero1hd.rhythmbullet.entity.EntityFrame;
import zero1hd.rhythmbullet.entity.coordinator.Coordinator;
import zero1hd.rhythmbullet.entity.coordinator.CoordinatorFrame;
public class EntitySpawnInfo { public class EntitySpawnInfo {
private EntityIndex entityType; private EntityFrame<? extends Entity> entityToSpawn;
// private float[] parameters; private CoordinatorFrame<? extends Coordinator> entityCoordinator;
public HashMap<String, Float> parameters; public HashMap<String, Float> parameters;
public EntitySpawnInfo(EntityIndex entityType) {
this.entityType = entityType; public EntitySpawnInfo(EntityFrame<? extends Entity> entityToSpawn, CoordinatorFrame<? extends Coordinator> coordinator) {
this.entityToSpawn = entityToSpawn;
parameters = new HashMap<>(); parameters = new HashMap<>();
} }
public EntityIndex getEntityType() { public EntityFrame<? extends Entity> getEntityToSpawn() {
return entityType; return entityToSpawn;
} }
@Override public CoordinatorFrame<? extends Coordinator> getEntityCoordinator() {
public String toString() { return entityCoordinator;
return entityType.name() + ": " + parameters.size();
} }
} }

View File

@ -1,7 +1,10 @@
package zero1hd.rhythmbullet.audio.map; package zero1hd.rhythmbullet.audio.map;
import zero1hd.rhythmbullet.audio.AudioData; import zero1hd.rhythmbullet.audio.AudioData;
import zero1hd.rhythmbullet.entity.EntityIndex; import zero1hd.rhythmbullet.entity.Entity;
import zero1hd.rhythmbullet.entity.EntityFrame;
import zero1hd.rhythmbullet.entity.coordinator.Coordinator;
import zero1hd.rhythmbullet.entity.coordinator.CoordinatorFrame;
public class GamePlayMap { public class GamePlayMap {
private AudioData musicData; private AudioData musicData;
@ -30,12 +33,12 @@ public class GamePlayMap {
return previousIndex; return previousIndex;
} }
public EntitySpawnInfo addEntity(EntityIndex entityType) { public EntitySpawnInfo addEntity(EntityFrame<? extends Entity> entityType, CoordinatorFrame<? extends Coordinator> coordinator) {
if (building) { if (building) {
if (spawnList[index] == null) { if (spawnList[index] == null) {
spawnList[index] = new MapWindowData(); spawnList[index] = new MapWindowData();
} }
EntitySpawnInfo esi = new EntitySpawnInfo(entityType); EntitySpawnInfo esi = new EntitySpawnInfo(entityType, coordinator);
spawnList[index].addEntity(esi); spawnList[index].addEntity(esi);
return esi; return esi;
} else { } else {

View File

@ -7,13 +7,17 @@ import com.badlogic.gdx.utils.FloatArray;
import zero1hd.rhythmbullet.RhythmBullet; import zero1hd.rhythmbullet.RhythmBullet;
import zero1hd.rhythmbullet.audio.AudioAnalyzer; import zero1hd.rhythmbullet.audio.AudioAnalyzer;
import zero1hd.rhythmbullet.entity.EntityIndex; import zero1hd.rhythmbullet.entity.EntityManager;
import zero1hd.rhythmbullet.entity.coordinator.CoordinatorManager;
import zero1hd.rhythmbullet.util.MiniEvents; import zero1hd.rhythmbullet.util.MiniEvents;
import zero1hd.rhythmbullet.util.MiniSender; import zero1hd.rhythmbullet.util.MiniSender;
public class RhythmMapAlgorithm implements Runnable { public class RhythmMapAlgorithm implements Runnable {
private MiniSender sender; private MiniSender sender;
private EntityManager em;
private CoordinatorManager cm;
private FloatArray bassPeaks; private FloatArray bassPeaks;
private FloatArray mPeaks; private FloatArray mPeaks;
private FloatArray umPeaks; private FloatArray umPeaks;
@ -30,7 +34,10 @@ public class RhythmMapAlgorithm implements Runnable {
private float windowPerSecond; private float windowPerSecond;
private volatile int progress; private volatile int progress;
public RhythmMapAlgorithm(AudioAnalyzer analyzer, float speedMod, float healthMod, float difficultyMod) { public RhythmMapAlgorithm(EntityManager em, CoordinatorManager cm, AudioAnalyzer analyzer, float speedMod, float healthMod, float difficultyMod) {
this.cm = cm;
this.em = em;
sender = new MiniSender(); sender = new MiniSender();
bassPeaks = analyzer.getBassPeaks(); bassPeaks = analyzer.getBassPeaks();
@ -67,7 +74,7 @@ public class RhythmMapAlgorithm implements Runnable {
float waitTime = 1.5f; float waitTime = 1.5f;
float endRadius = (bassPeaks.get(index)/bassMax)*(RhythmBullet.GAME_AREA_HEIGHT/4f); float endRadius = (bassPeaks.get(index)/bassMax)*(RhythmBullet.GAME_AREA_HEIGHT/4f);
esi = map.addEntity(EntityIndex.VOID_CIRCLE); esi = map.addEntity(em.voidCircle, null);
esi.parameters.put("warningTime", waitTime); esi.parameters.put("warningTime", waitTime);
esi.parameters.put("endRadius", endRadius); esi.parameters.put("endRadius", endRadius);
esi.parameters.put("growthRate", endRadius/(avgSPB*0.8f)); esi.parameters.put("growthRate", endRadius/(avgSPB*0.8f));
@ -85,14 +92,14 @@ public class RhythmMapAlgorithm implements Runnable {
//If upper midrange peaks are greater than average, the: //If upper midrange peaks are greater than average, the:
int spawnLocations = (RhythmBullet.GAME_AREA_WIDTH-8)/8; int spawnLocations = (RhythmBullet.GAME_AREA_WIDTH-8)/8;
esi = map.addEntity(EntityIndex.BAR); esi = map.addEntity(em.bar, null);
esi.parameters.put("x", (float) (MathUtils.round(rand.nextFloat()*spawnLocations)*8)); esi.parameters.put("x", (float) (MathUtils.round(rand.nextFloat()*spawnLocations)*8));
esi.parameters.put("rate", (8f/avgSPB)*speedMod); esi.parameters.put("rate", (8f/avgSPB)*speedMod);
} else { } else {
float xSpawnLocation = (rand.nextFloat()*(RhythmBullet.GAME_AREA_WIDTH-2))+1; float xSpawnLocation = (rand.nextFloat()*(RhythmBullet.GAME_AREA_WIDTH-2))+1;
esi = map.addEntity(EntityIndex.PELLET); esi = map.addEntity(em.pellet, null);
esi.parameters.put("x", xSpawnLocation); esi.parameters.put("x", xSpawnLocation);
esi.parameters.put("y", RhythmBullet.GAME_AREA_HEIGHT-0.25f); esi.parameters.put("y", RhythmBullet.GAME_AREA_HEIGHT-0.25f);
esi.parameters.put("angle", 140*rand.nextFloat()+200f); esi.parameters.put("angle", 140*rand.nextFloat()+200f);
@ -130,4 +137,8 @@ public class RhythmMapAlgorithm implements Runnable {
public MiniSender getSender() { public MiniSender getSender() {
return sender; return sender;
} }
public EntityManager getEm() {
return em;
}
} }

View File

@ -18,6 +18,7 @@ public class CollisionDetector {
AssetManager assets; AssetManager assets;
Preferences prefs; Preferences prefs;
//Particle pools; //Particle pools;
ParticleEffectPool explosionEffectPool; ParticleEffectPool explosionEffectPool;
Array<PooledEffect> effects = new Array<>(); Array<PooledEffect> effects = new Array<>();
@ -68,7 +69,7 @@ public class CollisionDetector {
/** /**
* draws the explosion particles where necessecary. * draws the explosion particles where necessary.
* @param batch the batch used to draw the said particles * @param batch the batch used to draw the said particles
* @param cleanBatch whether this method should call begin and end on the batch. * @param cleanBatch whether this method should call begin and end on the batch.
*/ */

View File

@ -13,12 +13,15 @@ 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;
import zero1hd.rhythmbullet.entity.coordinator.Coordinator;
public class Entity extends Actor implements Poolable { public class Entity extends Actor implements Poolable {
private Coordinator coordinator;
private EntityFrame<?> ef; private EntityFrame<?> ef;
protected AssetManager assets; protected AssetManager assets;
protected Preferences prefs; protected Preferences prefs;
protected EntityController ec; protected EntityManager ec;
protected boolean enemy; protected boolean enemy;
protected boolean simple = true; protected boolean simple = true;
@ -29,15 +32,15 @@ public class Entity extends Actor implements Poolable {
protected Sprite sprite; protected Sprite sprite;
protected Vector2 rotRatios; protected Vector2 rotRatios;
protected Vector2 center; protected Vector2 center;
protected float angle; public float angle;
protected float speed; public float speed;
/** /**
* called by the entity frame and only once (when this object is created). * called by the entity frame and only once (when this object is created).
*/ */
protected void setup(EntityController ec, EntityFrame<?> ef) { protected void setup(EntityManager ec, EntityFrame<?> ef) {
this.ec = ec; this.ec = ec;
this.ef = ef; this.ef = ef;
assets = ec.getAssets(); assets = ec.getAssets();
@ -45,6 +48,7 @@ public class Entity extends Actor implements Poolable {
rotRatios = new Vector2(); rotRatios = new Vector2();
center = new Vector2(); center = new Vector2();
hitbox = new Rectangle(); hitbox = new Rectangle();
preInit(); preInit();
} }
@ -90,29 +94,17 @@ public class Entity extends Actor implements Poolable {
@Override @Override
public void act(float delta) { public void act(float delta) {
if (!nonStnrd) { if (!nonStnrd) {
coordinator.coordinate(delta);
if (move) { if (move) {
move(delta, false); move(delta, true);
} }
if (simple) {
sprite.setPosition(getX(), getY());
hitbox.setPosition(getX(), getY());
sprite.setSize(getWidth(), getHeight());
hitbox.setSize(getWidth(), getHeight());
} else {
sprite.setCenter(center.x, center.y);
hitbox.setCenter(center);
sprite.setOriginCenter();
sprite.setRotation(angle);
}
super.act(delta);
if (isDead()) { if (isDead()) {
ef.recycleEntity(this); ef.recycleEntity(this);
} }
} }
super.act(delta);
} }
@Override @Override
@ -146,18 +138,23 @@ public class Entity extends Actor implements Poolable {
if (simple) { if (simple) {
sprite.setPosition(getX(), getY()); sprite.setPosition(getX(), getY());
hitbox.setPosition(getX(), getY()); hitbox.setPosition(getX(), getY());
sprite.setSize(getWidth(), getHeight());
hitbox.setSize(getWidth(), getHeight());
} else { } else {
sprite.setCenter(center.x, center.y); sprite.setCenter(center.x, center.y);
hitbox.setCenter(center); hitbox.setCenter(center);
sprite.setOriginCenter();
sprite.setRotation(angle); sprite.setRotation(angle);
} }
} }
@Override @Override
public void reset() { public void reset() {
coordinator.clean();
coordinator = null;
rotRatios.set(0, 0); rotRatios.set(0, 0);
hitbox.set(0, 0, 0, 0);
sprite.setPosition(0, 0); sprite.setPosition(0, 0);
hitbox.set(0, 0, 0, 0);
sprite.setRotation(0); sprite.setRotation(0);
setPosition(0, 0); setPosition(0, 0);
center.set(0, 0); center.set(0, 0);
@ -180,4 +177,8 @@ public class Entity extends Actor implements Poolable {
public float getSpeed() { public float getSpeed() {
return speed; return speed;
} }
public void setCoordinator(Coordinator coordinator) {
this.coordinator = coordinator;
}
} }

View File

@ -4,11 +4,10 @@ import com.badlogic.gdx.utils.Pool;
public class EntityFrame<T extends Entity> { public class EntityFrame<T extends Entity> {
private Pool<T> pool; private Pool<T> pool;
private EntityController ec; private EntityManager ec;
Class<T> ct; Class<T> ct;
EntityFrame<T> ef; EntityFrame<T> ef;
public EntityFrame(EntityController entityController, Class<T> classType) { public EntityFrame(EntityManager entityController) {
ct = classType;
ef = this; ef = this;
ec = entityController; ec = entityController;
pool = new Pool<T>() { pool = new Pool<T>() {
@ -44,7 +43,7 @@ public class EntityFrame<T extends Entity> {
* Free the entity if no longer used. * Free the entity if no longer used.
* @param entity to be freed. * @param entity to be freed.
*/ */
public void recycleEntity(Entity entity) { protected void recycleEntity(Entity entity) {
if (entity.enemy) { if (entity.enemy) {
ec.activeEnemies.removeValue(entity, true); ec.activeEnemies.removeValue(entity, true);
} else { } else {

View File

@ -1,8 +1,5 @@
package zero1hd.rhythmbullet.entity; package zero1hd.rhythmbullet.entity;
import java.util.HashMap;
import com.badlogic.gdx.Preferences; import com.badlogic.gdx.Preferences;
import com.badlogic.gdx.assets.AssetManager; import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.scenes.scene2d.Stage; import com.badlogic.gdx.scenes.scene2d.Stage;
@ -15,7 +12,7 @@ import zero1hd.rhythmbullet.entity.enemies.Pellet;
import zero1hd.rhythmbullet.entity.enemies.Shard; import zero1hd.rhythmbullet.entity.enemies.Shard;
import zero1hd.rhythmbullet.entity.enemies.VoidCircle; import zero1hd.rhythmbullet.entity.enemies.VoidCircle;
public class EntityController { public class EntityManager {
private AssetManager assets; private AssetManager assets;
private Preferences prefs; private Preferences prefs;
private Stage stage; private Stage stage;
@ -31,9 +28,7 @@ public class EntityController {
public EntityFrame<Laser> laser; public EntityFrame<Laser> laser;
private HashMap<EntityIndex, EntityFrame<? extends Entity>> index = new HashMap<>(); public EntityManager(AssetManager assetManager, Preferences preferences, Stage stage) {
public EntityController(AssetManager assetManager, Preferences preferences, Stage stage) {
activeAllies = new Array<Entity>(); activeAllies = new Array<Entity>();
activeEnemies = new Array<Entity>(); activeEnemies = new Array<Entity>();
this.assets = assetManager; this.assets = assetManager;
@ -44,17 +39,13 @@ public class EntityController {
} }
private void setup() { private void setup() {
index.put(EntityIndex.VOID_CIRCLE, (voidCircle = new EntityFrame<>(this, VoidCircle.class))); voidCircle = new EntityFrame<>(this);
index.put(EntityIndex.PELLET, pellet = new EntityFrame<>(this, Pellet.class)); pellet = new EntityFrame<>(this);
index.put(EntityIndex.SHARD, shard = new EntityFrame<>(this, Shard.class)); shard = new EntityFrame<>(this);
index.put(EntityIndex.BAR, bar = new EntityFrame<>(this, Bar.class)); bar = new EntityFrame<>(this);
index.put(EntityIndex.FLAKE, flake = new EntityFrame<>(this, Flake.class)); flake = new EntityFrame<>(this);
laser = new EntityFrame<>(this);
index.put(EntityIndex.LASER, laser = new EntityFrame<>(this, Laser.class));
}
public HashMap<EntityIndex, EntityFrame<? extends Entity>> getIndex() {
return index;
} }
public Stage getStage() { public Stage getStage() {

View File

@ -46,6 +46,7 @@ public class PolyJetEntity extends Entity {
thrust.update(delta); thrust.update(delta);
teleportCloak.setPosition(getX() +(getWidth()-1)/2, getY() + (getHeight()-1)/2); teleportCloak.setPosition(getX() +(getWidth()-1)/2, getY() + (getHeight()-1)/2);
hitbox.setPosition(getX(), getY());
//Movement! //Movement!
if (accelerate) { if (accelerate) {

View File

@ -0,0 +1,33 @@
package zero1hd.rhythmbullet.entity.coordinator;
import com.badlogic.gdx.utils.Pool.Poolable;
import zero1hd.rhythmbullet.entity.Entity;
import zero1hd.rhythmbullet.entity.EntityManager;
public class Coordinator implements Poolable {
private CoordinatorFrame<? extends Coordinator> cf;
protected EntityManager em;
protected Entity entity;
public void setup(EntityManager em, CoordinatorFrame<? extends Coordinator> cf) {
this.em = em;
this.cf = cf;
}
public void init(Entity entity) {
this.entity = entity;
}
public void coordinate(float delta) {
}
public void clean() {
cf.recycleCoordinator(this);
}
@Override
public void reset() {
entity = null;
}
}

View File

@ -0,0 +1,39 @@
package zero1hd.rhythmbullet.entity.coordinator;
import com.badlogic.gdx.utils.Pool;
import zero1hd.rhythmbullet.entity.EntityManager;
public class CoordinatorFrame<T extends Coordinator> {
private Pool<T> pool;
private EntityManager em;
CoordinatorFrame<T> cf;
Class<T> coordinatorType;
public CoordinatorFrame(EntityManager entityManager) {
this.em = entityManager;
cf = this;
pool = new Pool<T>() {
@Override
protected T newObject() {
try {
T coordinator = coordinatorType.newInstance();
coordinator.setup(em, cf);
return coordinator;
} catch (InstantiationException | IllegalAccessException e) {
e.printStackTrace();
return null;
}
}
};
}
public T buildCoordinator() {
T coordinator = pool.obtain();
return coordinator;
}
protected void recycleCoordinator(Coordinator coordinator) {
pool.free(coordinatorType.cast(coordinator));
}
}

View File

@ -0,0 +1,5 @@
package zero1hd.rhythmbullet.entity.coordinator;
public enum CoordinatorIndex {
SLOW_RIGHT, SLOW_LEFT;
}

View File

@ -0,0 +1,20 @@
package zero1hd.rhythmbullet.entity.coordinator;
import zero1hd.rhythmbullet.entity.EntityManager;
public class CoordinatorManager {
private EntityManager em;
public CoordinatorFrame<SlowLeftCoordinator> slowLeft;
public CoordinatorFrame<SlowRightCoordinator> slowRight;
public CoordinatorManager(EntityManager em) {
this.em = em;
setup();
}
private void setup() {
slowLeft = new CoordinatorFrame<>(em);
slowRight = new CoordinatorFrame<>(em);
}
}

View File

@ -0,0 +1,9 @@
package zero1hd.rhythmbullet.entity.coordinator;
public class SlowLeftCoordinator extends Coordinator {
@Override
public void coordinate(float delta) {
entity.angle -= 8*delta;
super.coordinate(delta);
}
}

View File

@ -0,0 +1,9 @@
package zero1hd.rhythmbullet.entity.coordinator;
public class SlowRightCoordinator extends Coordinator {
@Override
public void coordinate(float delta) {
entity.angle += 8*delta;
super.coordinate(delta);
}
}

View File

@ -21,7 +21,7 @@ public class GameScreen extends ScreenAdapter {
private GamePlayArea gameArea; private GamePlayArea gameArea;
private GameHUD gameHUD; private GameHUD gameHUD;
public InputMultiplexer inputs; private InputMultiplexer inputs;
public RhythmBullet core; public RhythmBullet core;
@ -31,8 +31,8 @@ public class GameScreen extends ScreenAdapter {
private ShaderProgram bgShader; private ShaderProgram bgShader;
private Texture background; private Texture background;
public GameScreen(RhythmBullet polyJet, GamePlayMap gpm) { public GameScreen(RhythmBullet core) {
core = polyJet; this.core = core;
// Overlay stuff // Overlay stuff
ImageButton pause = new ImageButton(core.getDefaultSkin().getDrawable("pause"), ImageButton pause = new ImageButton(core.getDefaultSkin().getDrawable("pause"),
@ -46,11 +46,8 @@ public class GameScreen extends ScreenAdapter {
} }
}); });
music = gpm.getMusicData(); gameArea = new GamePlayArea(core.getAssetManager(), core.getPrefs());
gameHUD = new GameHUD(core.getDefaultSkin(), gameArea.getMaxHealth());
gameArea = new GamePlayArea(polyJet.getAssetManager(), core.getPrefs());
gameArea.setAudioMap(gpm);
gameHUD = new GameHUD(polyJet.getDefaultSkin(), gpm.getMusicData().getPlaybackMusic(), gameArea.getMaxHealth());
inputs = new InputMultiplexer(); inputs = new InputMultiplexer();
inputs.addProcessor(gameHUD); inputs.addProcessor(gameHUD);
@ -77,8 +74,15 @@ public class GameScreen extends ScreenAdapter {
} }
} }
public void setGamePlayMap(GamePlayMap gpm) {
music = gpm.getMusicData();
gameArea.setAudioMap(gpm);
gameHUD.setMusic(gpm.getMusicData().getPlaybackMusic());
}
@Override @Override
public void show() { public void show() {
if (music == null) new NullPointerException("Idiot, you can't have a music game not have music on the gameplay screen...");
Gdx.input.setInputProcessor(inputs); Gdx.input.setInputProcessor(inputs);
gameArea.loadShaders(core.getPrefs()); gameArea.loadShaders(core.getPrefs());
@ -156,4 +160,7 @@ public class GameScreen extends ScreenAdapter {
super.resize(width, height); super.resize(width, height);
} }
public GamePlayArea getGameArea() {
return gameArea;
}
} }

View File

@ -55,6 +55,7 @@ public class AnalyzePage extends Page implements MiniListener {
private long startTime, endTime; private long startTime, endTime;
private Thread mapGenThread; private Thread mapGenThread;
private GameScreen gameScreen;
private RhythmBullet core; private RhythmBullet core;
@ -261,7 +262,8 @@ public class AnalyzePage extends Page implements MiniListener {
case MUSIC_DATA_CLEANED: case MUSIC_DATA_CLEANED:
info[3].setText("data cleaning done."); info[3].setText("data cleaning done.");
info[4].addAction(Actions.color(Color.BLACK, 0.75f)); info[4].addAction(Actions.color(Color.BLACK, 0.75f));
mapGenAlgorithm = new RhythmMapAlgorithm(audioAnalyzer, speedModifier.getValue(), healthModifier.getValue(), sensitivityRating.getValue()); gameScreen = new GameScreen(core);
mapGenAlgorithm = new RhythmMapAlgorithm(gameScreen.getGameArea().em, gameScreen.getGameArea().cm, audioAnalyzer, speedModifier.getValue(), healthModifier.getValue(), sensitivityRating.getValue());
mapGenAlgorithm.getSender().addListener(this); mapGenAlgorithm.getSender().addListener(this);
mapGenThread = new Thread(mapGenAlgorithm); mapGenThread = new Thread(mapGenAlgorithm);
mapGenThread.start(); mapGenThread.start();
@ -277,11 +279,11 @@ public class AnalyzePage extends Page implements MiniListener {
Gdx.app.postRunnable(new Runnable() { Gdx.app.postRunnable(new Runnable() {
@Override @Override
public void run() { public void run() {
final GameScreen gameScreen = new GameScreen(core, mapGenAlgorithm.getMap());
beginButton.addListener(new ChangeListener() { beginButton.addListener(new ChangeListener() {
@Override @Override
public void changed(ChangeEvent event, Actor actor) { public void changed(ChangeEvent event, Actor actor) {
gameScreen.setGamePlayMap(mapGenAlgorithm.getMap());
core.setScreen(gameScreen); core.setScreen(gameScreen);
} }
}); });

View File

@ -56,7 +56,7 @@ public class CreativeHUD extends Stage implements MiniListener {
bassUMgraphWindow = new BassUMGraphWindow("Bass/UM Peak Values", core.getDefaultSkin()); bassUMgraphWindow = new BassUMGraphWindow("Bass/UM Peak Values", core.getDefaultSkin());
mGraphWindow = new MGraphWindow("Midrange Peak Values", core.getDefaultSkin()); mGraphWindow = new MGraphWindow("Midrange Peak Values", core.getDefaultSkin());
volumeWindow = new VolumeWindow("Volume adjustments", core.getDefaultSkin(), core.getPrefs()); volumeWindow = new VolumeWindow("Volume adjustments", core.getDefaultSkin(), core.getPrefs());
spawnerWindow = new SpawnerWindow("Spawn Tool", core.getDefaultSkin(), gpa.ec, gpa); spawnerWindow = new SpawnerWindow("Spawn Tool", core.getDefaultSkin(), gpa.em, gpa);
diffWindow = new DifficultyWindow(core.getDefaultSkin()); diffWindow = new DifficultyWindow(core.getDefaultSkin());
//Back button //Back button
@ -255,7 +255,7 @@ public class CreativeHUD extends Stage implements MiniListener {
break; break;
case MUSIC_DATA_CLEANED: case MUSIC_DATA_CLEANED:
if (analyzer != null && analyzer.isFinalized()) { if (analyzer != null && analyzer.isFinalized()) {
mapGen = new RhythmMapAlgorithm(analyzer, diffWindow.getSpeedModifier(), diffWindow.getHealthModifier(), diffWindow.getSensitivityVal()); mapGen = new RhythmMapAlgorithm(gpa.em, gpa.cm, analyzer, diffWindow.getSpeedModifier(), diffWindow.getHealthModifier(), diffWindow.getSensitivityVal());
mapGen.getSender().addListener(this); mapGen.getSender().addListener(this);
Thread mapGenThread = new Thread(mapGen); Thread mapGenThread = new Thread(mapGen);
mapGenThread.start(); mapGenThread.start();

View File

@ -25,10 +25,8 @@ public class GameHUD extends Stage {
private Music music; private Music music;
public GameHUD(Skin skin, Music music, int maxHealth) { public GameHUD(Skin skin, int maxHealth) {
super(); super();
this.music = music;
score = new Label("Score: 0", skin, "default-font", Color.WHITE); score = new Label("Score: 0", skin, "default-font", Color.WHITE);
score.setPosition(10f, Gdx.graphics.getHeight()-score.getHeight() - 10f); score.setPosition(10f, Gdx.graphics.getHeight()-score.getHeight() - 10f);
addActor(score); addActor(score);
@ -127,4 +125,7 @@ public class GameHUD extends Stage {
return false; return false;
} }
public void setMusic(Music music) {
this.music = music;
}
} }

View File

@ -18,17 +18,18 @@ import zero1hd.rhythmbullet.audio.map.MapWindowData;
import zero1hd.rhythmbullet.controls.KeyMap; import zero1hd.rhythmbullet.controls.KeyMap;
import zero1hd.rhythmbullet.entity.CollisionDetector; import zero1hd.rhythmbullet.entity.CollisionDetector;
import zero1hd.rhythmbullet.entity.Entity; import zero1hd.rhythmbullet.entity.Entity;
import zero1hd.rhythmbullet.entity.EntityController; import zero1hd.rhythmbullet.entity.EntityManager;
import zero1hd.rhythmbullet.entity.EntityIndex;
import zero1hd.rhythmbullet.entity.ally.Laser; import zero1hd.rhythmbullet.entity.ally.Laser;
import zero1hd.rhythmbullet.entity.ally.PolyJetEntity; import zero1hd.rhythmbullet.entity.ally.PolyJetEntity;
import zero1hd.rhythmbullet.entity.coordinator.CoordinatorManager;
public class GamePlayArea extends Stage { public class GamePlayArea extends Stage {
public PolyJetEntity polyjet; public PolyJetEntity polyjet;
private GamePlayMap audioMap; private GamePlayMap audioMap;
public EntityController ec; public CoordinatorManager cm;
public EntityManager em;
private CollisionDetector collisionDetector; private CollisionDetector collisionDetector;
private int maxHealth = 100; private int maxHealth = 100;
@ -47,9 +48,10 @@ public class GamePlayArea extends Stage {
Gdx.app.debug("Game Area", "new area created"); Gdx.app.debug("Game Area", "new area created");
polyjet = new PolyJetEntity(assetManager, 25f, 25f, "standard"); polyjet = new PolyJetEntity(assetManager, 25f, 25f, "standard");
ec = new EntityController(assetManager, prefs, this); em = new EntityManager(assetManager, prefs, this);
collisionDetector = new CollisionDetector(ec.activeEnemies, ec.activeAllies, assetManager, prefs); cm = new CoordinatorManager(em);
ec.activeAllies.add(polyjet); collisionDetector = new CollisionDetector(em.activeEnemies, em.activeAllies, assetManager, prefs);
em.activeAllies.add(polyjet);
addActor(polyjet); addActor(polyjet);
} }
@ -127,7 +129,10 @@ public class GamePlayArea extends Stage {
EntitySpawnInfo[] currentSpawnInfo = mwd.getArray(); EntitySpawnInfo[] currentSpawnInfo = mwd.getArray();
if (currentSpawnInfo != null) { if (currentSpawnInfo != null) {
for (int i = 0; i < currentSpawnInfo.length; i++) { for (int i = 0; i < currentSpawnInfo.length; i++) {
Entity entity = ec.getIndex().get(currentSpawnInfo[i].getEntityType()).buildEntity(); Entity entity = currentSpawnInfo[i].getEntityToSpawn().buildEntity();
if (currentSpawnInfo[i].getEntityCoordinator() != null) {
entity.setCoordinator(currentSpawnInfo[i].getEntityCoordinator().buildCoordinator());
}
entity.init(currentSpawnInfo[i].parameters); entity.init(currentSpawnInfo[i].parameters);
addActor(entity); addActor(entity);
} }
@ -210,7 +215,7 @@ public class GamePlayArea extends Stage {
} }
if (keycode == KeyMap.shoot) { if (keycode == KeyMap.shoot) {
Laser laser = (Laser) ec.getIndex().get(EntityIndex.LASER).buildEntity(); Laser laser = em.laser.buildEntity();
laser.init(polyjet.getX() + polyjet.getWidth()/2f, polyjet.getY() + polyjet.getHeight()+1f, 60f); laser.init(polyjet.getX() + polyjet.getWidth()/2f, polyjet.getY() + polyjet.getHeight()+1f, 60f);
addActor(laser); addActor(laser);
} }

View File

@ -10,8 +10,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.Slider; 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.rhythmbullet.entity.Entity; import zero1hd.rhythmbullet.entity.EntityManager;
import zero1hd.rhythmbullet.entity.EntityController;
import zero1hd.rhythmbullet.entity.EntityIndex; import zero1hd.rhythmbullet.entity.EntityIndex;
import zero1hd.rhythmbullet.entity.ally.Laser; import zero1hd.rhythmbullet.entity.ally.Laser;
import zero1hd.rhythmbullet.entity.enemies.Bar; import zero1hd.rhythmbullet.entity.enemies.Bar;
@ -21,7 +20,7 @@ import zero1hd.rhythmbullet.entity.enemies.Shard;
import zero1hd.rhythmbullet.entity.enemies.VoidCircle; import zero1hd.rhythmbullet.entity.enemies.VoidCircle;
public class SpawnerWindow extends Window { public class SpawnerWindow extends Window {
private EntityController ec; private EntityManager ec;
private Stage stage; private Stage stage;
private List<EntityIndex> listOfEntities; private List<EntityIndex> listOfEntities;
@ -32,7 +31,7 @@ public class SpawnerWindow extends Window {
private Slider mod3; private Slider mod3;
private Slider mod4; private Slider mod4;
public SpawnerWindow(String title, Skin skin, EntityController ec, Stage stageForEntities) { public SpawnerWindow(String title, Skin skin, EntityManager ec, Stage stageForEntities) {
super(title, skin, "tinted"); super(title, skin, "tinted");
this.ec = ec; this.ec = ec;
stage = stageForEntities; stage = stageForEntities;
@ -67,41 +66,38 @@ public class SpawnerWindow extends Window {
stage.screenToStageCoordinates(coords); stage.screenToStageCoordinates(coords);
if (ec.getIndex().get(listOfEntities.getSelected()) != null) { switch(listOfEntities.getSelected()) {
Entity entity = ec.getIndex().get(listOfEntities.getSelected()).buildEntity(); case LASER:
switch(entity.getEntityType()) { Laser laser = ec.laser.buildEntity();
case LASER: laser.init(coords.x, coords.y, mod1.getValue());
Laser laser = (Laser) entity; stage.addActor(laser);
laser.init(coords.x, coords.y, mod1.getValue()); break;
stage.addActor(laser); case PELLET:
break; Pellet pellet = ec.pellet.buildEntity();
case PELLET: pellet.init(coords.x, coords.y, mod2.getValue()/mod2.getMaxValue()*360f, mod1.getValue());
Pellet pellet = (Pellet) entity; stage.addActor(pellet);
pellet.init(coords.x, coords.y, mod2.getValue()/mod2.getMaxValue()*360f, mod1.getValue()); break;
stage.addActor(pellet); case VOID_CIRCLE:
break; VoidCircle voidCircle = ec.voidCircle.buildEntity();
case VOID_CIRCLE: voidCircle.init(mod2.getValue(), coords.x, coords.y, mod1.getValue(), mod3.getValue());
VoidCircle voidCircle = (VoidCircle) entity; stage.addActor(voidCircle);
voidCircle.init(mod2.getValue(), coords.x, coords.y, mod1.getValue(), mod3.getValue()); break;
stage.addActor(voidCircle); case SHARD:
break; Shard shard = ec.shard.buildEntity();
case SHARD: shard.init(coords.x, coords.y, mod2.getValue()/mod2.getMaxValue()*360f, mod1.getValue(), (int) mod3.getValue());
Shard shard = (Shard) entity; stage.addActor(shard);
shard.init(coords.x, coords.y, mod2.getValue()/mod2.getMaxValue()*360f, mod1.getValue(), (int) mod3.getValue()); break;
stage.addActor(shard); case BAR:
break; Bar bar = ec.bar.buildEntity();
case BAR: bar.init(coords.x, mod1.getValue());
Bar bar = (Bar) entity; stage.addActor(bar);
bar.init(coords.x, mod1.getValue()); break;
stage.addActor(bar); case FLAKE:
break; Flake flake = ec.flake.buildEntity();
case FLAKE: flake.init(coords.x, coords.y, mod1.getValue(), mod3.getValue(), mod2.getValue()/mod2.getMaxValue()*360f, (int) mod4.getValue());
Flake flake = (Flake) entity; stage.addActor(flake);
flake.init(coords.x, coords.y, mod1.getValue(), mod3.getValue(), mod2.getValue()/mod2.getMaxValue()*360f, (int) mod4.getValue()); default:
stage.addActor(flake); break;
default:
break;
}
} }
} }
super.act(delta); super.act(delta);

View File

@ -8,7 +8,7 @@ import zero1hd.rhythmbullet.RhythmBullet;
public class DesktopLauncher { public class DesktopLauncher {
public static void main (String[] arg) { public static void main (String[] arg) {
LwjglApplicationConfiguration config = new LwjglApplicationConfiguration(); LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
config.title = "Polyjet"; config.title = "Rhythm Bullet";
config.width = 800; config.width = 800;
config.height = 480; config.height = 480;
config.resizable = false; config.resizable = false;