removed deprecated code; platform based, window manager created; cleaned

code and files;
This commit is contained in:
2018-08-16 13:49:44 -05:00
parent 7fb42a63f8
commit 901594608c
22 changed files with 159 additions and 85 deletions

View File

@@ -18,8 +18,11 @@ import com.badlogic.gdx.graphics.g2d.ParticleEffect;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import zero1hd.rhythmbullet.util.AssetPack;
import zero1hd.rhythmbullet.util.GenericFileTypeHandler;
import zero1hd.rhythmbullet.util.InitialScreen;
import zero1hd.rhythmbullet.util.RoundingResolutionHandler;
import zero1hd.rhythmbullet.util.ScreenConfiguration;
import zero1hd.rhythmbullet.util.ResizeReadyScreen;
@@ -40,15 +43,16 @@ public class RhythmBullet extends Game {
private RoundingResolutionHandler rRHandler;
private InitialScreen initialScreen;
private AssetPack assetPack;
private ScreenConfiguration screenConfiguration;
/**
* This should be called before passed to LWJGL. Setup for system-dependent items such as UI and assets.
* @param initialScreen the first screen to go to.
* @param assetPack the asset package to be used.
*/
public void setup(InitialScreen initialScreen, AssetPack assetPack) {
public void setup(InitialScreen initialScreen, AssetPack assetPack, ScreenConfiguration screenConfiguration) {
this.initialScreen = initialScreen;
this.assetPack = assetPack;
this.screenConfiguration = screenConfiguration;
}
@Override
@@ -203,4 +207,8 @@ public class RhythmBullet extends Game {
}
super.dispose();
}
public ScreenConfiguration getScreenConfiguration() {
return screenConfiguration;
}
}

View File

@@ -219,7 +219,10 @@ public class MusicController extends Observable implements OnCompletionListener,
}
public boolean isPlaying() {
return music.isPlaying();
if (music != null) {
return music.isPlaying();
}
return false;
}
/**

View File

@@ -21,9 +21,10 @@ public class DoubleHorizontalVisualizer implements Disposable {
private int binsPerBar;
private float offset;
private int boundaryThickness;
private float targetDelta;
private float spacePercentage = 0.85f;
private int barCount = 80;
private float normalFactor = 1.2f;
private float normalFactor = 0.8f;
private float barChangeRate = 14f;
private int smoothRange = 1;
private int binsToInclude = 160;
@@ -34,12 +35,11 @@ public class DoubleHorizontalVisualizer implements Disposable {
* @param width the width of the visualizer.
* @param spacePercentage the percentage of a bar that should be space.
*/
public DoubleHorizontalVisualizer(int width, int height, MusicController musicController, PCMSystem PCMSystem) {
public DoubleHorizontalVisualizer(int width, int height, int targetFPS, MusicController musicController, PCMSystem PCMSystem) {
this.barWidth = width/barCount;
this.spaceBetweenBars = MathUtils.round(barWidth * spacePercentage);
this.barWidth -= spaceBetweenBars;
pcm = PCMSystem;
if (barWidth < 1) throw new IllegalArgumentException("The arguments you passed caused the bar width to be 0.");
binsPerBar = (binsToInclude/barCount);
this.width = width;
this.height = height;
@@ -48,6 +48,7 @@ public class DoubleHorizontalVisualizer implements Disposable {
shapeRenderer = new ShapeRenderer();
boundaryThickness = barWidth;
offset = (width - (barCount*(barWidth+spaceBetweenBars)-spaceBetweenBars))/2f + x;
this.targetDelta = 1f/targetFPS;
}
public void act(float delta) {
@@ -55,10 +56,11 @@ public class DoubleHorizontalVisualizer implements Disposable {
if (color.g > 1f) color.g = 0f;
if (color.b > 1f) color.b = 0f;
if (color.a > 1f) color.a = 0.2f;
float[] freqBins = pcm.getFrequencyBins();
for (int bar = 0; bar < amplitudes.length; bar++) {
float normalizedAmplitude = 0;
for (int freq = bar*binsPerBar; freq < (bar*binsPerBar) + binsPerBar; freq++) {
normalizedAmplitude += Math.abs(pcm.getFrequencyBins()[freq]);
normalizedAmplitude += Math.abs(freqBins[freq]);
}
amplitudes[bar] += normalizedAmplitude * normalFactor * (height/100f);
amplitudes[bar] /= binsPerBar;
@@ -77,8 +79,11 @@ public class DoubleHorizontalVisualizer implements Disposable {
}
amplitudes[bar] /= smoothCount;
int pixelsMoved = MathUtils.round(amplitudes[bar] - barHeights[bar]);
pixelsMoved = MathUtils.floor(pixelsMoved*delta*barChangeRate);
int pixelsMoved = 0;
pixelsMoved = MathUtils.round(amplitudes[bar] - barHeights[bar]);
pixelsMoved = MathUtils.floor(pixelsMoved*targetDelta*barChangeRate);
barHeights[bar] += pixelsMoved;

View File

@@ -13,7 +13,6 @@ import zero1hd.rhythmbullet.entity.EntityManager;
import zero1hd.rhythmbullet.entity.ally.Laser;
import zero1hd.rhythmbullet.entity.ally.PolyjetEntity;
import zero1hd.rhythmbullet.entity.coordinator.CoordinatorManager;
import zero1hd.rhythmbullet.util.ScoreManager;
public class GameController implements Disposable, InputProcessor {

View File

@@ -1,4 +1,4 @@
package zero1hd.rhythmbullet.util;
package zero1hd.rhythmbullet.game;
public class ScoreManager {
private int score;

View File

@@ -1,11 +1,10 @@
package zero1hd.rhythmbullet.util;
package zero1hd.rhythmbullet.graphics.ui.components;
import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.scenes.scene2d.ui.ButtonGroup;
import com.badlogic.gdx.utils.Array;
import zero1hd.rhythmbullet.audio.metadata.AudioMetadata;
import zero1hd.rhythmbullet.graphics.ui.components.MusicSelectable;
public class MusicSelectableButtonGroup extends ButtonGroup<MusicSelectable> {
private Array<MusicSelectable> buttons;

View File

@@ -1,4 +1,4 @@
package zero1hd.rhythmbullet;
package zero1hd.rhythmbullet.util;
import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;

View File

@@ -1,8 +1,8 @@
package zero1hd.rhythmbullet;
package zero1hd.rhythmbullet.util;
import com.badlogic.gdx.Screen;
import zero1hd.rhythmbullet.util.ResizeReadyScreen;
import zero1hd.rhythmbullet.RhythmBullet;
public interface InitialScreen extends ResizeReadyScreen {
/**

View File

@@ -1,6 +0,0 @@
package zero1hd.rhythmbullet.util;
@Deprecated
public enum MiniEvents {
SPECTRAL_FLUX_DONE, MUSIC_DATA_CLEANED, MUSIC_SELECTED, BACK, MAP_GENERATED, ANALYZER_ITERATED, MAPGEN_ITERATED;
}

View File

@@ -1,6 +0,0 @@
package zero1hd.rhythmbullet.util;
@Deprecated
public interface MiniListener {
public void handle(MiniEvents ID);
}

View File

@@ -1,26 +0,0 @@
package zero1hd.rhythmbullet.util;
import com.badlogic.gdx.utils.Array;
@Deprecated
public class MiniSender {
private volatile Array<MiniListener> listeners;
public MiniSender() {
listeners = new Array<MiniListener>();
}
public synchronized void send(MiniEvents ID) {
for (MiniListener listener : listeners) {
listener.handle(ID);
}
}
public synchronized void addListener(MiniListener handler) {
listeners.add(handler);
}
public synchronized void removeListener(MiniListener listener) {
listeners.removeValue(listener, true);
}
}

View File

@@ -0,0 +1,25 @@
package zero1hd.rhythmbullet.util;
public interface ScreenConfiguration {
public void setFramesPerSecond(int fps);
public void setVsync(boolean useVsync);
public int getFramesPerSecond();
public boolean getVsync();
public int getScreenWidth();
public int getScreenHeight();
public int getWindowPosX();
public int getWindowPosY();
public void setWindowLocationX(int x);
public void setWindowLocationY(int y);
public void setWindowLocation(int x, int y);
}