Added simple main menu.
This commit is contained in:
parent
35eca95cd8
commit
12da7d5cbe
BIN
core/assets/sprites/buttons/play.png
Normal file
BIN
core/assets/sprites/buttons/play.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.9 KiB |
BIN
core/assets/sprites/buttons/playHover.png
Normal file
BIN
core/assets/sprites/buttons/playHover.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.1 KiB |
@ -9,7 +9,7 @@ import com.saltosion.gladiator.gui.GUIManager;
|
|||||||
import com.saltosion.gladiator.input.InputHandler;
|
import com.saltosion.gladiator.input.InputHandler;
|
||||||
import com.saltosion.gladiator.level.EntityFactory;
|
import com.saltosion.gladiator.level.EntityFactory;
|
||||||
import com.saltosion.gladiator.state.BaseState;
|
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.AISystem;
|
||||||
import com.saltosion.gladiator.systems.CombatSystem;
|
import com.saltosion.gladiator.systems.CombatSystem;
|
||||||
import com.saltosion.gladiator.systems.MiscManagerSystem;
|
import com.saltosion.gladiator.systems.MiscManagerSystem;
|
||||||
@ -50,7 +50,7 @@ public class GladiatorBrawler extends ApplicationAdapter {
|
|||||||
|
|
||||||
// Initialize states
|
// Initialize states
|
||||||
BaseState.setMainClass(this);
|
BaseState.setMainClass(this);
|
||||||
setState(new InGameState());
|
setState(new MainMenuState());
|
||||||
|
|
||||||
Log.info("Successfully started the game.");
|
Log.info("Successfully started the game.");
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -2,6 +2,7 @@ package com.saltosion.gladiator.state;
|
|||||||
|
|
||||||
import com.saltosion.gladiator.gui.creators.GUICreator;
|
import com.saltosion.gladiator.gui.creators.GUICreator;
|
||||||
import com.saltosion.gladiator.gui.creators.TestGUICreator;
|
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.Level;
|
||||||
import com.saltosion.gladiator.level.TestLevel;
|
import com.saltosion.gladiator.level.TestLevel;
|
||||||
import com.saltosion.gladiator.util.AppUtil;
|
import com.saltosion.gladiator.util.AppUtil;
|
||||||
|
32
core/src/com/saltosion/gladiator/state/MainMenuState.java
Normal file
32
core/src/com/saltosion/gladiator/state/MainMenuState.java
Normal file
@ -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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -45,7 +45,7 @@ public class RenderingSystem extends EntitySystem {
|
|||||||
public int screenHeight = 0;
|
public int screenHeight = 0;
|
||||||
public int screenWidth = 0;
|
public int screenWidth = 0;
|
||||||
|
|
||||||
private boolean debug = true;
|
private boolean debug = false;
|
||||||
private final Color debugColor = new Color(0, 1, 0, 1);
|
private final Color debugColor = new Color(0, 1, 0, 1);
|
||||||
|
|
||||||
private float deltaDelay = 0;
|
private float deltaDelay = 0;
|
||||||
@ -82,10 +82,12 @@ public class RenderingSystem extends EntitySystem {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(float deltaTime) {
|
public void update(float deltaTime) {
|
||||||
|
if (AppUtil.player != null) {
|
||||||
CPhysics phys = pm.get(AppUtil.player);
|
CPhysics phys = pm.get(AppUtil.player);
|
||||||
camera.position.set(phys.getPosition().x, phys.getPosition().y, 0);
|
camera.position.set(phys.getPosition().x, phys.getPosition().y, 0);
|
||||||
camera.update();
|
|
||||||
fontCamera.position.set(camera.position.x * Global.FONT_SCALE, camera.position.y * Global.FONT_SCALE, 0);
|
fontCamera.position.set(camera.position.x * Global.FONT_SCALE, camera.position.y * Global.FONT_SCALE, 0);
|
||||||
|
}
|
||||||
|
camera.update();
|
||||||
fontCamera.update();
|
fontCamera.update();
|
||||||
|
|
||||||
Gdx.gl.glClearColor(0, 0, 0, 0);
|
Gdx.gl.glClearColor(0, 0, 0, 0);
|
||||||
|
@ -11,6 +11,9 @@ public class Name {
|
|||||||
public static final String WALLIMG = "WALLIMG";
|
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_LEFT = "MOVE_LEFT";
|
||||||
public static final String MOVE_RIGHT = "MOVE_RIGHT";
|
public static final String MOVE_RIGHT = "MOVE_RIGHT";
|
||||||
public static final String JUMP = "JUMP";
|
public static final String JUMP = "JUMP";
|
||||||
|
@ -17,6 +17,8 @@ public class SpriteLoader {
|
|||||||
loadTexture(Name.GROUNDIMG, "sprites/ground.png");
|
loadTexture(Name.GROUNDIMG, "sprites/ground.png");
|
||||||
loadTexture(Name.WALLIMG, "sprites/wall.png");
|
loadTexture(Name.WALLIMG, "sprites/wall.png");
|
||||||
loadTexture(Name.SWINGHITBOXIMG, "sprites/swinghitbox.png");
|
loadTexture(Name.SWINGHITBOXIMG, "sprites/swinghitbox.png");
|
||||||
|
loadTexture(Name.BUTTON_PLAY, "sprites/buttons/play.png");
|
||||||
|
loadTexture(Name.BUTTON_PLAY_HOVER, "sprites/buttons/playHover.png");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user