Added simple main menu.

This commit is contained in:
Jeasonfire 2015-05-16 02:00:25 +03:00
parent 35eca95cd8
commit 12da7d5cbe
9 changed files with 87 additions and 8 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

@ -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.");
}

View File

@ -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;
}
}

View File

@ -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;

View 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();
}
}

View File

@ -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);

View File

@ -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";

View File

@ -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");
}
/**