began working on hit detection system

This commit is contained in:
Harrison Deng 2017-05-29 14:46:48 -05:00
parent d6b6829023
commit 279658daa0
7 changed files with 81 additions and 59 deletions

View File

@ -41,7 +41,6 @@ project(":desktop") {
compile "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion" compile "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop" compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
compile "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop" compile "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop"
compile "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-desktop"
} }
} }
@ -64,13 +63,6 @@ project(":android") {
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-arm64-v8a" natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86" natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86_64" natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86_64"
compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86_64"
compile "com.badlogicgames.box2dlights:box2dlights:$box2DLightsVersion"
} }
} }
@ -85,8 +77,6 @@ project(":core") {
compile "com.badlogicgames.gdx:gdx:$gdxVersion" compile "com.badlogicgames.gdx:gdx:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion" compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
compile "com.badlogicgames.box2dlights:box2dlights:$box2DLightsVersion"
compile "org.apache.commons:commons-math3:3.2" compile "org.apache.commons:commons-math3:3.2"

View File

@ -128,7 +128,7 @@ public class AudioAnalyzer {
shrinkData(); shrinkData();
containsData = true; containsData = true;
Gdx.app.debug("Audio Analyzer", "USING SEED: " + PUID);
sender.send(MiniEvents.SPECTRAL_FLUX_DONE); sender.send(MiniEvents.SPECTRAL_FLUX_DONE);
} }
} }
@ -138,7 +138,6 @@ public class AudioAnalyzer {
@Override @Override
public void run() { public void run() {
Gdx.app.debug("Audio Analyzer", "USING SEED: " + PUID);
//threshold calculation //threshold calculation
for (int i = 0; i < UMSpectralFlux.size && work; i++) { for (int i = 0; i < UMSpectralFlux.size && work; i++) {

View File

@ -1,7 +1,7 @@
package zero1hd.polyjet.entity; package zero1hd.polyjet.entity;
public enum Entities { public enum Entities {
Bar_Beat, Void_Circle; BAR_BEAT, VOID_CIRCLE, SHARDS;
public float x; public float x;
public float y; public float y;

View File

@ -0,0 +1,52 @@
package zero1hd.polyjet.entity;
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.scenes.scene2d.Actor;
public class Entity extends Actor {
private Rectangle box;
public Entity() {
box = new Rectangle();
}
@Override
public void setHeight(float height) {
box.height = height;
super.setHeight(height);
}
@Override
public void setWidth(float width) {
box.width = width;
super.setWidth(width);
}
@Override
public void setSize(float width, float height) {
box.setSize(width, height);
super.setSize(width, height);
}
@Override
public void setX(float x) {
box.setX(x);
super.setX(x);
}
@Override
public void setY(float y) {
box.setY(y);
super.setY(y);
}
@Override
public void setPosition(float x, float y) {
box.setPosition(x, y);
super.setPosition(x, y);
}
public Rectangle getBox() {
return box;
}
}

View File

@ -8,7 +8,7 @@ import com.badlogic.gdx.scenes.scene2d.actions.Actions;
import zero1hd.polyjet.Polyjet; import zero1hd.polyjet.Polyjet;
public class PolyJetEntity extends Actor { public class PolyJetEntity extends Entity {
private ParticleEffect thrust; private ParticleEffect thrust;
private Texture polyjet; private Texture polyjet;
@ -16,8 +16,8 @@ public class PolyJetEntity extends Actor {
public boolean moveLeft, moveRight, moveUp, moveDown, teleporting; public boolean moveLeft, moveRight, moveUp, moveDown, teleporting;
private int rate; private float rate;
public PolyJetEntity(Polyjet core, int rate, String jet) { public PolyJetEntity(Polyjet core, float rate, String jet) {
this.rate = rate; this.rate = rate;
setSize(1.5f, 1.5f); setSize(1.5f, 1.5f);
@ -63,6 +63,5 @@ public class PolyJetEntity extends Actor {
thrust.draw(batch); thrust.draw(batch);
batch.draw(polyjet, getX(), getY(), getWidth(), getHeight()); batch.draw(polyjet, getX(), getY(), getWidth(), getHeight());
super.draw(batch, parentAlpha); super.draw(batch, parentAlpha);
} }
} }

View File

@ -1,8 +1,5 @@
package zero1hd.polyjet.ui.stages; package zero1hd.polyjet.ui.stages;
import com.badlogic.gdx.Gdx;
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;
import com.badlogic.gdx.scenes.scene2d.Stage; import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.utils.viewport.FitViewport; import com.badlogic.gdx.utils.viewport.FitViewport;
@ -14,10 +11,6 @@ import zero1hd.polyjet.entity.PolyJetEntity;
public class GamePlayArea extends Stage { public class GamePlayArea extends Stage {
public PolyJetEntity polyJet; public PolyJetEntity polyJet;
float timeCounter;
//Required to know when to spawn entities on screen.
int audioIndex;
private float health = 50; private float health = 50;
private float maxHealth = 100; private float maxHealth = 100;
@ -28,20 +21,7 @@ public class GamePlayArea extends Stage {
public GamePlayArea(Polyjet core) { public GamePlayArea(Polyjet core) {
super(new FitViewport(Polyjet.GAME_AREA_WIDTH, Polyjet.GAME_AREA_HEIGHT)); super(new FitViewport(Polyjet.GAME_AREA_WIDTH, Polyjet.GAME_AREA_HEIGHT));
Pixmap basicLaser = new Pixmap(2, 32, Format.RGBA8888); polyJet = new PolyJetEntity(core, 48f, "standard");
basicLaser.setColor(0f, 0.4f, 1f, 1f);
basicLaser.fill();
basicLaserTexture = new Texture(basicLaser);
basicLaser.dispose();
getCamera().far = 32f;
getCamera().near = 0f;
Gdx.app.debug("Camera position (x,y,z)", getCamera().position.x + " " + getCamera().position.y + " " + getCamera().position.z);
getCamera().update();
polyJet = new PolyJetEntity(core, 54, "standard");
addActor(polyJet); addActor(polyJet);
} }
@ -51,8 +31,6 @@ public class GamePlayArea extends Stage {
} }
@Override @Override
public void act(float delta) { public void act(float delta) {
timeCounter+=delta;
health -= 2*delta; health -= 2*delta;
if (health <= 0) { if (health <= 0) {
@ -81,9 +59,6 @@ public class GamePlayArea extends Stage {
super.act(delta); super.act(delta);
} }
public void setAudioIndex(int audioIndex) {
this.audioIndex = audioIndex;
}
public void addScore (int score) { public void addScore (int score) {
this.score += score; this.score += score;
health += score; health += score;

View File

@ -41,13 +41,12 @@ public class BeatViewer extends Window {
final Image bassBarFill = new Image(core.getDefaultSkin().getPatch("bar-fill")) { final Image bassBarFill = new Image(core.getDefaultSkin().getPatch("bar-fill")) {
@Override @Override
public void act(float delta) { public void act(float delta) {
try {
if (music != null && data.getBassPeaks().get(songIndex) != 0) { if (music != null && data.getBassPeaks().get(songIndex) != 0) {
clearActions(); clearActions();
try {
addAction(Actions.sequence(Actions.sizeTo(getWidth(), (data.getBassPeaks().get(songIndex)/data.getBassMaxValue())*bgBassBar.getHeight()), Actions.sizeTo(getWidth(), 0, 0.3f))); addAction(Actions.sequence(Actions.sizeTo(getWidth(), (data.getBassPeaks().get(songIndex)/data.getBassMaxValue())*bgBassBar.getHeight()), Actions.sizeTo(getWidth(), 0, 0.3f)));
} catch (IndexOutOfBoundsException e) {
} }
} catch (IndexOutOfBoundsException e) {
} }
super.act(delta); super.act(delta);
} }
@ -64,14 +63,14 @@ public class BeatViewer extends Window {
Image UMBarFill = new Image(core.getDefaultSkin().getPatch("bar-fill")) { Image UMBarFill = new Image(core.getDefaultSkin().getPatch("bar-fill")) {
@Override @Override
public void act(float delta) { public void act(float delta) {
try {
if (music != null && data.getUMPeaks().get(songIndex) != 0) { if (music != null && data.getUMPeaks().get(songIndex) != 0) {
clearActions(); clearActions();
try {
addAction(Actions.sequence(Actions.sizeTo(getWidth(), (data.getUMPeaks().get(songIndex)/data.getUMMaxValue())*bgUMBar.getHeight()), Actions.sizeTo(getWidth(), 0f, 0.3f))); addAction(Actions.sequence(Actions.sizeTo(getWidth(), (data.getUMPeaks().get(songIndex)/data.getUMMaxValue())*bgUMBar.getHeight()), Actions.sizeTo(getWidth(), 0f, 0.3f)));
}
} catch (IndexOutOfBoundsException e) { } catch (IndexOutOfBoundsException e) {
} }
}
super.act(delta); super.act(delta);
} }
}; };
@ -86,10 +85,14 @@ public class BeatViewer extends Window {
Image bassIndicator = new Image(lightOn) { Image bassIndicator = new Image(lightOn) {
@Override @Override
public void act(float delta) { public void act(float delta) {
try {
if (music != null && data.getBassPeaks().get(songIndex) != 0) { if (music != null && data.getBassPeaks().get(songIndex) != 0) {
clearActions(); clearActions();
addAction(Actions.sequence(Actions.alpha(1f), Actions.fadeOut(0.15f))); addAction(Actions.sequence(Actions.alpha(1f), Actions.fadeOut(0.15f)));
} }
} catch (IndexOutOfBoundsException e) {
// TODO: handle exception
}
super.act(delta); super.act(delta);
} }
}; };
@ -101,10 +104,14 @@ public class BeatViewer extends Window {
Image UMIndicator = new Image(lightOn) { Image UMIndicator = new Image(lightOn) {
@Override @Override
public void act(float delta) { public void act(float delta) {
try {
if (music != null && data.getUMPeaks().get(songIndex) != 0) { if (music != null && data.getUMPeaks().get(songIndex) != 0) {
clearActions(); clearActions();
addAction(Actions.sequence(Actions.alpha(1f), Actions.fadeOut(0.15f))); addAction(Actions.sequence(Actions.alpha(1f), Actions.fadeOut(0.15f)));
} }
} catch (IndexOutOfBoundsException e) {
}
super.act(delta); super.act(delta);
} }
}; };