diff --git a/StrafeOverdead/core/src/com/strafergame/GameState.java b/StrafeOverdead/core/src/com/strafergame/GameState.java new file mode 100644 index 0000000..e2ec887 --- /dev/null +++ b/StrafeOverdead/core/src/com/strafergame/GameState.java @@ -0,0 +1,9 @@ +package com.strafergame; + +public enum GameState { + LOADING, + MENU, + PAUSE, + CUTSCENE, + PLAY; +} diff --git a/StrafeOverdead/core/src/com/strafergame/Strafer.java b/StrafeOverdead/core/src/com/strafergame/Strafer.java index 4cf8f6e..d082397 100644 --- a/StrafeOverdead/core/src/com/strafergame/Strafer.java +++ b/StrafeOverdead/core/src/com/strafergame/Strafer.java @@ -13,7 +13,9 @@ import com.strafergame.game.world.GameWorld; import com.strafergame.graphics.WorldCamera; import com.strafergame.input.InputManager; +import com.strafergame.screens.GameScreen; import com.strafergame.screens.LoadingScreen; +import com.strafergame.screens.TitleScreen; import com.strafergame.ui.UiManager; /** @@ -38,6 +40,11 @@ public class Strafer extends Game { */ public static InputManager inputManager; + /** + * the current state of the game + */ + public static GameState gameState; + /** * the time elapsed. used to retrieve time dependent data such as animation * frames @@ -89,6 +96,21 @@ public class Strafer extends Game { */ public static UiManager uiManager; + /** + * the loading screen + */ + public static LoadingScreen loadingScreen; + + /** + * the title screen + */ + public static TitleScreen titleScreen; + + /** + * the game screen + */ + public static GameScreen gameScreen; + /** * stage that contains world entities */ @@ -130,8 +152,8 @@ public void create() { uiManager = new UiManager(uiScreenViewport, spriteBatch); uiManager.init(); - setScreen(new LoadingScreen(this)); - + loadingScreen = new LoadingScreen(this); + setScreen(loadingScreen); } @Override diff --git a/StrafeOverdead/core/src/com/strafergame/game/world/GameWorld.java b/StrafeOverdead/core/src/com/strafergame/game/world/GameWorld.java index ab5ccc6..91d8b79 100644 --- a/StrafeOverdead/core/src/com/strafergame/game/world/GameWorld.java +++ b/StrafeOverdead/core/src/com/strafergame/game/world/GameWorld.java @@ -22,10 +22,13 @@ public class GameWorld extends Stage implements Disposable { private Player playerTest2; private final TiledMap tiledMapTest = Strafer.assetManager.get("maps/test/map.tmx", TiledMap.class); + Strafer game; + Box2DWorld box2DWorld = new Box2DWorld(); - public GameWorld() { + public GameWorld(Strafer game) { super(Strafer.extendViewport, Strafer.spriteBatch); + this.game = game; addTestAssets(); } @@ -107,6 +110,9 @@ void debugControls() { if (Gdx.input.isKeyPressed(Keys.NUMPAD_5)) { playerTest1.getBody().setTransform(playerTest1.getX() + .5f, playerTest1.getY() + .5f, 0); } + if (Gdx.input.isKeyPressed(Keys.ESCAPE)) { + game.setScreen(Strafer.titleScreen); + } } } diff --git a/StrafeOverdead/core/src/com/strafergame/screens/LoadingScreen.java b/StrafeOverdead/core/src/com/strafergame/screens/LoadingScreen.java index aaeeea9..b17e57b 100644 --- a/StrafeOverdead/core/src/com/strafergame/screens/LoadingScreen.java +++ b/StrafeOverdead/core/src/com/strafergame/screens/LoadingScreen.java @@ -14,6 +14,7 @@ import com.badlogic.gdx.maps.tiled.TiledMap; import com.badlogic.gdx.maps.tiled.TmxMapLoader; import com.badlogic.gdx.math.MathUtils; +import com.strafergame.GameState; import com.strafergame.Strafer; import com.strafergame.graphics.AnimationProvider; @@ -36,6 +37,7 @@ public class LoadingScreen implements Screen { public LoadingScreen(final Strafer game) { this.game = game; + Strafer.gameState = GameState.LOADING; shapeRenderer = new ShapeRenderer(); queueAssetsToLoad(); @@ -56,8 +58,11 @@ private void update(float delta) { if (progress >= Strafer.assetManager.getProgress() - .001f) { if (Strafer.assetManager.isFinished()) { AnimationProvider.prepareAnimations(); - //game.setScreen(new GameScreen(game)); - game.setScreen(new TitleScreen(game)); + // game.setScreen(new GameScreen(game)); + if (Strafer.titleScreen == null) { + Strafer.titleScreen = new TitleScreen(game); + } + game.setScreen(Strafer.titleScreen); } } } diff --git a/StrafeOverdead/core/src/com/strafergame/ui/UiManager.java b/StrafeOverdead/core/src/com/strafergame/ui/UiManager.java index a569eea..440b748 100644 --- a/StrafeOverdead/core/src/com/strafergame/ui/UiManager.java +++ b/StrafeOverdead/core/src/com/strafergame/ui/UiManager.java @@ -12,8 +12,6 @@ public class UiManager extends Stage implements Disposable { - private HUD hud; - public UiManager(Viewport viewport, SpriteBatch spriteBatch) { super(viewport, spriteBatch); @@ -23,7 +21,6 @@ public void init() { ((InputMultiplexer) Gdx.input.getInputProcessor()).addProcessor(Strafer.uiManager); VisUI.load(SkinScale.X2); - hud = new HUD(); } @Override