began working on game screen; changing entity system; clean up assets

This commit is contained in:
2018-02-04 21:16:36 -06:00
parent 1fbdefaecd
commit 7f51ca2c55
43 changed files with 102 additions and 78 deletions

View File

@@ -7,7 +7,7 @@ import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
import zero1hd.rhythmbullet.RhythmBullet;
import zero1hd.rhythmbullet.desktop.screens.LoadingScreen;
import zero1hd.rhythmbullet.desktop.screens.SplashScreen;
public class DesktopLauncher {
public static void main (String[] arg) {
@@ -20,7 +20,7 @@ public class DesktopLauncher {
config.allowSoftwareMode = true;
config.useHDPI = true;
core = new RhythmBullet();
core.setInitialScreen(new LoadingScreen(core));
core.setInitialScreen(new SplashScreen(core));
new LwjglApplication(core, config);

View File

@@ -24,7 +24,7 @@ import javazoom.jl.decoder.DecoderException;
import javazoom.jl.decoder.Header;
import javazoom.jl.decoder.MP3Decoder;
import javazoom.jl.decoder.OutputBuffer;
import zero1hd.rhythmbullet.util.MusicManager;
import zero1hd.rhythmbullet.audio.MusicManager;
public class Mp3Manager implements MusicManager {

View File

@@ -9,8 +9,8 @@ import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.Sort;
import zero1hd.rhythmbullet.audio.MusicManager;
import zero1hd.rhythmbullet.util.FileHandleAlphabeticalComparator;
import zero1hd.rhythmbullet.util.MusicManager;
public class MusicList extends Observable {
private Array<FileHandle> musicList;

View File

@@ -9,7 +9,7 @@ import com.badlogic.gdx.Preferences;
import com.badlogic.gdx.audio.Music;
import com.badlogic.gdx.audio.Music.OnCompletionListener;
import zero1hd.rhythmbullet.util.MusicManager;
import zero1hd.rhythmbullet.audio.MusicManager;
public class MusicListController extends Observable implements OnCompletionListener, Observer {
private MusicList musicList;

View File

@@ -12,8 +12,8 @@ import com.badlogic.gdx.audio.Music;
import com.badlogic.gdx.audio.Music.OnCompletionListener;
import com.badlogic.gdx.files.FileHandle;
import zero1hd.rhythmbullet.audio.MusicManager;
import zero1hd.rhythmbullet.audio.wavedecoder.WAVSampleReader;
import zero1hd.rhythmbullet.util.MusicManager;
public class WAVManager implements MusicManager {
private int readWindowSize = 1024;

View File

@@ -1,28 +0,0 @@
package zero1hd.rhythmbullet.desktop.audio.map;
import java.util.HashMap;
import zero1hd.rhythmbullet.entity.Entity;
import zero1hd.rhythmbullet.entity.EntityFrame;
import zero1hd.rhythmbullet.entity.coordinator.Coordinator;
import zero1hd.rhythmbullet.entity.coordinator.CoordinatorFrame;
public class EntitySpawnInfo {
private EntityFrame<? extends Entity> entityToSpawn;
private CoordinatorFrame<? extends Coordinator> entityCoordinator;
public HashMap<String, Float> parameters;
public EntitySpawnInfo(EntityFrame<? extends Entity> entityToSpawn, CoordinatorFrame<? extends Coordinator> coordinator) {
this.entityToSpawn = entityToSpawn;
parameters = new HashMap<>();
}
public EntityFrame<? extends Entity> getEntityToSpawn() {
return entityToSpawn;
}
public CoordinatorFrame<? extends Coordinator> getEntityCoordinator() {
return entityCoordinator;
}
}

View File

@@ -1,106 +0,0 @@
package zero1hd.rhythmbullet.desktop.audio.map;
import zero1hd.rhythmbullet.entity.Entity;
import zero1hd.rhythmbullet.entity.EntityFrame;
import zero1hd.rhythmbullet.entity.coordinator.Coordinator;
import zero1hd.rhythmbullet.entity.coordinator.CoordinatorFrame;
import zero1hd.rhythmbullet.util.MusicManager;
public class GamePlayMap {
private MusicManager musicData;
private MapWindowData[] spawnList;
private boolean building;
private int index;
private byte[] hudType;
/**
* GamePlayMap is what the game area will use to generate entities and judge current audio data
* @param audioData audio data
*/
public GamePlayMap(MusicManager audioData, int totalWindows) {
this.musicData = audioData;
spawnList = new MapWindowData[totalWindows];
hudType = new byte[totalWindows];
}
public int setIndex(int index) {
int previousIndex = this.index;
if (index < 0) {
this.index = 0;
} else if (index >= spawnList.length) {
toHead();
} else {
this.index = index;
}
return previousIndex;
}
public void setHUDType(byte data) {
hudType[index] = data;
}
public byte[] getHudType() {
return hudType;
}
public EntitySpawnInfo addEntity(EntityFrame<? extends Entity> entityType, CoordinatorFrame<? extends Coordinator> coordinator) {
if (building) {
if (spawnList[index] == null) {
spawnList[index] = new MapWindowData();
}
EntitySpawnInfo esi = new EntitySpawnInfo(entityType, coordinator);
spawnList[index].addEntity(esi);
return esi;
} else {
throw new IllegalStateException("Stupid, you need to call begin building first first.");
}
}
public void nextWindowData() {
if (building) {
index++;
} else {
throw new IllegalStateException("Stupid, you need to call begin building first first.");
}
}
public void toHead() {
index = spawnList.length-1;
}
public MusicManager getMusicData() {
return musicData;
}
public void beginBuild() {
if (!building) {
index = 0;
building = true;
} else {
throw new IllegalStateException("Excuse me, but your already building...");
}
}
public void endBuild() {
if (building) {
index = 0;
building = false;
} else {
throw new IllegalStateException("Nothings being built...");
}
}
public MapWindowData getCurrentWindowBasedOnIndex() {
if (index != musicData.getPlaybackIndexPosition()) {
index = musicData.getPlaybackIndexPosition();
if (index < spawnList.length) {
return spawnList[index];
}
}
return null;
}
public int getIndex() {
return index;
}
}

View File

@@ -1,19 +0,0 @@
package zero1hd.rhythmbullet.desktop.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();
}
}

View File

@@ -2,13 +2,13 @@ package zero1hd.rhythmbullet.desktop.audio.map;
import org.apache.commons.math3.random.MersenneTwister;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.utils.FloatArray;
import zero1hd.rhythmbullet.RhythmBullet;
import zero1hd.rhythmbullet.audio.AudioDataPackage;
import zero1hd.rhythmbullet.entity.EntityManager;
import zero1hd.rhythmbullet.entity.coordinator.CoordinatorManager;
import zero1hd.rhythmbullet.game.EntitySpawnInfo;
import zero1hd.rhythmbullet.game.GamePlayMap;
public class RhythmMapAlgorithm implements Runnable {

View File

@@ -9,7 +9,7 @@ import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.utils.FloatArray;
import zero1hd.rhythmbullet.util.MusicManager;
import zero1hd.rhythmbullet.audio.MusicManager;
public class AudioGraph extends Actor {
private MusicManager audioData;

View File

@@ -9,7 +9,7 @@ import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.utils.FloatArray;
import zero1hd.rhythmbullet.util.MusicManager;
import zero1hd.rhythmbullet.audio.MusicManager;
public class AudioGraphRelation extends Actor {
private MusicManager audioData;

View File

@@ -11,7 +11,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
import com.badlogic.gdx.utils.Align;
import zero1hd.rhythmbullet.desktop.screens.MainMenu;
import zero1hd.rhythmbullet.desktop.screens.MainMenuScreen;
public class GraphicsOptions extends Table {
private Label resolutions, shaders;
@@ -28,7 +28,7 @@ public class GraphicsOptions extends Table {
_1366x768;
public GraphicsOptions(final MainMenu mainMenu, Skin skin, final Preferences prefs) {
public GraphicsOptions(final MainMenuScreen mainMenu, Skin skin, final Preferences prefs) {
align(Align.center);
defaults().space(10f);
this.prefs = prefs;

View File

@@ -17,8 +17,8 @@ import com.badlogic.gdx.utils.reflect.ClassReflection;
import com.badlogic.gdx.utils.reflect.Field;
import com.badlogic.gdx.utils.reflect.ReflectionException;
import zero1hd.rhythmbullet.audio.MusicManager;
import zero1hd.rhythmbullet.audio.visualizer.BasicVisualizer;
import zero1hd.rhythmbullet.util.MusicManager;
public class Visualizer extends Widget implements Disposable {
private BasicVisualizer vis;

View File

@@ -14,8 +14,8 @@ import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
import zero1hd.rhythmbullet.audio.MusicInfo;
import zero1hd.rhythmbullet.audio.MusicManager;
import zero1hd.rhythmbullet.audio.analyzer.AudioAnalyzer;
import zero1hd.rhythmbullet.util.MusicManager;
public class AnalysisPage extends Page {
private boolean confirmed;

View File

@@ -14,12 +14,12 @@ import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
import com.badlogic.gdx.utils.Align;
import zero1hd.rhythmbullet.RhythmBullet;
import zero1hd.rhythmbullet.audio.MusicManager;
import zero1hd.rhythmbullet.desktop.audio.MusicListController;
import zero1hd.rhythmbullet.desktop.graphics.ui.components.MusicControls;
import zero1hd.rhythmbullet.desktop.graphics.ui.components.ScrollText;
import zero1hd.rhythmbullet.desktop.graphics.ui.components.TitleBarVisualizer;
import zero1hd.rhythmbullet.desktop.screens.MainMenu;
import zero1hd.rhythmbullet.util.MusicManager;
import zero1hd.rhythmbullet.desktop.screens.MainMenuScreen;
public class MainPage extends Page implements Observer {
private Label versionLabel;
@@ -32,10 +32,10 @@ public class MainPage extends Page implements Observer {
private TextButton quitButton;
private MusicControls musicControls;
private MainMenu mMenu;
private MainMenuScreen mMenu;
private ScrollText scrollText;
public MainPage(RhythmBullet core, final Vector3 targetPosition, MusicListController mlc, final MainMenu mainMenu) {
public MainPage(RhythmBullet core, final Vector3 targetPosition, MusicListController mlc, final MainMenuScreen mainMenu) {
this.mlc = mlc;
this.mMenu = mainMenu;
titleBar = new TitleBarVisualizer(core.getAssetManager());

View File

@@ -26,11 +26,11 @@ import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
import com.badlogic.gdx.utils.Array;
import zero1hd.rhythmbullet.audio.MusicInfo;
import zero1hd.rhythmbullet.audio.MusicManager;
import zero1hd.rhythmbullet.desktop.audio.MusicInfoController;
import zero1hd.rhythmbullet.desktop.audio.MusicListController;
import zero1hd.rhythmbullet.desktop.graphics.ui.components.MusicSelectable;
import zero1hd.rhythmbullet.desktop.graphics.ui.components.ScrollText;
import zero1hd.rhythmbullet.util.MusicManager;
public class MusicSelectionPage extends Page implements Observer {
Preferences musicFileAnnotation;

View File

@@ -10,14 +10,14 @@ import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
import zero1hd.rhythmbullet.desktop.graphics.ui.components.GraphicsOptions;
import zero1hd.rhythmbullet.desktop.screens.MainMenu;
import zero1hd.rhythmbullet.desktop.screens.MainMenuScreen;
public class VideoOptionsPage extends Page {
private ScrollPane scrollPane;
private GraphicsOptions graphicsTable;
private TextButton backButton;
public VideoOptionsPage(Skin skin, Preferences prefs, final MainMenu menu, AssetManager assets) {
public VideoOptionsPage(Skin skin, Preferences prefs, final MainMenuScreen menu, AssetManager assets) {
graphicsTable = new GraphicsOptions(menu, skin, prefs);
scrollPane = new ScrollPane(graphicsTable, skin);
scrollPane.setFadeScrollBars(false);

View File

@@ -10,7 +10,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup;
import com.badlogic.gdx.scenes.scene2d.ui.Window;
import zero1hd.rhythmbullet.audio.AudioDataPackage;
import zero1hd.rhythmbullet.util.MusicManager;
import zero1hd.rhythmbullet.audio.MusicManager;
public class BeatViewer extends Window {
Pixmap lights;

View File

@@ -9,7 +9,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.Slider;
import com.badlogic.gdx.scenes.scene2d.ui.Window;
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
import zero1hd.rhythmbullet.util.MusicManager;
import zero1hd.rhythmbullet.audio.MusicManager;
public class VolumeWindow extends Window {

View File

@@ -0,0 +1,29 @@
package zero1hd.rhythmbullet.desktop.screens;
import com.badlogic.gdx.Preferences;
import com.badlogic.gdx.ScreenAdapter;
import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.utils.viewport.ExtendViewport;
import zero1hd.rhythmbullet.RhythmBullet;
import zero1hd.rhythmbullet.game.GameController;
public class GameScreen extends ScreenAdapter {
private AssetManager assets;
private SpriteBatch batch;
private ExtendViewport viewport;
private GameController gc;
public GameScreen(AssetManager assets, Preferences prefs) {
this.assets = assets;
batch = new SpriteBatch();
viewport = new ExtendViewport(RhythmBullet.WORLD_WIDTH, RhythmBullet.WORLD_HEIGHT);
}
@Override
public void render(float delta) {
super.render(delta);
}
}

View File

@@ -20,6 +20,7 @@ import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.badlogic.gdx.utils.viewport.ScreenViewport;
import zero1hd.rhythmbullet.RhythmBullet;
import zero1hd.rhythmbullet.audio.MusicManager;
import zero1hd.rhythmbullet.desktop.audio.MusicInfoController;
import zero1hd.rhythmbullet.desktop.audio.MusicList;
import zero1hd.rhythmbullet.desktop.audio.MusicListController;
@@ -31,9 +32,8 @@ import zero1hd.rhythmbullet.desktop.graphics.ui.pages.MusicSelectionPage;
import zero1hd.rhythmbullet.desktop.graphics.ui.pages.OptionsPage;
import zero1hd.rhythmbullet.desktop.graphics.ui.pages.VideoOptionsPage;
import zero1hd.rhythmbullet.util.AdvancedResizeScreen;
import zero1hd.rhythmbullet.util.MusicManager;
public class MainMenu extends ScreenAdapter implements AdvancedResizeScreen {
public class MainMenuScreen extends ScreenAdapter implements AdvancedResizeScreen {
public Stage stage;
private Texture background;
private Vector3 cameraPosition;
@@ -65,7 +65,7 @@ public class MainMenu extends ScreenAdapter implements AdvancedResizeScreen {
private ScreenViewport screenViewport;
private boolean shaderLoaded;
public MainMenu(RhythmBullet core) {
public MainMenuScreen(RhythmBullet core) {
this.core = core;
stage = new Stage(new ScreenViewport());
cameraPosition = new Vector3(stage.getCamera().position);
@@ -90,7 +90,7 @@ public class MainMenu extends ScreenAdapter implements AdvancedResizeScreen {
stage.addActor(mainPage);
//End main menu
background = core.getAssetManager().get("RhythmBulletBG.png", Texture.class);
background = core.getAssetManager().get("backgrounds/mainBG.png", Texture.class);
keybindPage = new KeybindOptionsPage(core.getDefaultSkin(), core.getAssetManager(), cameraPosition);
keybindPage.setPosition(-1f*Gdx.graphics.getWidth(), -1f*Gdx.graphics.getHeight());

View File

@@ -13,14 +13,14 @@ import com.badlogic.gdx.utils.viewport.ScreenViewport;
import zero1hd.rhythmbullet.RhythmBullet;
import zero1hd.rhythmbullet.util.AdvancedResizeScreen;
public class LoadingScreen extends ScreenAdapter implements AdvancedResizeScreen {
public class SplashScreen extends ScreenAdapter implements AdvancedResizeScreen {
private Stage stage;
private RhythmBullet core;
private Texture splash;
private Image zero1HD;
private boolean done;
public LoadingScreen(RhythmBullet core) {
public SplashScreen(RhythmBullet core) {
this.core = core;
}
@@ -48,7 +48,7 @@ public class LoadingScreen extends ScreenAdapter implements AdvancedResizeScreen
if (!done) {
Gdx.app.debug("Loading Screen", "queue has all been loaded. Action is done playing.");
done = true;
core.setScreen(new MainMenu(core));
core.setScreen(new MainMenuScreen(core));
zero1HD.remove();
}
}

View File

@@ -1,159 +0,0 @@
package zero1hd.rhythmbullet.desktop.stages;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.InputProcessor;
import com.badlogic.gdx.Preferences;
import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.utils.Disposable;
import zero1hd.rhythmbullet.controls.KeyMap;
import zero1hd.rhythmbullet.desktop.audio.map.GamePlayMap;
import zero1hd.rhythmbullet.entity.CollisionDetector;
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 {
public PolyjetEntity polyjet;
private GamePlayMap audioMap;
public CoordinatorManager cm;
public EntityManager em;
private CollisionDetector collisionDetector;
public ScoreManager score = new ScoreManager();
public GameController(AssetManager assetManager, Preferences prefs) {
Gdx.app.debug("Game Area", "new area created");
polyjet = new PolyjetEntity(assetManager, 25f, 25f, 100, "standard");
em = new EntityManager(assetManager, prefs);
cm = new CoordinatorManager(em);
collisionDetector = new CollisionDetector(em.activeEnemies, em.activeAllies, assetManager, prefs);
em.activeAllies.add(polyjet);
}
public void draw(Batch batch) {
batch.begin();
for (int i = 0; i < em.activeEnemies.size; i++) {
em.activeEnemies.get(i).draw(batch);
}
for (int i = 0; i < em.activeAllies.size; i++) {
em.activeAllies.get(i).draw(batch);
}
batch.end();
}
public void prepare(float delta) {
for (int i = 0; i < em.activeEnemies.size; i++) {
em.activeEnemies.get(i).updatePosition();
}
for (int i = 0; i < em.activeAllies.size; i++) {
em.activeAllies.get(i).updatePosition();
}
}
public void setAudioMap(GamePlayMap audioMap) {
this.audioMap = audioMap;
}
public GamePlayMap getAudioMap() {
return audioMap;
}
@Override
public boolean keyDown(int keycode) {
if (keycode == KeyMap.left) {
polyjet.moveLeft = true;
}
if (keycode == KeyMap.right) {
polyjet.moveRight = true;
}
if (keycode == KeyMap.up) {
polyjet.moveUp = true;
}
if (keycode == KeyMap.down) {
polyjet.moveDown = true;
}
if (keycode == KeyMap.accelerate) {
polyjet.accelerate = true;
}
return false;
}
@Override
public boolean keyUp(int keycode) {
if (keycode == KeyMap.left) {
polyjet.moveLeft = false;
}
if (keycode == KeyMap.right) {
polyjet.moveRight = false;
}
if (keycode == KeyMap.up) {
polyjet.moveUp = false;
}
if (keycode == KeyMap.down) {
polyjet.moveDown = false;
}
if (keycode == KeyMap.accelerate) {
polyjet.accelerate = false;
}
if (keycode == KeyMap.shoot) {
Laser laser = em.laser.buildEntity();
laser.init(polyjet.getX() + polyjet.getWidth()/2f, polyjet.getY() + polyjet.getHeight()+1f, 60f);
}
return false;
}
public PolyjetEntity getPolyjetEntity() {
return polyjet;
}
@Override
public void dispose() {
}
public CollisionDetector getCollisionDetector() {
return collisionDetector;
}
@Override
public boolean keyTyped(char character) {
return false;
}
@Override
public boolean touchDown(int screenX, int screenY, int pointer, int button) {
return false;
}
@Override
public boolean touchUp(int screenX, int screenY, int pointer, int button) {
return false;
}
@Override
public boolean touchDragged(int screenX, int screenY, int pointer) {
return false;
}
@Override
public boolean mouseMoved(int screenX, int screenY) {
return false;
}
@Override
public boolean scrolled(int amount) {
return false;
}
}