progress on debug screen and minor error resolved with map gen

This commit is contained in:
Harrison Deng 2017-07-11 23:33:25 -05:00
parent 27757f0024
commit 2cd752f25c
14 changed files with 66 additions and 19 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 248 B

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 317 B

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 294 B

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 487 B

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 503 B

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 608 B

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 167 B

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@ -8,8 +8,12 @@ import com.badlogic.gdx.utils.FloatArray;
import zero1hd.polyjet.Polyjet;
import zero1hd.polyjet.audio.AudioAnalyzer;
import zero1hd.polyjet.entity.Entities;
import zero1hd.polyjet.util.MiniEvents;
import zero1hd.polyjet.util.MiniSender;
public class RhythmMapAlgorithm implements Runnable {
private MiniSender sender;
private FloatArray bassPeaks;
private FloatArray UMPeaks;
private FloatArray overlappedPeaks;
@ -23,6 +27,8 @@ public class RhythmMapAlgorithm implements Runnable {
private volatile int progress;
public RhythmMapAlgorithm(AudioAnalyzer analyzer, float speedMod, float healthMod) {
sender = new MiniSender();
bassPeaks = analyzer.getBassPeaks();
UMPeaks = analyzer.getUMPeaks();
overlappedPeaks = analyzer.getOverlappedPeaks();
@ -41,7 +47,7 @@ public class RhythmMapAlgorithm implements Runnable {
for (int index = 0; index < bassPeaks.size; index++) {
if (bassPeaks.get(index) != 0 || UMPeaks.get(index) != 0) {
int warningTime = (int) ((3/speedMod)*windowPerSecond);
if (overlappedPeaks.get(index + warningTime) != 0) {
if ((index+warningTime <= bassPeaks.size) && overlappedPeaks.get(index + warningTime) != 0) {
//TODO basic void circle spawning
float endRadius = overlappedPeaks.get(index+3)*Polyjet.GAME_AREA_WIDTH;
@ -73,6 +79,8 @@ public class RhythmMapAlgorithm implements Runnable {
}
progress = (int) (100f*index/bassPeaks.size);
sender.send(MiniEvents.MAPGEN_ITERATED);
}
map.endBuild();
}
@ -84,4 +92,8 @@ public class RhythmMapAlgorithm implements Runnable {
public synchronized int getProgress() {
return progress;
}
public MiniSender getSender() {
return sender;
}
}

View File

@ -30,7 +30,7 @@ public class Flake extends Actor implements Poolable, Entity {
public void init(float x, float y, float rate, float fuse, float angle, Shard... shards) {
this.shards = shards;
setSize(1f, 1f);
setSize(3f, 3f);
this.rate = rate;
this.timer = fuse;
hitbox.setSize(getWidth(), getHeight());

View File

@ -71,7 +71,7 @@ public class Shard extends Actor implements Entity, Poolable {
@Override
public void draw(Batch batch, float parentAlpha) {
sprite.setCenter(getX()+center.x, getY()+center.y);
sprite.setColor((float)hp/(float)maxHp, 0f, 0f, 1f);
sprite.setColor(1.3f-((float)hp/(float)maxHp), 1.3f-((float)hp/(float)maxHp), 1.3f-((float)hp/(float)maxHp), 0.75f);
sprite.draw(batch);
batch.setColor(Color.WHITE);
super.draw(batch, parentAlpha);

View File

@ -230,11 +230,18 @@ public class AnalyzePage extends Page implements MiniListener {
info[3].setText("data cleaning done.");
info[4].addAction(Actions.color(Color.BLACK, 0.75f));
mapGenAlgorithm = new RhythmMapAlgorithm(audioAnalyzer, speedModifier.getValue(), healthModifier.getValue());
mapGenAlgorithm.getSender().addListener(this);
mapGenThread = new Thread(mapGenAlgorithm);
mapGenThread.start();
startTime = System.currentTimeMillis();
break;
case MAPGEN_ITERATED:
info[4].setText("Generating map: " + mapGenAlgorithm.getProgress());
break;
case MAP_GENERATED:
endTime = System.currentTimeMillis();
info[5].setText("Done. Generation time: " + ((endTime - startTime)/1000f) + "s");
info[5].addAction(Actions.color(Color.BLACK, 0.75f));
default:
break;
}
@ -246,8 +253,4 @@ public class AnalyzePage extends Page implements MiniListener {
info[3].setText("finalizing data...");
info[3].addAction(Actions.color(Color.BLACK, 0.75f));
}
private void generateMap() {
}
}

View File

@ -15,8 +15,10 @@ import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
import zero1hd.polyjet.Polyjet;
import zero1hd.polyjet.audio.AudioAnalyzer;
import zero1hd.polyjet.audio.map.RhythmMapAlgorithm;
import zero1hd.polyjet.screens.MainMenu;
import zero1hd.polyjet.ui.windows.BeatViewer;
import zero1hd.polyjet.ui.windows.DifficultyWindow;
import zero1hd.polyjet.ui.windows.FPSWindow;
import zero1hd.polyjet.ui.windows.GraphWindow;
import zero1hd.polyjet.ui.windows.MusicController;
@ -34,8 +36,10 @@ public class CreativeStage extends Stage implements MiniListener {
GraphWindow graphViewer;
VolumeWindow volumeWindow;
SpawnerWindow spawnerWindow;
DifficultyWindow diffWindow;
AudioAnalyzer analyzer;
RhythmMapAlgorithm mapGen;
Window toolbox;
public CreativeStage(final Polyjet core, final MainMenu mainMenu, final GamePlayArea gpa) {
@ -48,6 +52,7 @@ public class CreativeStage extends Stage implements MiniListener {
graphViewer = new GraphWindow("Peak Values", core.getDefaultSkin());
volumeWindow = new VolumeWindow("Volume adjustments", core.getDefaultSkin(), core.getPrefs());
spawnerWindow = new SpawnerWindow("Spawn Tool", core.getDefaultSkin(), gpa.ec, gpa);
diffWindow = new DifficultyWindow(core.getDefaultSkin());
//Back button
TextButton backButton = new TextButton("Back", core.getDefaultSkin());
@ -171,7 +176,21 @@ public class CreativeStage extends Stage implements MiniListener {
}
});
toolboxToolSet.add(spawnToolCheckBox);
toolboxToolSet.row();
final CheckBox diffAdjusterCheckBox = new CheckBox(" Difficulty", core.getDefaultSkin());
diffAdjusterCheckBox.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
if (diffAdjusterCheckBox.isChecked()) {
addActor(diffWindow);
} else {
diffWindow.remove();
}
}
});
toolboxToolSet.add(diffAdjusterCheckBox);
ScrollPane scroller = new ScrollPane(toolboxToolSet, core.getDefaultSkin());
toolbox.add(scroller).expand().fill();
@ -225,16 +244,19 @@ public class CreativeStage extends Stage implements MiniListener {
analyzer.startAnalyticalThread(musicSelector.getSelectedMusic());
break;
case SPECTRAL_FLUX_DONE:
analyzer.runThresholdCleaning();
analyzer.runThresholdCleaning(diffWindow.getSensitivityVal());
break;
case MUSIC_DATA_CLEANED:
mapGen = new RhythmMapAlgorithm(analyzer, diffWindow.getSpeedModifier(), diffWindow.getHealthModifier());
Thread mapGenThread = new Thread(mapGen);
mapGenThread.start();
break;
case MAP_GENERATED:
musicPlayBackControls.setAudiofile(musicSelector.getSelectedMusic());
volumeWindow.setMusic(musicPlayBackControls.getAudiofile());
beatViewer.setMusic(musicPlayBackControls.getAudiofile(), analyzer);
graphViewer.setData(analyzer.getBassPeaks(), analyzer.getUMPeaks(), musicPlayBackControls.getAudiofile());
break;
case MAP_GENERATED:
break;
default:
break;
}

View File

@ -15,8 +15,8 @@ public class DifficultyWindow extends Window {
private Slider healthModifier;
private Label healthModifierTitle;
public DifficultyWindow(String title, Skin skin) {
super(title, skin, "tinted");
public DifficultyWindow(Skin skin) {
super("Difficulty Adjuster", skin, "tinted");
sensitivityRating = new Slider(-5f, 5f, 1f, false, skin);
sensitivityRating.setValue(0f);
sensitivityRating.addListener(new ChangeListener() {
@ -29,8 +29,7 @@ public class DifficultyWindow extends Window {
sensitivityRatingTitle = new Label("Base Difficulty: " + sensitivityRating.getValue(), skin, "sub-font", skin.getColor("default"));
add(sensitivityRatingTitle);
row();
add(sensitivityRating).fillX();
add(sensitivityRating);
row();
@ -44,8 +43,7 @@ public class DifficultyWindow extends Window {
});
speedModifierTitle = new Label("Speed Modifier: " + speedModifier.getValue(), skin, "sub-font", skin.getColor("default"));
add(speedModifierTitle);
row();
add(speedModifier).fillX();
add(speedModifier);
row();
@ -60,8 +58,20 @@ public class DifficultyWindow extends Window {
});
healthModifierTitle = new Label("Health modifier: " + healthModifier.getValue(), skin, "sub-font", skin.getColor("default"));
add(healthModifierTitle);
row();
add(healthModifier).fillX().spaceBottom(15f);
add(healthModifier);
pack();
}
public float getSensitivityVal() {
return sensitivityRating.getValue();
}
public float getSpeedModifier() {
return speedModifier.getValue();
}
public float getHealthModifier() {
return healthModifier.getValue();
}
}