background now full window size; sensitivity slider no longer attached to analyzer

This commit is contained in:
Harrison Deng 2017-07-23 00:11:28 -05:00
parent 8af157567f
commit ec234af091
19 changed files with 63 additions and 95 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 745 KiB

After

Width:  |  Height:  |  Size: 616 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 954 KiB

After

Width:  |  Height:  |  Size: 799 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 895 KiB

After

Width:  |  Height:  |  Size: 754 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 MiB

After

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 MiB

After

Width:  |  Height:  |  Size: 1.4 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 MiB

After

Width:  |  Height:  |  Size: 1.6 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.0 MiB

After

Width:  |  Height:  |  Size: 3.5 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 399 KiB

After

Width:  |  Height:  |  Size: 366 KiB

View File

@ -318,20 +318,4 @@ large-pane
split: 4, 4, 13, 13 split: 4, 4, 13, 13
orig: 9, 27 orig: 9, 27
offset: 0, 0 offset: 0, 0
index: -1
grad-dark-light
rotate: false
xy: 26, 7
size: 3, 3
split: 0, 0, 0, 0
orig: 3, 3
offset: 0, 0
index: -1
grad-light-dark
rotate: false
xy: 30, 7
size: 3, 3
split: 0, 0, 0, 0
orig: 3, 3
offset: 0, 0
index: -1 index: -1

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

View File

@ -25,12 +25,12 @@ public class RhythmMapAlgorithm implements Runnable {
private float avgSPB; private float avgSPB;
private float umMax, bassMax; private float umMax, bassMax;
private float speedMod, healthMod; private float speedMod, healthMod, difficultyMod;
private float windowPerSecond; private float windowPerSecond;
private volatile int progress; private volatile int progress;
public RhythmMapAlgorithm(AudioAnalyzer analyzer, float speedMod, float healthMod) { public RhythmMapAlgorithm(AudioAnalyzer analyzer, float speedMod, float healthMod, float difficultyMod) {
sender = new MiniSender(); sender = new MiniSender();
bassPeaks = analyzer.getBassPeaks(); bassPeaks = analyzer.getBassPeaks();
@ -43,6 +43,7 @@ public class RhythmMapAlgorithm implements Runnable {
this.speedMod = speedMod; this.speedMod = speedMod;
this.healthMod = healthMod; this.healthMod = healthMod;
this.difficultyMod = difficultyMod;
umMax = analyzer.getUMMaxValue(); umMax = analyzer.getUMMaxValue();
avgUM = analyzer.getUmAvg(); avgUM = analyzer.getUmAvg();
@ -61,7 +62,7 @@ public class RhythmMapAlgorithm implements Runnable {
float warningTime = map.goBack((int) (windowPerSecond*1.5f))/windowPerSecond; float warningTime = map.goBack((int) (windowPerSecond*1.5f))/windowPerSecond;
float endRadius = (bassPeaks.get(index)/bassMax)*(Main.GAME_AREA_HEIGHT/4f); float endRadius = (bassPeaks.get(index)/bassMax)*(Main.GAME_AREA_HEIGHT/4f);
map.addToMap(Entities.VOID_CIRCLE, map.addToMap(Entities.VOID_CIRCLE,
endRadius, endRadius,
rand.nextFloat()*Main.GAME_AREA_WIDTH, rand.nextFloat()*Main.GAME_AREA_WIDTH,
rand.nextFloat()*Main.GAME_AREA_HEIGHT, rand.nextFloat()*Main.GAME_AREA_HEIGHT,
endRadius/(avgSPB*0.7f), endRadius/(avgSPB*0.7f),

View File

@ -4,6 +4,9 @@ import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.InputMultiplexer; import com.badlogic.gdx.InputMultiplexer;
import com.badlogic.gdx.ScreenAdapter; import com.badlogic.gdx.ScreenAdapter;
import com.badlogic.gdx.graphics.GL20; import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.glutils.ShaderProgram;
import com.badlogic.gdx.scenes.scene2d.Actor; import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.ui.ImageButton; import com.badlogic.gdx.scenes.scene2d.ui.ImageButton;
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener; import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
@ -24,6 +27,10 @@ public class GameScreen extends ScreenAdapter {
private AudioData music; private AudioData music;
SpriteBatch bgBatch;
private ShaderProgram bgShader;
private Texture background;
public GameScreen(Main polyJet, GamePlayMap gpm) { public GameScreen(Main polyJet, GamePlayMap gpm) {
core = polyJet; core = polyJet;
@ -43,12 +50,13 @@ public class GameScreen extends ScreenAdapter {
gameArea = new GamePlayArea(polyJet.getAssetManager(), core.getPrefs()); gameArea = new GamePlayArea(polyJet.getAssetManager(), core.getPrefs());
gameArea.setAudioMap(gpm); gameArea.setAudioMap(gpm);
gameHUD = new GameHUD(polyJet.getDefaultSkin(), gpm.getPlayableClip(), gameArea.getMaxHealth(), gameArea.getViewport().getLeftGutterWidth(), gameArea.getViewport().getRightGutterWidth()); gameHUD = new GameHUD(polyJet.getDefaultSkin(), gpm.getPlayableClip(), gameArea.getMaxHealth());
inputs = new InputMultiplexer(); inputs = new InputMultiplexer();
inputs.addProcessor(gameHUD); inputs.addProcessor(gameHUD);
inputs.addProcessor(gameArea); inputs.addProcessor(gameArea);
background = core.getAssetManager().get("star_bg.png");
} }
@Override @Override
@ -59,6 +67,24 @@ public class GameScreen extends ScreenAdapter {
if (!gameHUD.isPaused()) { if (!gameHUD.isPaused()) {
music.getPlaybackMusic().play(); music.getPlaybackMusic().play();
} }
if (core.getPrefs().getBoolean("bg shader")) {
Gdx.app.debug("Shader", "using background shader");
bgShader = new ShaderProgram(Gdx.files.internal("shaders/bg.vsh"), Gdx.files.internal("shaders/bg.fsh"));
if (!bgShader.isCompiled()) {
System.err.println(bgShader.getLog());
System.exit(0);
}
if (bgShader.getLog().length()!=0) {
System.out.println(bgShader.getLog());
}
bgBatch = new SpriteBatch(2, bgShader);
} else {
bgBatch = new SpriteBatch(2);
}
super.show(); super.show();
} }
@ -66,6 +92,17 @@ public class GameScreen extends ScreenAdapter {
public void render(float delta) { public void render(float delta) {
Gdx.gl.glClearColor(0f, 0f, 0f, 0f); Gdx.gl.glClearColor(0f, 0f, 0f, 0f);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);
bgBatch.begin();
if (bgShader != null) {
bgBatch.setShader(bgShader);
bgShader.setUniformf("resolution", Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
if (music != null) {
bgShader.setUniformf("time", music.getPlaybackMusic().getPosition());
}
}
bgBatch.draw(background, 0f, 0f, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
bgBatch.end();
gameArea.getViewport().apply(); gameArea.getViewport().apply();
gameArea.draw(); gameArea.draw();

View File

@ -8,18 +8,19 @@ import com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup;
public class HealthBar extends WidgetGroup { public class HealthBar extends WidgetGroup {
Image empty; Image empty;
Image filled; Image filler;
int health; int health;
int maxHealth; int maxHealth;
public HealthBar(Skin skin, int maxHealth) { public HealthBar(Skin skin, int maxHealth) {
super(); super();
filler = new Image(skin.getPatch("bar-fill"));
addActor(filler);
empty = new Image(skin.getPatch("bar-empty")); empty = new Image(skin.getPatch("bar-empty"));
filled = new Image(skin.getPatch("bar-fill"));
addActor(filled);
addActor(empty); addActor(empty);
empty.toFront();
this.maxHealth = maxHealth; this.maxHealth = maxHealth;
} }
@ -27,20 +28,20 @@ public class HealthBar extends WidgetGroup {
public void setHealth(int health) { public void setHealth(int health) {
this.health = health; this.health = health;
filled.addAction(Actions.sizeTo(getWidth(), MathUtils.round((health/maxHealth)*getHeight()), 0.1f));; filler.addAction(Actions.sizeTo(getWidth(), MathUtils.round((health/maxHealth)*getHeight()), 0.1f));;
} }
@Override @Override
public void setSize(float width, float height) { public void setSize(float width, float height) {
empty.setSize(width, height); empty.setSize(width, height);
filled.setSize(width, height); filler.setSize(width, height);
super.setSize(width, height); super.setSize(width, height);
} }
@Override @Override
public void setWidth(float width) { public void setWidth(float width) {
empty.setWidth(width); empty.setWidth(width);
filled.setWidth(width); filler.setWidth(width);
super.setWidth(width); super.setWidth(width);
} }

View File

@ -4,6 +4,7 @@ import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.math.Interpolation; import com.badlogic.gdx.math.Interpolation;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.scenes.scene2d.Actor; import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.actions.Actions; import com.badlogic.gdx.scenes.scene2d.actions.Actions;
import com.badlogic.gdx.scenes.scene2d.ui.Image; import com.badlogic.gdx.scenes.scene2d.ui.Image;
@ -77,13 +78,13 @@ public class AnalyzePage extends Page implements MiniListener {
difficultyTable.row(); difficultyTable.row();
sensitivityRating = new Slider(-5f, 5f, 1f, false, skin); sensitivityRating = new Slider(0f, 1f, 0.01f, false, skin);
sensitivityRating.setValue(0f); sensitivityRating.setValue(0f);
sensitivityRating.addListener(new ChangeListener() { sensitivityRating.addListener(new ChangeListener() {
@Override @Override
public void changed(ChangeEvent event, Actor actor) { public void changed(ChangeEvent event, Actor actor) {
sensitivityRatingTitle.setText("Base Difficulty: " + sensitivityRating.getValue()); sensitivityRatingTitle.setText("Base Difficulty: " + MathUtils.round(sensitivityRating.getValue()*100) +"%");
} }
}); });
@ -260,7 +261,7 @@ 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()); mapGenAlgorithm = new RhythmMapAlgorithm(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();
@ -298,7 +299,7 @@ public class AnalyzePage extends Page implements MiniListener {
private void finalizeData() { private void finalizeData() {
Gdx.app.debug("analyze", "confirmed data finalization."); Gdx.app.debug("analyze", "confirmed data finalization.");
audioAnalyzer.runThresholdCleaning(sensitivityRating.getValue()); audioAnalyzer.runThresholdCleaning();
info[3].setText("finalizing data..."); info[3].setText("finalizing data...");
info[3].addAction(Actions.color(Color.BLACK, 0.75f)); info[3].addAction(Actions.color(Color.BLACK, 0.75f));
} }

View File

@ -243,11 +243,11 @@ public class CreativeHUD extends Stage implements MiniListener {
analyzer.startAnalyticalThread(musicSelector.getSelectedMusic()); analyzer.startAnalyticalThread(musicSelector.getSelectedMusic());
break; break;
case SPECTRAL_FLUX_DONE: case SPECTRAL_FLUX_DONE:
analyzer.runThresholdCleaning(diffWindow.getSensitivityVal()); analyzer.runThresholdCleaning();
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()); mapGen = new RhythmMapAlgorithm(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

@ -4,7 +4,6 @@ import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input.Keys; import com.badlogic.gdx.Input.Keys;
import com.badlogic.gdx.audio.Music; import com.badlogic.gdx.audio.Music;
import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.NinePatch;
import com.badlogic.gdx.scenes.scene2d.Actor; import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.Stage; import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.ImageButton; import com.badlogic.gdx.scenes.scene2d.ui.ImageButton;
@ -26,18 +25,10 @@ public class GameHUD extends Stage {
private Music music; private Music music;
private int leftLetterBox, rightLetterBox; public GameHUD(Skin skin, Music music, int maxHealth) {
private NinePatch leftPatch, rightPatch;
public GameHUD(Skin skin, Music music, int maxHealth, int leftLetterBox, int rightLetterBox) {
super(); super();
this.music = music; this.music = music;
this.leftLetterBox = leftLetterBox;
this.rightLetterBox = rightLetterBox;
leftPatch = skin.getPatch("grad-dark-light");
rightPatch = skin.getPatch("grad-light-dark");
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);
@ -136,12 +127,4 @@ public class GameHUD extends Stage {
return false; return false;
} }
@Override
public void draw() {
getBatch().begin();
leftPatch.draw(getBatch(), 0, 0, leftLetterBox, Gdx.graphics.getHeight());
rightPatch.draw(getBatch(), Gdx.graphics.getWidth()-rightLetterBox, 0, rightLetterBox, Gdx.graphics.getHeight());
getBatch().end();
super.draw();
}
} }

View File

@ -5,7 +5,6 @@ import com.badlogic.gdx.Preferences;
import com.badlogic.gdx.assets.AssetManager; import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.graphics.GL20; import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Pixmap.Format; import com.badlogic.gdx.graphics.Pixmap.Format;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.TextureRegion; import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.graphics.glutils.FrameBuffer; import com.badlogic.gdx.graphics.glutils.FrameBuffer;
import com.badlogic.gdx.graphics.glutils.ShaderProgram; import com.badlogic.gdx.graphics.glutils.ShaderProgram;
@ -42,12 +41,9 @@ public class GamePlayArea extends Stage {
TextureRegion fboRegion; TextureRegion fboRegion;
private int fboSize; private int fboSize;
private ShaderProgram bgShader;
private Texture background;
public GamePlayArea(AssetManager assetManager, Preferences prefs) { public GamePlayArea(AssetManager assetManager, Preferences prefs) {
super(new FitViewport(Main.GAME_AREA_WIDTH, Main.GAME_AREA_HEIGHT)); super(new FitViewport(Main.GAME_AREA_WIDTH, Main.GAME_AREA_HEIGHT));
Gdx.app.debug("Game Area", "new area created"); Gdx.app.debug("Game Area", "new area created");
background = assetManager.get("star_bg.png");
polyjet = new PolyJetEntity(assetManager, 25f, 25f, "standard"); polyjet = new PolyJetEntity(assetManager, 25f, 25f, "standard");
ec = new EntityController(assetManager, prefs); ec = new EntityController(assetManager, prefs);
@ -90,44 +86,12 @@ public class GamePlayArea extends Stage {
} }
if (prefs.getBoolean("bg shader")) {
Gdx.app.debug("Shader", "using background shader");
bgShader = new ShaderProgram(Gdx.files.internal("shaders/bg.vsh"), Gdx.files.internal("shaders/bg.fsh"));
if (!bgShader.isCompiled()) {
System.err.println(bgShader.getLog());
System.exit(0);
}
if (bgShader.getLog().length()!=0) {
System.out.println(bgShader.getLog());
}
} else {
//TODO prepare background rendering without shader
}
ShaderProgram.pedantic = false; ShaderProgram.pedantic = false;
} }
@Override @Override
public void draw() { public void draw() {
//TODO batch draw background //TODO batch draw background
getBatch().begin();
if (bgShader != null) {
getBatch().setShader(bgShader);
bgShader.setUniformf("resolution", background.getWidth(), background.getHeight());
if (audioMap != null) {
bgShader.setUniformf("time", audioMap.getPlayableClip().getPosition());
}
}
getBatch().draw(background, 0f, 0f, Main.GAME_AREA_WIDTH, Main.GAME_AREA_HEIGHT);
getBatch().end();
getBatch().setShader(null);
if (glowShader != null) { if (glowShader != null) {
blurTarget.begin(); blurTarget.begin();
@ -272,9 +236,6 @@ public class GamePlayArea extends Stage {
blurTarget.dispose(); blurTarget.dispose();
glowShader.dispose(); glowShader.dispose();
} }
if (bgShader != null) {
bgShader.dispose();
}
super.dispose(); super.dispose();
} }

View File

@ -17,7 +17,7 @@ public class DifficultyWindow extends Window {
public DifficultyWindow(Skin skin) { public DifficultyWindow(Skin skin) {
super("Difficulty Adjuster", skin, "tinted"); super("Difficulty Adjuster", skin, "tinted");
sensitivityRating = new Slider(-5f, 5f, 1f, false, skin); sensitivityRating = new Slider(0f, 100f, 1f, false, skin);
sensitivityRating.setValue(0f); sensitivityRating.setValue(0f);
sensitivityRating.addListener(new ChangeListener() { sensitivityRating.addListener(new ChangeListener() {

View File

@ -11,9 +11,9 @@ public class PauseMenu extends Window {
public PauseMenu(Skin skin) { public PauseMenu(Skin skin) {
super("Paused", skin, "tinted"); super("Paused", skin, "tinted");
defaults().pad(35f); defaults().pad(25f);
label = new Label("Game is paused.", skin); label = new Label("Game is paused.", skin);
add(label).spaceBottom(20f); add(label).spaceBottom(15f);
row(); row();
resumeButton = new TextButton("Resume", skin); resumeButton = new TextButton("Resume", skin);