changing to a different way of handling entities (no longer using scene2d)
This commit is contained in:
parent
08fb879b1f
commit
1fbdefaecd
@ -46,7 +46,6 @@ public class AudioAnalyzer implements Disposable {
|
||||
|
||||
public boolean isDone() {
|
||||
if ((sfar.isDone() && tcr.isDone() && pfr.isDone() && pdr.isDone())) {
|
||||
dispose();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -109,8 +109,10 @@ public class PeakDetectionRunnable implements Runnable {
|
||||
pack.setSecPerWin(secondsPerWindow);
|
||||
pack.setMusicInfo(musicManager);
|
||||
if (work) {
|
||||
Gdx.app.debug("Audio Analyzer", "data cleaned and ready for map gen.");
|
||||
Gdx.app.debug("Audio Analyzer", "Peak detection complete. Data ready for map gen.");
|
||||
}
|
||||
|
||||
done = true;
|
||||
}
|
||||
|
||||
public AudioDataPackage getPack() {
|
||||
|
@ -35,8 +35,8 @@ public class SpectralFluxAnalysisRunnable implements Runnable {
|
||||
float[] spectrum = new float[(musicManager.getReadWindowSize()/2)+1];
|
||||
float[] lastSpectrum = new float[(musicManager.getReadWindowSize()/2)+1];
|
||||
|
||||
int bassBinBegin = 0;
|
||||
int bassBinEnd = 12;
|
||||
int bassBinBegin = 1;
|
||||
int bassBinEnd = 11;
|
||||
|
||||
int mBinBegin = 50;
|
||||
int mBinEnd = 250;
|
||||
@ -105,10 +105,10 @@ public class SpectralFluxAnalysisRunnable implements Runnable {
|
||||
if (work) {
|
||||
Gdx.app.debug("Audio Analyzer", "Done getting spectral flux.");
|
||||
Gdx.app.debug("Audio Analyzer", "window count: " + bassSpectralFlux.size);
|
||||
done = true;
|
||||
Gdx.app.debug("Audio Analyzer", "USING SEED: " + PUID);
|
||||
progress = 100;
|
||||
}
|
||||
done = true;
|
||||
}
|
||||
|
||||
public synchronized int getProgress() {
|
||||
|
@ -65,8 +65,8 @@ public class ThresholdCalcRunnable implements Runnable {
|
||||
average /= (end - start);
|
||||
umThreshold.add(average*umThresholdMultiplier);
|
||||
}
|
||||
done = true;
|
||||
Gdx.app.debug("Audio Analyzer", "Threshold calculated.");
|
||||
done = true;
|
||||
}
|
||||
|
||||
private int thresholdRangeCalc(float durationOfRange) {
|
||||
|
@ -1,7 +1,5 @@
|
||||
package zero1hd.rhythmbullet.entity;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import com.badlogic.gdx.Preferences;
|
||||
import com.badlogic.gdx.assets.AssetManager;
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
@ -10,13 +8,12 @@ import com.badlogic.gdx.graphics.g2d.Sprite;
|
||||
import com.badlogic.gdx.math.MathUtils;
|
||||
import com.badlogic.gdx.math.Rectangle;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||
import com.badlogic.gdx.utils.Pool.Poolable;
|
||||
|
||||
import zero1hd.rhythmbullet.RhythmBullet;
|
||||
import zero1hd.rhythmbullet.entity.coordinator.Coordinator;
|
||||
|
||||
public class Entity extends Actor implements Poolable {
|
||||
public class Entity implements Poolable {
|
||||
private Coordinator coordinator;
|
||||
private EntityFrame<?> ef;
|
||||
|
||||
@ -32,10 +29,10 @@ public class Entity extends Actor implements Poolable {
|
||||
protected Rectangle hitbox;
|
||||
protected Sprite sprite;
|
||||
protected Vector2 rotRatios;
|
||||
protected Vector2 center;
|
||||
public float angle;
|
||||
public float speed;
|
||||
|
||||
protected float hitBoxScale;
|
||||
|
||||
protected int points;
|
||||
|
||||
/**
|
||||
@ -51,7 +48,6 @@ public class Entity extends Actor implements Poolable {
|
||||
assets = ec.getAssets();
|
||||
prefs = ec.getPrefs();
|
||||
rotRatios = new Vector2();
|
||||
center = new Vector2();
|
||||
hitbox = new Rectangle();
|
||||
|
||||
preInit();
|
||||
@ -65,11 +61,8 @@ public class Entity extends Actor implements Poolable {
|
||||
sprite.setOriginCenter();
|
||||
}
|
||||
|
||||
/**
|
||||
* used by the game stage to pass parameters for different types of entities.
|
||||
* @param params a hashmap containing parameters necessary for different entities.
|
||||
*/
|
||||
public void init(HashMap<String, Float> params) {
|
||||
public void init(float deg, float speed, int hp) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -91,16 +84,12 @@ public class Entity extends Actor implements Poolable {
|
||||
return dead;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void act(float delta) {
|
||||
public void calculate(float delta) {
|
||||
if (!nonStnrd) {
|
||||
if (coordinator != null) {
|
||||
coordinator.coordinate(delta);
|
||||
}
|
||||
|
||||
if (move) {
|
||||
move(delta, true);
|
||||
}
|
||||
if (dead) {
|
||||
ef.recycleEntity(this);
|
||||
}
|
||||
@ -110,36 +99,29 @@ public class Entity extends Actor implements Poolable {
|
||||
angle -= 360f;
|
||||
}
|
||||
|
||||
if (getX() > RhythmBullet.GAME_AREA_WIDTH || getY() > RhythmBullet.GAME_AREA_HEIGHT || getX() < 0-getWidth() || getY() < 0-getHeight()) {
|
||||
if (sprite.getX() > RhythmBullet.GAME_AREA_WIDTH || sprite.getY() > RhythmBullet.GAME_AREA_HEIGHT || sprite.getX() < 0-sprite.getWidth() || sprite.getX() < 0-sprite.getWidth()) {
|
||||
dead = true;
|
||||
}
|
||||
super.act(delta);
|
||||
|
||||
updatePosition();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Batch batch, float parentAlpha) {
|
||||
public void draw(Batch batch) {
|
||||
if (!nonStnrd) {
|
||||
sprite.draw(batch);
|
||||
}
|
||||
batch.setColor(Color.WHITE);
|
||||
super.draw(batch, parentAlpha);
|
||||
}
|
||||
|
||||
public void move(float delta, boolean update) {
|
||||
public void moveBy(float x, float y) {
|
||||
rotRatios.set(MathUtils.cosDeg(angle), MathUtils.sinDeg(angle));
|
||||
moveBy(rotRatios.x*speed*delta, rotRatios.y*speed*delta);
|
||||
center.set(getX() + getWidth()/2f, getY() + getHeight()/2f);
|
||||
|
||||
if (update) {
|
||||
updatePositionData();
|
||||
}
|
||||
sprite.setCenter(x, y);
|
||||
}
|
||||
|
||||
public void updatePositionData() {
|
||||
sprite.setCenter(center.x, center.y);
|
||||
hitbox.setCenter(center);
|
||||
public void updatePosition() {
|
||||
sprite.setOriginCenter();
|
||||
sprite.setRotation(angle);
|
||||
hitbox.setCenter(sprite.getOriginX(), sprite.getOriginY());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -153,18 +135,12 @@ public class Entity extends Actor implements Poolable {
|
||||
hitbox.set(0, 0, 0, 0);
|
||||
sprite.setRotation(0);
|
||||
sprite.setColor(Color.WHITE);
|
||||
setPosition(0, 0);
|
||||
center.set(0, 0);
|
||||
angle = 0;
|
||||
speed = 0;
|
||||
points = 0;
|
||||
dead = false;
|
||||
}
|
||||
|
||||
public Vector2 getCenter() {
|
||||
return center;
|
||||
}
|
||||
|
||||
public float getAngle() {
|
||||
return angle;
|
||||
}
|
||||
@ -189,4 +165,33 @@ public class Entity extends Actor implements Poolable {
|
||||
public int getPoints() {
|
||||
return points + (coordinator != null ? coordinator.getScoreBonus() : 0);
|
||||
}
|
||||
|
||||
public float getX() {
|
||||
return sprite.getX();
|
||||
}
|
||||
|
||||
public float getY() {
|
||||
return sprite.getY();
|
||||
}
|
||||
|
||||
public void setPosition(float x, float y) {
|
||||
sprite.setPosition(x, y);
|
||||
updatePosition();
|
||||
}
|
||||
|
||||
public float getWidth() {
|
||||
return sprite.getWidth();
|
||||
}
|
||||
|
||||
public float getHeight() {
|
||||
return sprite.getHeight();
|
||||
}
|
||||
|
||||
public void setSize(float width, float height) {
|
||||
sprite.setSize(width, height);
|
||||
}
|
||||
|
||||
public void setHitboxScale(float scale) {
|
||||
hitbox.setSize(sprite.getWidth()*scale, sprite.getHeight()*scale);
|
||||
}
|
||||
}
|
||||
|
@ -56,7 +56,6 @@ public class EntityFrame<T extends Entity> {
|
||||
} else {
|
||||
ec.activeAllies.removeValue(entity, true);
|
||||
}
|
||||
entity.remove();
|
||||
pool.free(ct.cast(entity));
|
||||
}
|
||||
|
||||
|
@ -2,53 +2,40 @@ package zero1hd.rhythmbullet.entity;
|
||||
|
||||
import com.badlogic.gdx.Preferences;
|
||||
import com.badlogic.gdx.assets.AssetManager;
|
||||
import com.badlogic.gdx.scenes.scene2d.Stage;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
|
||||
import zero1hd.rhythmbullet.entity.ally.Laser;
|
||||
import zero1hd.rhythmbullet.entity.enemies.Flake;
|
||||
import zero1hd.rhythmbullet.entity.enemies.Pellet;
|
||||
import zero1hd.rhythmbullet.entity.enemies.Shard;
|
||||
import zero1hd.rhythmbullet.entity.enemies.VoidCircle;
|
||||
|
||||
public class EntityManager {
|
||||
private AssetManager assets;
|
||||
private Preferences prefs;
|
||||
private Stage stage;
|
||||
|
||||
public Array<Entity> activeAllies;
|
||||
public Array<Entity> activeEnemies;
|
||||
|
||||
public EntityFrame<VoidCircle> voidCircle;
|
||||
public EntityFrame<Pellet> pellet;
|
||||
public EntityFrame<Shard> shard;
|
||||
public EntityFrame<Flake> flake;
|
||||
|
||||
public EntityFrame<Laser> laser;
|
||||
|
||||
public EntityManager(AssetManager assetManager, Preferences preferences, Stage stage) {
|
||||
public EntityManager(AssetManager assetManager, Preferences preferences) {
|
||||
activeAllies = new Array<Entity>();
|
||||
activeEnemies = new Array<Entity>();
|
||||
this.assets = assetManager;
|
||||
this.prefs = preferences;
|
||||
this.stage = stage;
|
||||
|
||||
setup();
|
||||
}
|
||||
|
||||
private void setup() {
|
||||
voidCircle = new EntityFrame<>(this, VoidCircle.class);
|
||||
pellet = new EntityFrame<>(this, Pellet.class);
|
||||
shard = new EntityFrame<>(this, Shard.class);
|
||||
flake = new EntityFrame<>(this, Flake.class);
|
||||
laser = new EntityFrame<>(this, Laser.class);
|
||||
|
||||
}
|
||||
|
||||
public Stage getStage() {
|
||||
return stage;
|
||||
}
|
||||
|
||||
public AssetManager getAssets() {
|
||||
return assets;
|
||||
}
|
||||
|
@ -1,7 +1,5 @@
|
||||
package zero1hd.rhythmbullet.entity.ally;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import com.badlogic.gdx.audio.Sound;
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
import com.badlogic.gdx.graphics.g2d.Batch;
|
||||
@ -25,35 +23,20 @@ public class Laser extends Entity {
|
||||
setPosition(x-getWidth()/2f, y-getHeight()/2f);
|
||||
speed = rate;
|
||||
sfx.play(prefs.getFloat("fx vol")/100f);
|
||||
toBack();
|
||||
angle = 90f;
|
||||
}
|
||||
|
||||
/**
|
||||
* Vars: x, y, rate;
|
||||
*/
|
||||
@Override
|
||||
public void init(HashMap<String, Float> params) {
|
||||
setX(params.get("x") - getWidth()/2f);
|
||||
setY(params.get("y") - getHeight()/2f);
|
||||
speed = params.get("rate");
|
||||
angle = 90f;
|
||||
sfx.play(prefs.getFloat("fx vol")/100f);
|
||||
super.init(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void act(float delta) {
|
||||
toBack();
|
||||
public void calculate(float delta) {
|
||||
if (getY() > RhythmBullet.GAME_AREA_HEIGHT) {
|
||||
dead = true;
|
||||
}
|
||||
super.act(delta);
|
||||
super.calculate(delta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Batch batch, float parentAlpha) {
|
||||
super.draw(batch, parentAlpha);
|
||||
public void draw(Batch batch) {
|
||||
super.draw(batch);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -5,7 +5,6 @@ import com.badlogic.gdx.graphics.Texture;
|
||||
import com.badlogic.gdx.graphics.g2d.Batch;
|
||||
import com.badlogic.gdx.graphics.g2d.ParticleEffect;
|
||||
import com.badlogic.gdx.math.Rectangle;
|
||||
import com.badlogic.gdx.scenes.scene2d.actions.Actions;
|
||||
|
||||
import zero1hd.rhythmbullet.RhythmBullet;
|
||||
import zero1hd.rhythmbullet.entity.Entity;
|
||||
@ -34,11 +33,10 @@ public class PolyjetEntity extends Entity {
|
||||
|
||||
teleportCloak = assets.get("teleport-cloak.p", ParticleEffect.class);
|
||||
|
||||
addAction(Actions.moveTo(getX(), 4f, 0.5f));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void act(float delta) {
|
||||
public void calculate(float delta) {
|
||||
hitbox.setPosition(getX(), getY());
|
||||
|
||||
thrust.setPosition(getX()+(getWidth())/2 - 1f/16f, getY()-0.2f);
|
||||
@ -74,34 +72,14 @@ public class PolyjetEntity extends Entity {
|
||||
health = maxH;
|
||||
}
|
||||
|
||||
if (getX() <= 1) {
|
||||
moveLeft = false;
|
||||
setX(1f);
|
||||
}
|
||||
|
||||
if (getX() >= RhythmBullet.GAME_AREA_WIDTH-1-getWidth()) {
|
||||
moveRight = false;
|
||||
setX(RhythmBullet.GAME_AREA_WIDTH-1f-getWidth());
|
||||
}
|
||||
|
||||
if (getY() >= RhythmBullet.GAME_AREA_HEIGHT - 1 - getHeight()) {
|
||||
moveUp = false;
|
||||
setY(RhythmBullet.GAME_AREA_HEIGHT - 1 - getHeight());
|
||||
}
|
||||
|
||||
if (getY() <= 1) {
|
||||
moveDown = false;
|
||||
setY(1f);
|
||||
}
|
||||
|
||||
super.act(delta);
|
||||
super.calculate(delta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Batch batch, float parentAlpha) {
|
||||
public void draw(Batch batch) {
|
||||
thrust.draw(batch);
|
||||
batch.draw(polyjet, getX(), getY(), getWidth(), getHeight());
|
||||
super.draw(batch, parentAlpha);
|
||||
super.draw(batch);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,115 +0,0 @@
|
||||
package zero1hd.rhythmbullet.entity.enemies;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
import com.badlogic.gdx.graphics.g2d.Batch;
|
||||
import com.badlogic.gdx.graphics.g2d.Sprite;
|
||||
import com.badlogic.gdx.math.Rectangle;
|
||||
|
||||
import zero1hd.rhythmbullet.entity.Entity;
|
||||
import zero1hd.rhythmbullet.entity.ally.Laser;
|
||||
|
||||
public class Flake extends Entity {
|
||||
private float timer;
|
||||
private float totalTime;
|
||||
private Shard[] shards;
|
||||
|
||||
@Override
|
||||
public void preInit() {
|
||||
sprite = new Sprite(assets.get("flake.png", Texture.class));
|
||||
enemy = true;
|
||||
move = false;
|
||||
setSize(3f, 3f);
|
||||
sprite.setSize(getWidth(), getHeight());
|
||||
super.preInit();
|
||||
}
|
||||
|
||||
public void init(float x, float y, float rate, float fuse, float angle, int shardCount) {
|
||||
this.shards = new Shard[shardCount];
|
||||
for (int i = 0; i < shards.length; i++) {
|
||||
shards[i] = ec.shard.buildEntity();
|
||||
shards[i].init(x, y, 360/shards.length*i, 0, 2);
|
||||
ec.getStage().addActor(shards[i]);
|
||||
}
|
||||
|
||||
this.speed = rate;
|
||||
this.timer = fuse;
|
||||
this.totalTime = fuse;
|
||||
this.angle = angle;
|
||||
setPosition(x-getWidth()/2f, y-getHeight()/2f);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* params: shardCount, x, y, rate, fuse, angle;
|
||||
*/
|
||||
@Override
|
||||
public void init(HashMap<String, Float> params) {
|
||||
this.shards = new Shard[params.get("shardCount").intValue()];
|
||||
for (int i = 0; i < shards.length; i++) {
|
||||
shards[i] = ec.shard.buildEntity();
|
||||
shards[i].init(params.get("x"), params.get("y"), 360/shards.length*i, 0, 1);
|
||||
ec.getStage().addActor(shards[i]);
|
||||
}
|
||||
this.speed = params.get("rate");
|
||||
this.timer = params.get("fuse");
|
||||
this.totalTime = timer;
|
||||
this.angle = params.get("angle");
|
||||
hitbox.setSize(getWidth(), getHeight());
|
||||
setPosition(params.get("x")-getWidth()/2f, params.get("y")-getHeight()/2f);
|
||||
super.init(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void act(float delta) {
|
||||
if (timer > 0) {
|
||||
timer -= delta;
|
||||
}
|
||||
|
||||
move(delta, true);
|
||||
for (int i = 0; i < shards.length; i++) {
|
||||
shards[i].setPosition(center.x-shards[i].getWidth()/2f, center.y-shards[i].getWidth()/2f);
|
||||
shards[i].move(delta, true);
|
||||
}
|
||||
|
||||
if (timer <= 0) {
|
||||
for (int i = 0; i < shards.length; i++) {
|
||||
shards[i].setSpeed(30f);
|
||||
}
|
||||
dead = true;
|
||||
}
|
||||
|
||||
super.act(delta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Batch batch, float parentAlpha) {
|
||||
sprite.setColor(0f, 0f, 0f, 1-(timer/totalTime));
|
||||
super.draw(batch, parentAlpha);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collided(Entity entity) {
|
||||
if (entity.getClass() == Laser.class) {
|
||||
dead = true;
|
||||
for (int i = 0; i < shards.length; i++) {
|
||||
shards[i].kill();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Rectangle getHitZone() {
|
||||
return hitbox;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
timer = 0;
|
||||
shards = null;
|
||||
totalTime = 0;
|
||||
super.reset();
|
||||
}
|
||||
|
||||
}
|
@ -1,7 +1,5 @@
|
||||
package zero1hd.rhythmbullet.entity.enemies;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
import com.badlogic.gdx.graphics.g2d.Sprite;
|
||||
import com.badlogic.gdx.utils.Pool.Poolable;
|
||||
@ -19,27 +17,13 @@ public class Pellet extends Entity implements Poolable {
|
||||
super.preInit();
|
||||
}
|
||||
|
||||
public void init(float x, float y, float angle, float rate) {
|
||||
setPosition(x, y);
|
||||
this.speed = rate;
|
||||
this.angle = angle;
|
||||
@Override
|
||||
public void init(float deg, float speed, int hp) {
|
||||
this.speed = speed;
|
||||
this.angle = deg;
|
||||
super.init(deg, speed, hp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Vars: x, y, speed, angle;
|
||||
*/
|
||||
@Override
|
||||
public void init(HashMap<String, Float> params) {
|
||||
setPosition(params.get("x"), params.get("y"));
|
||||
speed = params.get("speed");
|
||||
angle = params.get("angle");
|
||||
super.init(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void act(float delta) {
|
||||
super.act(delta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collided(Entity entity) {
|
||||
|
@ -1,7 +1,5 @@
|
||||
package zero1hd.rhythmbullet.entity.enemies;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
import com.badlogic.gdx.graphics.g2d.Batch;
|
||||
import com.badlogic.gdx.graphics.g2d.Sprite;
|
||||
@ -23,26 +21,13 @@ public class Shard extends Entity {
|
||||
super.preInit();
|
||||
}
|
||||
|
||||
public void init(float x, float y, float angle, float rate, int hp) {
|
||||
speed = rate;
|
||||
@Override
|
||||
public void init(float deg, float speed, int hp) {
|
||||
this.speed = speed;
|
||||
this.hp = hp;
|
||||
maxHp = hp;
|
||||
this.angle = angle;
|
||||
setPosition(x-(getWidth()/2f), y-(getHeight()/2f));
|
||||
hitbox.setSize(getWidth(), getHeight());
|
||||
}
|
||||
|
||||
/**
|
||||
* x, y, angle, rate, hp;
|
||||
*/
|
||||
@Override
|
||||
public void init(HashMap<String, Float> params) {
|
||||
setX(params.get("x"));
|
||||
setY(params.get("y"));
|
||||
angle = params.get("angle");
|
||||
speed = params.get("rate");
|
||||
hp = params.get("hp").intValue();
|
||||
super.init(params);
|
||||
this.angle = deg;
|
||||
super.init(deg, speed, hp);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -53,17 +38,17 @@ public class Shard extends Entity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void act(float delta) {
|
||||
public void calculate(float delta) {
|
||||
if (hp <= 0) {
|
||||
dead = true;
|
||||
}
|
||||
super.act(delta);
|
||||
super.calculate(delta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Batch batch, float parentAlpha) {
|
||||
public void draw(Batch batch) {
|
||||
sprite.setColor(((float)hp/(float)maxHp), ((float)hp/(float)maxHp), ((float)hp/(float)maxHp), 0.5f);
|
||||
super.draw(batch, parentAlpha);
|
||||
super.draw(batch);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,115 +0,0 @@
|
||||
package zero1hd.rhythmbullet.entity.enemies;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import com.badlogic.gdx.audio.Sound;
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
import com.badlogic.gdx.graphics.g2d.Batch;
|
||||
import com.badlogic.gdx.graphics.g2d.Sprite;
|
||||
|
||||
import zero1hd.rhythmbullet.entity.Entity;
|
||||
|
||||
public class VoidCircle extends Entity {
|
||||
private float timer;
|
||||
private float endRadius;
|
||||
private float currentRadius;
|
||||
private float growthRate;
|
||||
private boolean begin;
|
||||
private float maxTime;
|
||||
private Sound sound;
|
||||
|
||||
@Override
|
||||
public void preInit() {
|
||||
sprite = new Sprite(assets.get("void_circle.png", Texture.class));
|
||||
enemy = true;
|
||||
sound = assets.get("disintegrate.ogg", Sound.class);
|
||||
super.preInit();
|
||||
}
|
||||
|
||||
public void init(float endRadius, float x, float y, float growthRate, float warningTime) {
|
||||
timer = warningTime;
|
||||
maxTime = warningTime;
|
||||
this.endRadius = endRadius;
|
||||
setSize(2f*endRadius, 2f*endRadius);
|
||||
setPosition(x-getWidth()/2f, y-getHeight()/2f);
|
||||
this.growthRate = growthRate;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* warningTime, endRadius, growthRate, x, y;
|
||||
*/
|
||||
@Override
|
||||
public void init(HashMap<String, Float> params) {
|
||||
timer = params.get("warningTime");
|
||||
maxTime = timer;
|
||||
endRadius = params.get("endRadius");
|
||||
setSize(2f*endRadius, 2f*endRadius);
|
||||
setPosition(params.get("x")-getWidth()/2f, params.get("y")-getHeight()/2f);
|
||||
growthRate = params.get("growthRate");
|
||||
super.init(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void act(float delta) {
|
||||
toFront();
|
||||
if (begin) {
|
||||
sprite.setSize(2*currentRadius, 2*currentRadius);
|
||||
sprite.setColor(0f,0f,0f,1f);
|
||||
} else {
|
||||
sprite.setSize(2*endRadius, 2*endRadius);
|
||||
sprite.setColor(1f,0.52f,0.32f,0.1f*(timer/maxTime));
|
||||
}
|
||||
|
||||
if (timer > 0) {
|
||||
timer -= delta;
|
||||
} else {
|
||||
begin = true;
|
||||
if (currentRadius < endRadius) {
|
||||
growCurrentRadius(delta*growthRate);
|
||||
} else {
|
||||
endRadius = -1f;
|
||||
if (currentRadius > 0) {
|
||||
growCurrentRadius(delta*-growthRate);
|
||||
} else {
|
||||
dead = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
super.act(delta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Batch batch, float parentAlpha) {
|
||||
super.draw(batch, parentAlpha);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
currentRadius = 0;
|
||||
growthRate = 0;
|
||||
timer = 0;
|
||||
maxTime = 0;
|
||||
endRadius = 0;
|
||||
begin = false;
|
||||
setSize(0, 0);
|
||||
|
||||
super.reset();
|
||||
}
|
||||
|
||||
public void growCurrentRadius(float radius) {
|
||||
currentRadius += radius;
|
||||
float length = (float) Math.sqrt(2*(currentRadius*currentRadius));
|
||||
if (length < 0) {
|
||||
length = 0;
|
||||
}
|
||||
hitbox.setSize(length, length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collided(Entity entity) {
|
||||
if (begin) {
|
||||
sound.play(prefs.getFloat("fx vol"));
|
||||
}
|
||||
}
|
||||
}
|
@ -9,11 +9,8 @@ import zero1hd.rhythmbullet.RhythmBullet;
|
||||
import zero1hd.rhythmbullet.audio.AudioDataPackage;
|
||||
import zero1hd.rhythmbullet.entity.EntityManager;
|
||||
import zero1hd.rhythmbullet.entity.coordinator.CoordinatorManager;
|
||||
import zero1hd.rhythmbullet.util.MiniEvents;
|
||||
import zero1hd.rhythmbullet.util.MiniSender;
|
||||
|
||||
public class RhythmMapAlgorithm implements Runnable {
|
||||
private MiniSender sender;
|
||||
|
||||
private EntityManager em;
|
||||
private CoordinatorManager cm;
|
||||
@ -38,8 +35,6 @@ public class RhythmMapAlgorithm implements Runnable {
|
||||
this.cm = cm;
|
||||
this.em = em;
|
||||
|
||||
sender = new MiniSender();
|
||||
|
||||
bassPeaks = adp.getBassPeaks();
|
||||
mPeaks = adp.getmPeaks();
|
||||
umPeaks = adp.getuMPeaks();
|
||||
@ -64,82 +59,8 @@ public class RhythmMapAlgorithm implements Runnable {
|
||||
@Override
|
||||
public void run() {
|
||||
map.beginBuild();
|
||||
for (int index = 0; index < bassPeaks.size; index++) {
|
||||
if (bassPeaks.get(index) != 0 || umPeaks.get(index) != 0) {
|
||||
if (bassPeaks.get(index) != 0) {
|
||||
//If there is a value of some sorts that is not zero, we generate some beat for the map
|
||||
if (index > 1.5*windowPerSecond && bassPeaks.get(index) > avgBass) {
|
||||
//If bass peak is greater than the bass peak average, then:
|
||||
int normalIndexPos = map.setIndex((int) (map.getIndex() - windowPerSecond*1.5f));
|
||||
float waitTime = 1.5f;
|
||||
float endRadius = (bassPeaks.get(index)/bassMax)*(RhythmBullet.GAME_AREA_HEIGHT/4f);
|
||||
|
||||
esi = map.addEntity(em.voidCircle, null);
|
||||
esi.parameters.put("warningTime", waitTime);
|
||||
esi.parameters.put("endRadius", endRadius);
|
||||
esi.parameters.put("growthRate", endRadius/(avgSPB*0.8f));
|
||||
esi.parameters.put("x", rand.nextFloat()*RhythmBullet.GAME_AREA_WIDTH);
|
||||
esi.parameters.put("y", rand.nextFloat()*RhythmBullet.GAME_AREA_HEIGHT);
|
||||
|
||||
map.setIndex(normalIndexPos);
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (umPeaks.get(index) != 0) {
|
||||
if (umPeaks.get(index) >= avgUM*1.75f) {
|
||||
//If upper midrange peaks are greater than average, the:
|
||||
esi = map.addEntity(em.flake, null);
|
||||
|
||||
float xSpawn = (rand.nextFloat()*RhythmBullet.GAME_AREA_WIDTH) < RhythmBullet.GAME_AREA_WIDTH/2f ? 0 : RhythmBullet.GAME_AREA_WIDTH;
|
||||
float ySpawn = (rand.nextFloat()*RhythmBullet.GAME_AREA_HEIGHT < RhythmBullet.GAME_AREA_HEIGHT/2f ? 0 : RhythmBullet.GAME_AREA_HEIGHT);
|
||||
|
||||
float angle = rand.nextFloat()*90;
|
||||
if (xSpawn == 0) {
|
||||
if (ySpawn != 0) {
|
||||
angle += 270;
|
||||
}
|
||||
} else {
|
||||
if (ySpawn == 0) {
|
||||
angle += 90;
|
||||
} else {
|
||||
angle += 180;
|
||||
}
|
||||
}
|
||||
esi.parameters.put("shardCount", (1f+(difficultyMod/100f))*4f);
|
||||
esi.parameters.put("x", xSpawn);
|
||||
esi.parameters.put("y", ySpawn);
|
||||
esi.parameters.put("rate", (5/avgSPB)*speedMod);
|
||||
esi.parameters.put("fuse", avgSPB*10f);
|
||||
esi.parameters.put("angle", angle);
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (rand.nextFloat() < 0.15f) {
|
||||
switch(rand.nextInt(10)) {
|
||||
case 0:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
map.nextWindowData();
|
||||
|
||||
progress = MathUtils.round(100f*index/bassPeaks.size);
|
||||
|
||||
if (bassPeaks.get(index) > avgBass) {
|
||||
map.setHUDType((byte) 1);
|
||||
} else if (umPeaks.get(index) > avgUM) {
|
||||
map.setHUDType((byte) 2);
|
||||
}
|
||||
|
||||
sender.send(MiniEvents.MAPGEN_ITERATED);
|
||||
}
|
||||
//TODO Map gen algorithm
|
||||
map.endBuild();
|
||||
sender.send(MiniEvents.MAP_GENERATED);
|
||||
}
|
||||
|
||||
public synchronized GamePlayMap getMap() {
|
||||
@ -149,8 +70,4 @@ public class RhythmMapAlgorithm implements Runnable {
|
||||
public synchronized int getProgress() {
|
||||
return progress;
|
||||
}
|
||||
|
||||
public MiniSender getSender() {
|
||||
return sender;
|
||||
}
|
||||
}
|
||||
|
@ -86,12 +86,14 @@ public class AnalysisPage extends Page {
|
||||
speedModifierSlider.setDisabled(true);
|
||||
healthModifierSlider.setDisabled(true);
|
||||
difficultyModifierSlider.setDisabled(true);
|
||||
|
||||
progressLabel.setText("Loading...");
|
||||
}
|
||||
});
|
||||
|
||||
adjustment.add(confirmButton).colspan(3).fillX();
|
||||
adjustment.row();
|
||||
progressLabel = new Label("Loading... ", skin);
|
||||
progressLabel = new Label("Please confirm... ", skin);
|
||||
adjustment.add(progressLabel).colspan(2).left().spaceTop(20f);
|
||||
|
||||
backButton = new TextButton("Cancel", skin);
|
||||
@ -127,9 +129,11 @@ public class AnalysisPage extends Page {
|
||||
|
||||
@Override
|
||||
public void act(float delta) {
|
||||
if (aa != null && aa.isDone() && confirmed) {
|
||||
//TODO GAMESCREEN!!!
|
||||
}
|
||||
if (aa != null && aa.isDone()) {
|
||||
if (confirmed) {
|
||||
|
||||
}
|
||||
}
|
||||
super.act(delta);
|
||||
}
|
||||
|
||||
|
@ -1,119 +0,0 @@
|
||||
package zero1hd.rhythmbullet.desktop.graphics.ui.windows;
|
||||
|
||||
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.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.Slider;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Window;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
|
||||
import zero1hd.rhythmbullet.entity.Entity;
|
||||
import zero1hd.rhythmbullet.entity.EntityFrame;
|
||||
import zero1hd.rhythmbullet.entity.EntityManager;
|
||||
import zero1hd.rhythmbullet.entity.ally.Laser;
|
||||
import zero1hd.rhythmbullet.entity.coordinator.Coordinator;
|
||||
import zero1hd.rhythmbullet.entity.coordinator.CoordinatorFrame;
|
||||
import zero1hd.rhythmbullet.entity.coordinator.CoordinatorManager;
|
||||
import zero1hd.rhythmbullet.entity.enemies.Flake;
|
||||
import zero1hd.rhythmbullet.entity.enemies.Pellet;
|
||||
import zero1hd.rhythmbullet.entity.enemies.Shard;
|
||||
import zero1hd.rhythmbullet.entity.enemies.VoidCircle;
|
||||
|
||||
public class SpawnerWindow extends Window {
|
||||
private Stage stage;
|
||||
|
||||
private Array<EntityFrame<? extends Entity>> entityFrames = new Array<>();
|
||||
private List<EntityFrame<? extends Entity>> listOfEntities;
|
||||
private ScrollPane entityListScroller;
|
||||
|
||||
private Array<CoordinatorFrame<? extends Coordinator>> coordinatorFrames = new Array<>();
|
||||
private List<CoordinatorFrame<? extends Coordinator>> listOfCoordinators;
|
||||
private ScrollPane coordinatorListScroller;
|
||||
|
||||
private Slider mod1;
|
||||
private Slider mod2;
|
||||
private Slider mod3;
|
||||
private Slider mod4;
|
||||
|
||||
public SpawnerWindow(String title, Skin skin, EntityManager em, CoordinatorManager cm, Stage stageForEntities) {
|
||||
super(title, skin, "tinted");
|
||||
stage = stageForEntities;
|
||||
|
||||
defaults().pad(15f);
|
||||
|
||||
mod1 = new Slider(0.1f, 50f, 0.01f, true, skin);
|
||||
mod2 = new Slider(0f, 15f, 0.01f, true, skin);
|
||||
mod3 = new Slider(0.1f, 15f, 0.01f, true, skin);
|
||||
mod4 = new Slider(1f, 12f, 0.01f, true, skin);
|
||||
|
||||
add(mod1, mod2, mod3, mod4);
|
||||
|
||||
listOfEntities = new List<>(skin);
|
||||
entityFrames.add(em.flake);
|
||||
entityFrames.add(em.laser);
|
||||
entityFrames.add(em.pellet);
|
||||
entityFrames.add(em.shard);
|
||||
entityFrames.add(em.voidCircle);
|
||||
|
||||
listOfEntities.setItems(entityFrames);
|
||||
entityListScroller = new ScrollPane(listOfEntities, skin);
|
||||
add(entityListScroller).width(100f).fillY();
|
||||
|
||||
|
||||
listOfCoordinators = new List<>(skin);
|
||||
coordinatorFrames.add(cm.slowLeft);
|
||||
coordinatorFrames.add(cm.slowRight);
|
||||
|
||||
listOfCoordinators.setItems(coordinatorFrames);
|
||||
coordinatorListScroller = new ScrollPane(listOfCoordinators, skin);
|
||||
add(coordinatorListScroller).width(100f).fillY();
|
||||
|
||||
|
||||
pack();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean remove() {
|
||||
return super.remove();
|
||||
}
|
||||
|
||||
private Vector2 coords = new Vector2();
|
||||
@Override
|
||||
public void act(float delta) {
|
||||
if (Gdx.input.justTouched() && Gdx.input.isKeyPressed(Keys.CONTROL_LEFT)) {
|
||||
coords.set(Gdx.input.getX(), Gdx.input.getY());
|
||||
stage.screenToStageCoordinates(coords);
|
||||
|
||||
Entity entity = listOfEntities.getSelected().buildEntity();
|
||||
|
||||
if (Gdx.input.isKeyPressed(Keys.ALT_LEFT)) {
|
||||
entity.setCoordinator(listOfCoordinators.getSelected().buildCoordinator());
|
||||
}
|
||||
|
||||
if (entity.getClass() == Laser.class) {
|
||||
Laser laser = (Laser) entity;
|
||||
laser.init(coords.x, coords.y, mod1.getValue());
|
||||
} else if (entity.getClass() == Pellet.class) {
|
||||
Pellet pellet = (Pellet) entity;
|
||||
pellet.init(coords.x, coords.y, mod2.getValue()/mod2.getMaxValue()*360f, mod1.getValue());
|
||||
} else if (entity.getClass() == VoidCircle.class) {
|
||||
VoidCircle voidCircle = (VoidCircle) entity;
|
||||
voidCircle.init(mod2.getValue(), coords.x, coords.y, mod1.getValue(), mod3.getValue());
|
||||
} else if (entity.getClass() == Shard.class) {
|
||||
Shard shard = (Shard) entity;
|
||||
shard.init(coords.x, coords.y, mod2.getValue()/mod2.getMaxValue()*360f, mod1.getValue(), (int) mod3.getValue());
|
||||
} else if (entity.getClass() == Flake.class) {
|
||||
Flake flake = (Flake) entity;
|
||||
flake.init(coords.x, coords.y, mod1.getValue(), mod3.getValue(), mod2.getValue()/mod2.getMaxValue()*360f, (int) mod4.getValue());
|
||||
}
|
||||
|
||||
stage.addActor(entity);
|
||||
}
|
||||
super.act(delta);
|
||||
}
|
||||
}
|
@ -1,290 +0,0 @@
|
||||
package zero1hd.rhythmbullet.desktop.screens;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.InputMultiplexer;
|
||||
import com.badlogic.gdx.Screen;
|
||||
import com.badlogic.gdx.ScreenAdapter;
|
||||
import com.badlogic.gdx.graphics.GL20;
|
||||
import com.badlogic.gdx.graphics.Pixmap.Format;
|
||||
import com.badlogic.gdx.graphics.g2d.Batch;
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||
import com.badlogic.gdx.graphics.glutils.FrameBuffer;
|
||||
import com.badlogic.gdx.graphics.glutils.ShaderProgram;
|
||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.ImageButton;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
|
||||
import com.badlogic.gdx.utils.viewport.ScreenViewport;
|
||||
|
||||
import zero1hd.rhythmbullet.RhythmBullet;
|
||||
import zero1hd.rhythmbullet.desktop.audio.map.GamePlayMap;
|
||||
import zero1hd.rhythmbullet.desktop.stages.GameHUD;
|
||||
import zero1hd.rhythmbullet.desktop.stages.GamePlayArea;
|
||||
import zero1hd.rhythmbullet.util.MusicManager;
|
||||
|
||||
public class GameScreen extends ScreenAdapter {
|
||||
|
||||
protected GamePlayArea gameArea;
|
||||
public GameHUD gameHUD;
|
||||
|
||||
protected InputMultiplexer inputs;
|
||||
public RhythmBullet core;
|
||||
|
||||
private MusicManager music;
|
||||
|
||||
private ShaderProgram gaussianBlurShader;
|
||||
private ShaderProgram brightFilterShader;
|
||||
private ShaderProgram combineShader;
|
||||
private FrameBuffer lightFilterBuffer;
|
||||
private FrameBuffer normalBuffer;
|
||||
private FrameBuffer hBlur, vBlur;
|
||||
private TextureRegion fboRegion;
|
||||
private int fboSize;
|
||||
private Batch batch;
|
||||
private ScreenViewport screenViewport;
|
||||
private int blurlvl = 4;
|
||||
|
||||
/**
|
||||
* The game screen where the game play area, and hud are placed.
|
||||
* @param core The game context object
|
||||
* @param screen the screen to return to if player decides to press "quit" button.
|
||||
*/
|
||||
public GameScreen(RhythmBullet core, Screen screen) {
|
||||
this.core = core;
|
||||
|
||||
// Overlay stuff
|
||||
ImageButton pause = new ImageButton(core.getDefaultSkin().getDrawable("pause"),
|
||||
core.getDefaultSkin().getDrawable("pause-down"));
|
||||
pause.setPosition(Gdx.graphics.getWidth() - pause.getWidth() - 25,
|
||||
Gdx.graphics.getHeight() - pause.getHeight() - 25);
|
||||
pause.addListener(new ChangeListener() {
|
||||
@Override
|
||||
public void changed(ChangeEvent event, Actor actor) {
|
||||
pause();
|
||||
}
|
||||
});
|
||||
|
||||
gameArea = new GamePlayArea(core.getAssetManager(), core.getPrefs());
|
||||
gameHUD = new GameHUD(core.getDefaultSkin(), 100f, gameArea, screen, core);
|
||||
inputs = new InputMultiplexer();
|
||||
inputs.addProcessor(gameHUD);
|
||||
inputs.addProcessor(gameArea);
|
||||
|
||||
}
|
||||
|
||||
public void setGamePlayMap(GamePlayMap gpm) {
|
||||
music = gpm.getMusicData();
|
||||
gameArea.setAudioMap(gpm);
|
||||
gameHUD.setMusic(gpm.getMusicData());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void show() {
|
||||
Gdx.input.setInputProcessor(inputs);
|
||||
loadShaders();
|
||||
super.show();
|
||||
}
|
||||
|
||||
/**
|
||||
* needs to be called right after set as screen (should be called in show method).
|
||||
* This is due to the saving preference being done once the screen is hidden.
|
||||
* @param prefs
|
||||
*/
|
||||
public void loadShaders() {
|
||||
if (core.getPrefs().getBoolean("glow shader")) {
|
||||
batch = new SpriteBatch();
|
||||
screenViewport = new ScreenViewport();
|
||||
|
||||
Gdx.app.debug("Shader", "using glow shader");
|
||||
brightFilterShader = new ShaderProgram(Gdx.files.internal("shaders/basic.vsh"), Gdx.files.internal("shaders/bright_filter.fsh"));
|
||||
if (!brightFilterShader.isCompiled()) {
|
||||
Gdx.app.error("Shader failed to compile", brightFilterShader.getLog());
|
||||
System.exit(0);
|
||||
}
|
||||
if (brightFilterShader.getLog().length() != 0) {
|
||||
Gdx.app.error("Shader", brightFilterShader.getLog());
|
||||
}
|
||||
|
||||
gaussianBlurShader = new ShaderProgram(Gdx.files.internal("shaders/basic.vsh"), Gdx.files.internal("shaders/gaussian_blur.fsh"));
|
||||
if (!gaussianBlurShader.isCompiled()) {
|
||||
Gdx.app.error("Shader failed to compile", gaussianBlurShader.getLog());
|
||||
System.exit(0);
|
||||
}
|
||||
if (gaussianBlurShader.getLog().length() != 0) {
|
||||
Gdx.app.error("Shader", gaussianBlurShader.getLog());
|
||||
}
|
||||
|
||||
combineShader = new ShaderProgram(Gdx.files.internal("shaders/basic.vsh"), Gdx.files.internal("shaders/combine.fsh"));
|
||||
if (!combineShader.isCompiled()) {
|
||||
Gdx.app.error("Shader failed to compile", combineShader.getLog());
|
||||
System.exit(0);
|
||||
}
|
||||
if (combineShader.getLog().length() != 0) {
|
||||
Gdx.app.error("Shader", combineShader.getLog());
|
||||
}
|
||||
|
||||
|
||||
if (Gdx.graphics.getWidth() < 1024) {
|
||||
fboSize = 2048;
|
||||
} else if (Gdx.graphics.getWidth() < 2048) {
|
||||
fboSize = 4096;
|
||||
} else {
|
||||
fboSize = 4096;
|
||||
}
|
||||
|
||||
lightFilterBuffer = new FrameBuffer(Format.RGBA8888, fboSize/2, fboSize/2, false);
|
||||
normalBuffer = new FrameBuffer(Format.RGBA8888, fboSize, fboSize, false);
|
||||
hBlur = new FrameBuffer(Format.RGBA8888, fboSize/2, fboSize/2, false);
|
||||
vBlur = new FrameBuffer(Format.RGBA8888, fboSize/2, fboSize/2, false);
|
||||
|
||||
fboRegion = new TextureRegion(normalBuffer.getColorBufferTexture());
|
||||
fboRegion.flip(false, true);
|
||||
|
||||
combineShader.begin();
|
||||
combineShader.setUniformi("u_texture1", 1);
|
||||
combineShader.end();
|
||||
|
||||
vBlur.getColorBufferTexture().bind(1);
|
||||
|
||||
Gdx.gl.glActiveTexture(GL20.GL_TEXTURE0);
|
||||
}
|
||||
|
||||
ShaderProgram.pedantic = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(float delta) {
|
||||
Gdx.gl.glClearColor(0f, 0f, 0f, 1f);
|
||||
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
||||
//actual game and hud
|
||||
if (!gameHUD.isPaused()) {
|
||||
gameArea.act(delta);
|
||||
if (gameArea.getPolyjetEntity().isDead()) {
|
||||
end(false);
|
||||
}
|
||||
gameHUD.act(delta);
|
||||
}
|
||||
gameArea.getViewport().apply();
|
||||
|
||||
blurlvl = 4;
|
||||
if (gaussianBlurShader != null) {
|
||||
//Begin drawing a normal version of screen
|
||||
gameArea.getViewport().apply();
|
||||
normalBuffer.begin();
|
||||
Gdx.gl.glClearColor(0.22f, 0f, 0f, 1f);
|
||||
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
||||
gameArea.draw();
|
||||
normalBuffer.end();
|
||||
//END STAGE BATCH
|
||||
|
||||
//BEGINNING NORMAL SCREEN RENDER
|
||||
screenViewport.apply();
|
||||
//Begin light filtering
|
||||
lightFilterBuffer.begin();
|
||||
Gdx.gl.glClearColor(0f, 0f, 0f, 1f);
|
||||
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
||||
fboRegion.setTexture(normalBuffer.getColorBufferTexture());
|
||||
batch.setShader(brightFilterShader);
|
||||
batch.begin(); //BATCH STARTS HERE
|
||||
batch.draw(fboRegion, 0, 0, gameArea.getWidth(), gameArea.getHeight());
|
||||
batch.flush();
|
||||
lightFilterBuffer.end();
|
||||
|
||||
for (int i = 0; i < blurlvl; i++) {
|
||||
//Horizontal gaussian blur
|
||||
hBlur.begin();
|
||||
if (i > 0) {
|
||||
fboRegion.setTexture(vBlur.getColorBufferTexture());
|
||||
} else {
|
||||
fboRegion.setTexture(lightFilterBuffer.getColorBufferTexture());
|
||||
} batch.setShader(gaussianBlurShader);
|
||||
gaussianBlurShader.setUniformi("horizontal", 1);
|
||||
batch.draw(fboRegion, 0f, 0f, gameArea.getWidth(), gameArea.getHeight());
|
||||
batch.flush();
|
||||
hBlur.end();
|
||||
|
||||
//Vertical gaussian blur
|
||||
vBlur.begin();
|
||||
fboRegion.setTexture(hBlur.getColorBufferTexture());
|
||||
batch.setShader(gaussianBlurShader);
|
||||
gaussianBlurShader.setUniformi("horizontal", 0);
|
||||
batch.draw(fboRegion, 0f, 0f, gameArea.getWidth(), gameArea.getHeight());
|
||||
batch.flush();
|
||||
vBlur.end();
|
||||
}
|
||||
|
||||
//draw a final copy to a fbo
|
||||
Gdx.gl.glClearColor(0f, 0f, 0f, 0f);
|
||||
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
||||
batch.setShader(combineShader);
|
||||
fboRegion.setTexture(normalBuffer.getColorBufferTexture());
|
||||
batch.draw(fboRegion, 0f, 0f, gameArea.getWidth(), gameArea.getHeight());
|
||||
batch.setShader(null);
|
||||
batch.end(); //STAGE BATCH ENDS HERE
|
||||
|
||||
} else {
|
||||
gameArea.draw();
|
||||
}
|
||||
|
||||
gameHUD.getViewport().apply();
|
||||
gameHUD.draw();
|
||||
if (music != null && !music.isPlaying()) {
|
||||
end(true);
|
||||
}
|
||||
|
||||
super.render(delta);
|
||||
}
|
||||
|
||||
private void end(boolean trueEnd) {
|
||||
if (trueEnd) {
|
||||
// TODO they didn't die
|
||||
} else {
|
||||
// TODO They done goofed and ended up dying.
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
gameHUD.dispose();
|
||||
gameArea.dispose();
|
||||
|
||||
if (gaussianBlurShader != null) {
|
||||
normalBuffer.dispose();
|
||||
lightFilterBuffer.dispose();
|
||||
hBlur.dispose();
|
||||
vBlur.dispose();
|
||||
|
||||
brightFilterShader.dispose();
|
||||
gaussianBlurShader.dispose();
|
||||
combineShader.dispose();
|
||||
gaussianBlurShader.dispose();
|
||||
}
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pause() {
|
||||
gameHUD.setPaused(true);
|
||||
super.pause();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resize(int width, int height) {
|
||||
gameArea.getViewport().update(width, height, true);
|
||||
gameHUD.getViewport().update(width, height, true);
|
||||
|
||||
super.resize(width, height);
|
||||
}
|
||||
|
||||
public GamePlayArea getGameArea() {
|
||||
return gameArea;
|
||||
}
|
||||
|
||||
public void play() {
|
||||
if (music == null) throw new NullPointerException("Idiot, you can't have a music game not have music on the gameplay screen...");
|
||||
Gdx.input.setInputProcessor(inputs);
|
||||
if (!gameHUD.isPaused()) {
|
||||
music.play();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,18 +1,15 @@
|
||||
package zero1hd.rhythmbullet.desktop.stages;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.InputProcessor;
|
||||
import com.badlogic.gdx.Preferences;
|
||||
import com.badlogic.gdx.assets.AssetManager;
|
||||
import com.badlogic.gdx.scenes.scene2d.Stage;
|
||||
import com.badlogic.gdx.utils.viewport.FitViewport;
|
||||
import com.badlogic.gdx.graphics.g2d.Batch;
|
||||
import com.badlogic.gdx.utils.Disposable;
|
||||
|
||||
import zero1hd.rhythmbullet.RhythmBullet;
|
||||
import zero1hd.rhythmbullet.controls.KeyMap;
|
||||
import zero1hd.rhythmbullet.desktop.audio.map.EntitySpawnInfo;
|
||||
import zero1hd.rhythmbullet.desktop.audio.map.GamePlayMap;
|
||||
import zero1hd.rhythmbullet.desktop.audio.map.MapWindowData;
|
||||
import zero1hd.rhythmbullet.entity.CollisionDetector;
|
||||
import zero1hd.rhythmbullet.entity.Entity;
|
||||
import zero1hd.rhythmbullet.entity.EntityManager;
|
||||
import zero1hd.rhythmbullet.entity.ally.Laser;
|
||||
import zero1hd.rhythmbullet.entity.ally.PolyjetEntity;
|
||||
@ -20,7 +17,7 @@ import zero1hd.rhythmbullet.entity.coordinator.CoordinatorManager;
|
||||
import zero1hd.rhythmbullet.util.ScoreManager;
|
||||
|
||||
|
||||
public class GamePlayArea extends Stage {
|
||||
public class GameController implements Disposable, InputProcessor {
|
||||
public PolyjetEntity polyjet;
|
||||
private GamePlayMap audioMap;
|
||||
|
||||
@ -30,17 +27,35 @@ public class GamePlayArea extends Stage {
|
||||
|
||||
public ScoreManager score = new ScoreManager();
|
||||
|
||||
public GamePlayArea(AssetManager assetManager, Preferences prefs) {
|
||||
super(new FitViewport(RhythmBullet.GAME_AREA_WIDTH, RhythmBullet.GAME_AREA_HEIGHT));
|
||||
public GameController(AssetManager assetManager, Preferences prefs) {
|
||||
Gdx.app.debug("Game Area", "new area created");
|
||||
|
||||
polyjet = new PolyjetEntity(assetManager, 25f, 25f, 100, "standard");
|
||||
em = new EntityManager(assetManager, prefs, this);
|
||||
em = new EntityManager(assetManager, prefs);
|
||||
cm = new CoordinatorManager(em);
|
||||
|
||||
collisionDetector = new CollisionDetector(em.activeEnemies, em.activeAllies, assetManager, prefs);
|
||||
em.activeAllies.add(polyjet);
|
||||
addActor(polyjet);
|
||||
}
|
||||
|
||||
public void draw(Batch batch) {
|
||||
batch.begin();
|
||||
for (int i = 0; i < em.activeEnemies.size; i++) {
|
||||
em.activeEnemies.get(i).draw(batch);
|
||||
}
|
||||
for (int i = 0; i < em.activeAllies.size; i++) {
|
||||
em.activeAllies.get(i).draw(batch);
|
||||
}
|
||||
batch.end();
|
||||
}
|
||||
|
||||
public void prepare(float delta) {
|
||||
for (int i = 0; i < em.activeEnemies.size; i++) {
|
||||
em.activeEnemies.get(i).updatePosition();
|
||||
}
|
||||
for (int i = 0; i < em.activeAllies.size; i++) {
|
||||
em.activeAllies.get(i).updatePosition();
|
||||
}
|
||||
}
|
||||
|
||||
public void setAudioMap(GamePlayMap audioMap) {
|
||||
@ -51,38 +66,6 @@ public class GamePlayArea extends Stage {
|
||||
return audioMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw() {
|
||||
super.draw();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void act(float delta) {
|
||||
MapWindowData mwd;
|
||||
if (audioMap != null && audioMap.getMusicData().isPlaying()) {
|
||||
audioMap.getMusicData().playbackIndexUpdate();
|
||||
if ((mwd = audioMap.getCurrentWindowBasedOnIndex()) != null) {
|
||||
EntitySpawnInfo[] currentSpawnInfo = mwd.getArray();
|
||||
if (currentSpawnInfo != null) {
|
||||
for (int i = 0; i < currentSpawnInfo.length; i++) {
|
||||
Entity entity = currentSpawnInfo[i].getEntityToSpawn().buildEntity();
|
||||
if (currentSpawnInfo[i].getEntityCoordinator() != null) {
|
||||
entity.setCoordinator(currentSpawnInfo[i].getEntityCoordinator().buildCoordinator());
|
||||
}
|
||||
|
||||
entity.init(currentSpawnInfo[i].parameters);
|
||||
addActor(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
collisionDetector.collisionCheck();
|
||||
score.addScore(collisionDetector.getAmassedPoints());
|
||||
|
||||
super.act(delta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean keyDown(int keycode) {
|
||||
if (keycode == KeyMap.left) {
|
||||
@ -128,7 +111,6 @@ public class GamePlayArea extends Stage {
|
||||
if (keycode == KeyMap.shoot) {
|
||||
Laser laser = em.laser.buildEntity();
|
||||
laser.init(polyjet.getX() + polyjet.getWidth()/2f, polyjet.getY() + polyjet.getHeight()+1f, 60f);
|
||||
addActor(laser);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -139,10 +121,39 @@ public class GamePlayArea extends Stage {
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
public CollisionDetector getCollisionDetector() {
|
||||
return collisionDetector;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean keyTyped(char character) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean touchDown(int screenX, int screenY, int pointer, int button) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean touchUp(int screenX, int screenY, int pointer, int button) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean touchDragged(int screenX, int screenY, int pointer) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseMoved(int screenX, int screenY) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean scrolled(int amount) {
|
||||
return false;
|
||||
}
|
||||
}
|
@ -1,241 +0,0 @@
|
||||
package zero1hd.rhythmbullet.desktop.stages;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.Input.Keys;
|
||||
import com.badlogic.gdx.Screen;
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.graphics.Pixmap;
|
||||
import com.badlogic.gdx.graphics.Pixmap.Format;
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
import com.badlogic.gdx.graphics.Texture.TextureFilter;
|
||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||
import com.badlogic.gdx.scenes.scene2d.Stage;
|
||||
import com.badlogic.gdx.scenes.scene2d.actions.Actions;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Image;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.ImageButton;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Label;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
|
||||
|
||||
import zero1hd.rhythmbullet.RhythmBullet;
|
||||
import zero1hd.rhythmbullet.desktop.graphics.ui.components.HealthBar;
|
||||
import zero1hd.rhythmbullet.desktop.graphics.ui.windows.FPSWindow;
|
||||
import zero1hd.rhythmbullet.desktop.graphics.ui.windows.PauseMenu;
|
||||
import zero1hd.rhythmbullet.util.MusicManager;
|
||||
import zero1hd.rhythmbullet.util.ScoreManager;
|
||||
|
||||
public class GameHUD extends Stage {
|
||||
private Screen returnScreen;
|
||||
private Label scoreLabel;
|
||||
private ImageButton pause;
|
||||
private boolean paused;
|
||||
private FPSWindow fpsWindow;
|
||||
private PauseMenu pauseMenu;
|
||||
private HealthBar healthBar;
|
||||
private Pixmap pixmap;
|
||||
private Texture leftStatTexture;
|
||||
private Texture rightStatTexture;
|
||||
private Image leftStatusBar;
|
||||
private Image rightStatusBar;
|
||||
private GamePlayArea gpa;
|
||||
private MusicManager music;
|
||||
private ScoreManager sm;
|
||||
|
||||
private Color original, bass, um;
|
||||
public GameHUD(Skin skin, float maxHealth, GamePlayArea gpa, Screen rs, final RhythmBullet core) {
|
||||
super();
|
||||
scoreLabel = new Label("Score: 0", skin, "default-font", Color.WHITE);
|
||||
scoreLabel.setPosition(10f, Gdx.graphics.getHeight()-scoreLabel.getHeight() - 10f);
|
||||
addActor(scoreLabel);
|
||||
this.sm = gpa.score;
|
||||
this.gpa = gpa;
|
||||
this.returnScreen = rs;
|
||||
|
||||
pause = new ImageButton(skin.getDrawable("pause"),
|
||||
skin.getDrawable("pause-down"));
|
||||
pause.setPosition(Gdx.graphics.getWidth() - pause.getWidth() - 15f,
|
||||
Gdx.graphics.getHeight() - pause.getHeight() - 15f);
|
||||
pause.addListener(new ChangeListener() {
|
||||
@Override
|
||||
public void changed(ChangeEvent event, Actor actor) {
|
||||
setPaused(true);
|
||||
}
|
||||
});
|
||||
addActor(pause);
|
||||
|
||||
fpsWindow = new FPSWindow("FPS", skin);
|
||||
fpsWindow.setPosition(15f, 15f);
|
||||
|
||||
pauseMenu = new PauseMenu(skin);
|
||||
pauseMenu.getResumeButton().addListener(new ChangeListener() {
|
||||
@Override
|
||||
public void changed(ChangeEvent event, Actor actor) {
|
||||
setPaused(false);
|
||||
}
|
||||
});
|
||||
|
||||
pauseMenu.getQuitButton().addListener(new ChangeListener() {
|
||||
@Override
|
||||
public void changed(ChangeEvent event, Actor actor) {
|
||||
core.setScreen(returnScreen);
|
||||
}
|
||||
});
|
||||
pauseMenu.setPosition((Gdx.graphics.getWidth()-pauseMenu.getWidth())/2f, (Gdx.graphics.getHeight()-pauseMenu.getHeight())/2f);
|
||||
|
||||
healthBar = new HealthBar(skin, maxHealth);
|
||||
healthBar.setSize(30f, Gdx.graphics.getHeight()/3);
|
||||
healthBar.setHealth(maxHealth);
|
||||
healthBar.setPosition(Gdx.graphics.getWidth() -(gpa.getViewport().getRightGutterWidth()/4f), (Gdx.graphics.getHeight()-healthBar.getHeight())/2f);
|
||||
addActor(healthBar);
|
||||
healthBar.setPolyjetEntity(gpa.getPolyjetEntity());
|
||||
pixmap = new Pixmap(3, 3, Format.RGBA8888);
|
||||
int excess = 2*gpa.getViewport().getLeftGutterWidth()/pixmap.getWidth();
|
||||
Gdx.app.debug("GHUD", "offset on size: " + excess);
|
||||
pixmap.setColor(Color.WHITE);
|
||||
pixmap.drawLine(0, 0, 0, 2);
|
||||
pixmap.setColor(1f, 1f, 1f, 0.5f);
|
||||
pixmap.drawLine(1, 0, 1, 2);
|
||||
leftStatTexture = new Texture(pixmap);
|
||||
leftStatTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
|
||||
leftStatusBar = new Image(leftStatTexture);
|
||||
leftStatusBar.setSize(gpa.getViewport().getLeftGutterWidth()+excess, getHeight());
|
||||
leftStatusBar.setPosition(0, 0);
|
||||
addActor(leftStatusBar);
|
||||
leftStatusBar.toBack();
|
||||
|
||||
pixmap.dispose();
|
||||
pixmap = new Pixmap(3, 3, Format.RGBA8888);
|
||||
pixmap.setColor(Color.WHITE);
|
||||
pixmap.drawLine(2, 0, 2, 2);
|
||||
pixmap.setColor(1f, 1f, 1f, 0.5f);
|
||||
pixmap.drawLine(1, 0, 1, 2);
|
||||
rightStatTexture = new Texture(pixmap);
|
||||
rightStatTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
|
||||
rightStatusBar = new Image(rightStatTexture);
|
||||
rightStatusBar.setSize(gpa.getViewport().getRightGutterWidth()+excess, getHeight());
|
||||
rightStatusBar.setPosition(getWidth()-gpa.getViewport().getRightGutterWidth()-excess, 0f);
|
||||
addActor(rightStatusBar);
|
||||
rightStatusBar.toBack();
|
||||
pixmap.dispose();
|
||||
|
||||
original = new Color(0.6f, 0.8f, 255f, 0.55f);
|
||||
bass = new Color(0.8f, 0, 1, 0.9f);
|
||||
um = new Color(1f, 0.6f, 0.4f, 0.9f);
|
||||
setStatusColor(original);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void act(float delta) {
|
||||
if (sm.checkDifferent()) {
|
||||
setScore(sm.getScore());
|
||||
}
|
||||
|
||||
if (gpa.getAudioMap() != null && gpa.getAudioMap().getHudType().length > gpa.getAudioMap().getIndex()) {
|
||||
if (gpa.getAudioMap() != null && gpa.getAudioMap().getHudType()[gpa.getAudioMap().getIndex()] != 0) {
|
||||
switch (gpa.getAudioMap().getHudType()[gpa.getAudioMap().getIndex()]) {
|
||||
case 1:
|
||||
changeStatusColor(bass, 0.2f, original);
|
||||
break;
|
||||
case 2:
|
||||
changeStatusColor(um, 0.2f, original);
|
||||
}
|
||||
}
|
||||
}
|
||||
super.act(delta);
|
||||
}
|
||||
|
||||
/**
|
||||
* sets the label for scoring to the designated score
|
||||
* @param score designated score
|
||||
*/
|
||||
public void setScore(int score) {
|
||||
this.scoreLabel.setText("Score: " + score);
|
||||
}
|
||||
|
||||
public void setPaused(boolean paused) {
|
||||
if (paused) {
|
||||
addActor(pauseMenu);
|
||||
if (music != null) {
|
||||
music.pause();
|
||||
}
|
||||
} else {
|
||||
pauseMenu.remove();
|
||||
if (music != null) {
|
||||
music.play();
|
||||
}
|
||||
}
|
||||
this.paused = paused;
|
||||
}
|
||||
|
||||
/**
|
||||
* toggle's between the two states of paused and unpaused
|
||||
* @return whatever the new game state is (true for paused)
|
||||
*/
|
||||
public boolean togglePause() {
|
||||
if (isPaused()) {
|
||||
setPaused(false);
|
||||
} else {
|
||||
setPaused(true);
|
||||
}
|
||||
return isPaused();
|
||||
}
|
||||
|
||||
public boolean isPaused() {
|
||||
return paused;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean keyUp(int keycode) {
|
||||
switch (keycode) {
|
||||
case Keys.F3:
|
||||
if (fpsWindow.hasParent()) {
|
||||
fpsWindow.remove();
|
||||
} else {
|
||||
addActor(fpsWindow);
|
||||
}
|
||||
break;
|
||||
case Keys.ESCAPE:
|
||||
togglePause();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setMusic(MusicManager music) {
|
||||
this.music = music;
|
||||
}
|
||||
|
||||
public void setStatusColor(Color color) {
|
||||
leftStatusBar.setColor(color);
|
||||
rightStatusBar.setColor(color);
|
||||
}
|
||||
|
||||
public void setLeftStatusColor(Color color) {
|
||||
leftStatusBar.setColor(color);
|
||||
}
|
||||
|
||||
public void setRightStatusColor(Color color) {
|
||||
rightStatusBar.setColor(color);
|
||||
}
|
||||
|
||||
public void changeStatusColor(Color color, float duration, Color endColor) {
|
||||
leftStatusBar.clearActions();
|
||||
rightStatusBar.clearActions();
|
||||
|
||||
leftStatusBar.addAction(Actions.sequence(Actions.color(color, duration*0.8f), Actions.color(endColor, duration)));
|
||||
rightStatusBar.addAction(Actions.sequence(Actions.color(color, duration*0.8f), Actions.color(endColor, duration)));
|
||||
}
|
||||
|
||||
public HealthBar getHealthBar() {
|
||||
return healthBar;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
leftStatTexture.dispose();
|
||||
rightStatTexture.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user