Merge branch 'NewMapStructure' into AnalysisMapGenWork
This commit is contained in:
commit
052dcd2789
@ -1,35 +1,24 @@
|
|||||||
package zero1hd.polyjet.audio.map;
|
package zero1hd.polyjet.audio.map;
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
<<<<<<< HEAD
|
|
||||||
=======
|
|
||||||
import com.badlogic.gdx.Gdx;
|
|
||||||
import com.badlogic.gdx.audio.Music;
|
import com.badlogic.gdx.audio.Music;
|
||||||
import com.badlogic.gdx.math.MathUtils;
|
|
||||||
>>>>>>> parent of e4359f4... tuning and adjustments
|
|
||||||
=======
|
|
||||||
import com.badlogic.gdx.Gdx;
|
|
||||||
import com.badlogic.gdx.audio.Music;
|
|
||||||
import com.badlogic.gdx.math.MathUtils;
|
|
||||||
>>>>>>> parent of e4359f4... tuning and adjustments
|
|
||||||
import com.badlogic.gdx.utils.Array;
|
import com.badlogic.gdx.utils.Array;
|
||||||
|
|
||||||
import zero1hd.polyjet.audio.AudioData;
|
import zero1hd.polyjet.audio.AudioData;
|
||||||
import zero1hd.polyjet.entity.Entities;
|
import zero1hd.polyjet.entity.Entities;
|
||||||
|
|
||||||
public class GamePlayMap {
|
public class GamePlayMap {
|
||||||
private AudioData playableClip;
|
private AudioData musicData;
|
||||||
private float playTime;
|
private float playTime;
|
||||||
private Array<EntitySpawnInfo> spawnList;
|
private Array<MapWindowData> spawnList;
|
||||||
private boolean building;
|
private boolean building;
|
||||||
private int constIndex;
|
|
||||||
private int index;
|
private int index;
|
||||||
|
private int absoluteIndex;
|
||||||
/**
|
/**
|
||||||
* GamePlayMap is what the game area will use to generate entities and judge current audio data
|
* GamePlayMap is what the game area will use to generate entities and judge current audio data
|
||||||
* @param audioData audio data
|
* @param audioData audio data
|
||||||
*/
|
*/
|
||||||
public GamePlayMap(AudioData audioData) {
|
public GamePlayMap(AudioData audioData) {
|
||||||
this.playableClip = audioData;
|
this.musicData = audioData;
|
||||||
spawnList = new Array<>();
|
spawnList = new Array<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,8 +26,8 @@ public class GamePlayMap {
|
|||||||
* returns audio data
|
* returns audio data
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public AudioData getMusicData() {
|
public Music getPlayableClip() {
|
||||||
return playableClip;
|
return musicData.getPlaybackMusic();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -54,8 +43,10 @@ public class GamePlayMap {
|
|||||||
*/
|
*/
|
||||||
public void beginBuild() {
|
public void beginBuild() {
|
||||||
building = true;
|
building = true;
|
||||||
|
spawnList.clear();
|
||||||
|
spawnList.add(new MapWindowData());
|
||||||
index = 0;
|
index = 0;
|
||||||
constIndex = 0;
|
absoluteIndex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -64,7 +55,7 @@ public class GamePlayMap {
|
|||||||
public void endBuild() {
|
public void endBuild() {
|
||||||
building = false;
|
building = false;
|
||||||
index = 0;
|
index = 0;
|
||||||
constIndex = 0;
|
absoluteIndex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -74,53 +65,49 @@ public class GamePlayMap {
|
|||||||
* @param entityType what type of entity to spawn
|
* @param entityType what type of entity to spawn
|
||||||
* @param parameters the arguments for the entity. It is important to have the same amount of parameters the entity requires to spawn
|
* @param parameters the arguments for the entity. It is important to have the same amount of parameters the entity requires to spawn
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public void addToMap(Entities entityType, float... parameters) {
|
public void addToMap(Entities entityType, float... parameters) {
|
||||||
if (building && entityType != null && parameters != null) {
|
if (building && entityType != null && parameters != null) {
|
||||||
spawnList.add(new EntitySpawnInfo(entityType, index, parameters));
|
spawnList.get(index).addEntity(new EntitySpawnInfo(entityType, parameters));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void nextWindow() {
|
|
||||||
constIndex++;
|
|
||||||
index++;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Only works when not started.
|
* Moves onto the next window of the map for the song
|
||||||
* retrieve next entity in list.
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
public EntitySpawnInfo nextEntityBatch(boolean indexUpdate) {
|
public void nextWindow() {
|
||||||
if (!building) {
|
absoluteIndex++;
|
||||||
if (indexUpdate) {
|
resetIndex();
|
||||||
constIndex++;
|
if (building) {
|
||||||
index++;
|
spawnList.add(new MapWindowData());
|
||||||
}
|
|
||||||
EntitySpawnInfo spawnInfo = spawnList.get(index);
|
|
||||||
return spawnInfo;
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public EntitySpawnInfo safeNextEntityBatch() {
|
/**
|
||||||
playableClip.readIndexUpdate();
|
* moves to the previous window to make edits to that frame.
|
||||||
if (index != playableClip.getReadIndex()) {
|
*/
|
||||||
index = playableClip.getReadIndex();
|
public void previousWindow() {
|
||||||
<<<<<<< HEAD
|
absoluteIndex--;
|
||||||
<<<<<<< HEAD
|
resetIndex();
|
||||||
return nextEntityBatch(false);
|
}
|
||||||
=======
|
/**
|
||||||
=======
|
* use this to add rest for current index position
|
||||||
>>>>>>> parent of e4359f4... tuning and adjustments
|
*/
|
||||||
Gdx.app.debug("GPM", "index: " + index);
|
public void addNullToMap() {
|
||||||
return nextEntity(false);
|
if (building) {
|
||||||
>>>>>>> parent of e4359f4... tuning and adjustments
|
spawnList.set(index, null);
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MapWindowData nextWindowData() {
|
||||||
|
if (index != musicData.getReadIndex()) {
|
||||||
|
absoluteIndex = musicData.getReadIndex();
|
||||||
|
resetIndex();
|
||||||
|
return spawnList.get(index);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set retrieve entity index position.
|
* set retrieve entity index position.
|
||||||
* @param index
|
* @param index
|
||||||
@ -129,11 +116,11 @@ public class GamePlayMap {
|
|||||||
this.index = index;
|
this.index = index;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void restoreIndex() {
|
public boolean isCurrentNull() {
|
||||||
this.index = constIndex;
|
return spawnList.get(index) == null ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getIndex() {
|
public void resetIndex() {
|
||||||
return index;
|
index = absoluteIndex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
19
core/src/zero1hd/polyjet/audio/map/MapWindowData.java
Executable file
19
core/src/zero1hd/polyjet/audio/map/MapWindowData.java
Executable file
@ -0,0 +1,19 @@
|
|||||||
|
package zero1hd.polyjet.audio.map;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.utils.Array;
|
||||||
|
|
||||||
|
|
||||||
|
public class MapWindowData {
|
||||||
|
Array<EntitySpawnInfo> entityDatas;
|
||||||
|
public MapWindowData() {
|
||||||
|
entityDatas = new Array<>(EntitySpawnInfo.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addEntity(EntitySpawnInfo entity) {
|
||||||
|
entityDatas.add(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
public EntitySpawnInfo[] getArray() {
|
||||||
|
return entityDatas.toArray();
|
||||||
|
}
|
||||||
|
}
|
@ -56,20 +56,16 @@ public class RhythmMapAlgorithm implements Runnable {
|
|||||||
map.beginBuild();
|
map.beginBuild();
|
||||||
for (int index = 0; index < bassPeaks.size; index++) {
|
for (int index = 0; index < bassPeaks.size; index++) {
|
||||||
if (bassPeaks.get(index) != 0 || UMPeaks.get(index) != 0) {
|
if (bassPeaks.get(index) != 0 || UMPeaks.get(index) != 0) {
|
||||||
<<<<<<< HEAD
|
|
||||||
if (bassPeaks.get(index) > avgBass) {
|
|
||||||
=======
|
|
||||||
int warningTime = (int) ((3/speedMod)*windowPerSecond);
|
int warningTime = (int) ((3/speedMod)*windowPerSecond);
|
||||||
if ((index+warningTime < bassPeaks.size) && bassPeaks.get(index + warningTime) >= avgBass) {
|
if ((index+warningTime < bassPeaks.size) && bassPeaks.get(index + warningTime) != 0) {
|
||||||
>>>>>>> parent of e4359f4... tuning and adjustments
|
|
||||||
//TODO basic void circle spawning
|
//TODO basic void circle spawning
|
||||||
float endRadius = (bassPeaks.get(index)/bassMax)*(Polyjet.GAME_AREA_HEIGHT/2f);
|
float endRadius = (bassPeaks.get(index + warningTime)/bassMax)*(Polyjet.GAME_AREA_HEIGHT/2f);
|
||||||
|
|
||||||
map.addToMap(Entities.VOID_CIRCLE,
|
map.addToMap(Entities.VOID_CIRCLE,
|
||||||
endRadius,
|
endRadius,
|
||||||
rand.nextFloat()*Polyjet.GAME_AREA_WIDTH,
|
rand.nextFloat()*Polyjet.GAME_AREA_WIDTH,
|
||||||
rand.nextFloat()*Polyjet.GAME_AREA_HEIGHT,
|
rand.nextFloat()*Polyjet.GAME_AREA_HEIGHT,
|
||||||
endRadius/(avgSPB*0.5f),
|
endRadius/(avgSPB*0.6f),
|
||||||
3f/speedMod
|
3f/speedMod
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -87,11 +83,13 @@ public class RhythmMapAlgorithm implements Runnable {
|
|||||||
(Polyjet.GAME_AREA_HEIGHT/4f)/avgSPB);
|
(Polyjet.GAME_AREA_HEIGHT/4f)/avgSPB);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
map.addNullToMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
progress = MathUtils.round(100f*index/bassPeaks.size);
|
|
||||||
map.nextWindow();
|
map.nextWindow();
|
||||||
|
|
||||||
|
progress = MathUtils.round(100f*index/bassPeaks.size);
|
||||||
|
|
||||||
sender.send(MiniEvents.MAPGEN_ITERATED);
|
sender.send(MiniEvents.MAPGEN_ITERATED);
|
||||||
}
|
}
|
||||||
map.endBuild();
|
map.endBuild();
|
||||||
|
@ -9,7 +9,9 @@ import com.badlogic.gdx.scenes.scene2d.Stage;
|
|||||||
import com.badlogic.gdx.utils.viewport.FitViewport;
|
import com.badlogic.gdx.utils.viewport.FitViewport;
|
||||||
|
|
||||||
import zero1hd.polyjet.Polyjet;
|
import zero1hd.polyjet.Polyjet;
|
||||||
|
import zero1hd.polyjet.audio.map.EntitySpawnInfo;
|
||||||
import zero1hd.polyjet.audio.map.GamePlayMap;
|
import zero1hd.polyjet.audio.map.GamePlayMap;
|
||||||
|
import zero1hd.polyjet.audio.map.MapWindowData;
|
||||||
import zero1hd.polyjet.controls.KeyMap;
|
import zero1hd.polyjet.controls.KeyMap;
|
||||||
import zero1hd.polyjet.entity.CollisionDetector;
|
import zero1hd.polyjet.entity.CollisionDetector;
|
||||||
import zero1hd.polyjet.entity.Entities;
|
import zero1hd.polyjet.entity.Entities;
|
||||||
@ -106,18 +108,22 @@ public class GamePlayArea extends Stage {
|
|||||||
getBatch().draw(background, 0f, 0f, Polyjet.GAME_AREA_WIDTH, Polyjet.GAME_AREA_HEIGHT);
|
getBatch().draw(background, 0f, 0f, Polyjet.GAME_AREA_WIDTH, Polyjet.GAME_AREA_HEIGHT);
|
||||||
getBatch().end();
|
getBatch().end();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
getBatch().setShader(null);
|
getBatch().setShader(null);
|
||||||
super.draw();
|
super.draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void act(float delta) {
|
public void act(float delta) {
|
||||||
if (audioMap != null) {
|
MapWindowData mwd;
|
||||||
audioMap.getMusicData().readIndexUpdate();
|
if (audioMap != null && audioMap.getPlayableClip().isPlaying() && (mwd = audioMap.nextWindowData()) != null) {
|
||||||
time = audioMap.getMusicData().getPlaybackMusic().getPosition();
|
EntitySpawnInfo[] currentSpawnInfo = mwd.getArray();
|
||||||
while (ec.spawnEntity(this, audioMap.nextEntityBatch(false)).getSpawnWindowID() == audioMap.getMusicData().getReadIndex()) {
|
if (currentSpawnInfo != null) {
|
||||||
audioMap.nextWindow();
|
for (int i = 0; i < currentSpawnInfo.length; i++) {
|
||||||
};
|
ec.spawnEntity(this, currentSpawnInfo[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
collisionDetector.collisionCheck();
|
collisionDetector.collisionCheck();
|
||||||
ec.deathClean();
|
ec.deathClean();
|
||||||
|
Loading…
Reference in New Issue
Block a user