worked on entity gen as well as began adding average bps calc

This commit is contained in:
2017-06-23 22:24:42 -05:00
parent 329ff21c75
commit d815a3c053
3 changed files with 70 additions and 26 deletions

View File

@@ -20,6 +20,7 @@ public class GamePlayMap {
public GamePlayMap(AudioData audioData) {
playableClip = audioData.getPlaybackMusic();
playTime = audioData.getDuration();
spawnList = new Array<>();
}
/**
@@ -41,14 +42,14 @@ public class GamePlayMap {
/**
* call this when beginning to build map
*/
public void start() {
public void beginBuild() {
building = true;
}
/**
* call this when finishing building map
*/
public void end() {
public void endBuild() {
building = false;
}

View File

@@ -2,35 +2,59 @@ package zero1hd.polyjet.audio.map;
import org.apache.commons.math3.random.MersenneTwister;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.utils.FloatArray;
import zero1hd.polyjet.Polyjet;
import zero1hd.polyjet.audio.AudioAnalyzer;
import zero1hd.polyjet.entity.Entities;
public class RhythmMapAlgorithm implements Runnable {
private FloatArray bassPeaks;
private FloatArray UMPeaks;
private FloatArray overlappedPeaks;
private MersenneTwister rand;
private GamePlayMap map;
private float avgBPS;
public RhythmMapAlgorithm(AudioAnalyzer analyzer) {
bassPeaks = analyzer.getBassPeaks();
UMPeaks = analyzer.getUMPeaks();
overlappedPeaks = analyzer.getOverlappedPeaks();
map = new GamePlayMap(analyzer.getAudioData());
rand = new MersenneTwister(analyzer.getPUID());
avgBPS = analyzer.getAvgBPS();
}
@Override
public void run() {
map.beginBuild();
for (int index = 0; index < bassPeaks.size; index++) {
if (overlappedPeaks.get(index) != 0) {
//TODO basic void spawning
} else if (bassPeaks.get(index) != 0) {
//TODO basic bar spawning
} else {
if (UMPeaks.get(index) != 0) {
//TODO basic pellet scatter spawn
if (bassPeaks.get(index) != 0 || UMPeaks.get(index) != 0) {
if (overlappedPeaks.get(index) != 0) {
//TODO basic void circle spawning
map.addToMap(Entities.VOID_CIRCLE,
overlappedPeaks.get(index)*Polyjet.GAME_AREA_WIDTH,
rand.nextFloat()*Polyjet.GAME_AREA_WIDTH,
rand.nextFloat()*Polyjet.GAME_AREA_HEIGHT);
} else if (bassPeaks.get(index) != 0) {
map.addToMap(Entities.BAR,
MathUtils.round(rand.nextFloat()*Polyjet.GAME_AREA_WIDTH),
bassPeaks.get(index)*Polyjet.GAME_AREA_HEIGHT/avgBPS);
} else {
if (UMPeaks.get(index) != 0) {
//TODO basic pellet scatter spawn
}
//TODO rest of the basic generation
}
//TODO rest of the basic generation
} else {
map.addRestToMap();
}
}
map.endBuild();
}
public synchronized GamePlayMap getMap() {
return map;
}
}