diff --git a/core/assets/sprites/buttons/play.png b/core/assets/sprites/buttons/play.png new file mode 100644 index 0000000..5b0b50f Binary files /dev/null and b/core/assets/sprites/buttons/play.png differ diff --git a/core/assets/sprites/buttons/playHover.png b/core/assets/sprites/buttons/playHover.png new file mode 100644 index 0000000..dc5d64b Binary files /dev/null and b/core/assets/sprites/buttons/playHover.png differ diff --git a/core/src/com/saltosion/gladiator/GladiatorBrawler.java b/core/src/com/saltosion/gladiator/GladiatorBrawler.java index 1e5b152..e706e11 100644 --- a/core/src/com/saltosion/gladiator/GladiatorBrawler.java +++ b/core/src/com/saltosion/gladiator/GladiatorBrawler.java @@ -9,7 +9,7 @@ import com.saltosion.gladiator.gui.GUIManager; import com.saltosion.gladiator.input.InputHandler; import com.saltosion.gladiator.level.EntityFactory; import com.saltosion.gladiator.state.BaseState; -import com.saltosion.gladiator.state.InGameState; +import com.saltosion.gladiator.state.MainMenuState; import com.saltosion.gladiator.systems.AISystem; import com.saltosion.gladiator.systems.CombatSystem; import com.saltosion.gladiator.systems.MiscManagerSystem; @@ -50,7 +50,7 @@ public class GladiatorBrawler extends ApplicationAdapter { // Initialize states BaseState.setMainClass(this); - setState(new InGameState()); + setState(new MainMenuState()); Log.info("Successfully started the game."); } diff --git a/core/src/com/saltosion/gladiator/gui/creators/MainMenuGUICreator.java b/core/src/com/saltosion/gladiator/gui/creators/MainMenuGUICreator.java new file mode 100644 index 0000000..7cb28c6 --- /dev/null +++ b/core/src/com/saltosion/gladiator/gui/creators/MainMenuGUICreator.java @@ -0,0 +1,39 @@ +package com.saltosion.gladiator.gui.creators; + +import com.saltosion.gladiator.gui.nodes.ButtonNode; +import com.saltosion.gladiator.gui.nodes.TextNode; +import com.saltosion.gladiator.util.AppUtil; +import com.saltosion.gladiator.util.Log; +import com.saltosion.gladiator.util.Name; +import com.saltosion.gladiator.util.SpriteLoader; + +public class MainMenuGUICreator implements GUICreator { + + private boolean shouldPlay = false; + + @Override + public void create() { + TextNode titleText = new TextNode("Game Title", "Gladiator Brawler Game Thing!"); + titleText.setPosition(0.23f, 0.8f); + AppUtil.guiManager.getRootNode().addChild(titleText); + + ButtonNode playButton = new ButtonNode("Play Button", SpriteLoader.loadSprite(Name.BUTTON_PLAY_HOVER), + SpriteLoader.loadSprite(Name.BUTTON_PLAY)) { + @Override + public void pressed(int x, int y, int mouseButton) { + } + + @Override + public void released(int x, int y, int mouseButton) { + shouldPlay = true; + } + }; + playButton.setPosition(0.5f, 0.5f); + AppUtil.guiManager.getRootNode().addChild(playButton); + } + + public boolean shouldPlay() { + return shouldPlay; + } + +} diff --git a/core/src/com/saltosion/gladiator/state/InGameState.java b/core/src/com/saltosion/gladiator/state/InGameState.java index 78b5e1a..1fe1f67 100644 --- a/core/src/com/saltosion/gladiator/state/InGameState.java +++ b/core/src/com/saltosion/gladiator/state/InGameState.java @@ -2,6 +2,7 @@ package com.saltosion.gladiator.state; import com.saltosion.gladiator.gui.creators.GUICreator; import com.saltosion.gladiator.gui.creators.TestGUICreator; +import com.saltosion.gladiator.gui.nodes.ButtonNode; import com.saltosion.gladiator.level.Level; import com.saltosion.gladiator.level.TestLevel; import com.saltosion.gladiator.util.AppUtil; diff --git a/core/src/com/saltosion/gladiator/state/MainMenuState.java b/core/src/com/saltosion/gladiator/state/MainMenuState.java new file mode 100644 index 0000000..8fa1dea --- /dev/null +++ b/core/src/com/saltosion/gladiator/state/MainMenuState.java @@ -0,0 +1,32 @@ +package com.saltosion.gladiator.state; + +import com.saltosion.gladiator.gui.creators.MainMenuGUICreator; +import com.saltosion.gladiator.util.AppUtil; + +public class MainMenuState extends BaseState { + + private MainMenuGUICreator guiCreator; + + @Override + public void create() { + // Start from a clean slate + AppUtil.guiManager.clearGUI(); + + guiCreator = new MainMenuGUICreator(); + guiCreator.create(); + } + + @Override + public void update(float deltaTime) { + if (guiCreator.shouldPlay()) { + changeState(new InGameState()); + } + } + + @Override + public void destroy() { + // Clear GUI so there's nothing leftover for the next state + AppUtil.guiManager.clearGUI(); + } + +} diff --git a/core/src/com/saltosion/gladiator/systems/RenderingSystem.java b/core/src/com/saltosion/gladiator/systems/RenderingSystem.java index 1d6fd14..b1a1297 100644 --- a/core/src/com/saltosion/gladiator/systems/RenderingSystem.java +++ b/core/src/com/saltosion/gladiator/systems/RenderingSystem.java @@ -45,7 +45,7 @@ public class RenderingSystem extends EntitySystem { public int screenHeight = 0; public int screenWidth = 0; - private boolean debug = true; + private boolean debug = false; private final Color debugColor = new Color(0, 1, 0, 1); private float deltaDelay = 0; @@ -82,10 +82,12 @@ public class RenderingSystem extends EntitySystem { @Override public void update(float deltaTime) { - CPhysics phys = pm.get(AppUtil.player); - camera.position.set(phys.getPosition().x, phys.getPosition().y, 0); + if (AppUtil.player != null) { + CPhysics phys = pm.get(AppUtil.player); + camera.position.set(phys.getPosition().x, phys.getPosition().y, 0); + fontCamera.position.set(camera.position.x * Global.FONT_SCALE, camera.position.y * Global.FONT_SCALE, 0); + } camera.update(); - fontCamera.position.set(camera.position.x * Global.FONT_SCALE, camera.position.y * Global.FONT_SCALE, 0); fontCamera.update(); Gdx.gl.glClearColor(0, 0, 0, 0); diff --git a/core/src/com/saltosion/gladiator/util/Name.java b/core/src/com/saltosion/gladiator/util/Name.java index 1ee162e..a881e16 100644 --- a/core/src/com/saltosion/gladiator/util/Name.java +++ b/core/src/com/saltosion/gladiator/util/Name.java @@ -4,12 +4,15 @@ public class Name { public static final String GAME_NAME = "Gladiator Brawl"; public static final String DEBUG = "DEBUG"; - + public static final String STATICPLAYER = "STATICPLAYER"; public static final String PLAYERIMG = "PLAYERIMG"; public static final String GROUNDIMG = "GROUNDIMG"; public static final String WALLIMG = "WALLIMG"; - public static final String SWINGHITBOXIMG = "SWINGHITBOXIMG"; + public static final String SWINGHITBOXIMG = "SWINGHITBOXIMG"; + + public static final String BUTTON_PLAY = "BUTTON_PLAY"; + public static final String BUTTON_PLAY_HOVER = "BUTTON_PLAY_HOVER"; public static final String MOVE_LEFT = "MOVE_LEFT"; public static final String MOVE_RIGHT = "MOVE_RIGHT"; diff --git a/core/src/com/saltosion/gladiator/util/SpriteLoader.java b/core/src/com/saltosion/gladiator/util/SpriteLoader.java index 16dbfa1..9bfa6bd 100644 --- a/core/src/com/saltosion/gladiator/util/SpriteLoader.java +++ b/core/src/com/saltosion/gladiator/util/SpriteLoader.java @@ -17,6 +17,8 @@ public class SpriteLoader { loadTexture(Name.GROUNDIMG, "sprites/ground.png"); loadTexture(Name.WALLIMG, "sprites/wall.png"); loadTexture(Name.SWINGHITBOXIMG, "sprites/swinghitbox.png"); + loadTexture(Name.BUTTON_PLAY, "sprites/buttons/play.png"); + loadTexture(Name.BUTTON_PLAY_HOVER, "sprites/buttons/playHover.png"); } /**