From 12da7d5cbe79979df32078bd2b8d59a929a17f7d Mon Sep 17 00:00:00 2001 From: Jeasonfire Date: Sat, 16 May 2015 02:00:25 +0300 Subject: [PATCH] Added simple main menu. --- core/assets/sprites/buttons/play.png | Bin 0 -> 1942 bytes core/assets/sprites/buttons/playHover.png | Bin 0 -> 2101 bytes .../saltosion/gladiator/GladiatorBrawler.java | 4 +- .../gui/creators/MainMenuGUICreator.java | 39 ++++++++++++++++++ .../gladiator/state/InGameState.java | 1 + .../gladiator/state/MainMenuState.java | 32 ++++++++++++++ .../gladiator/systems/RenderingSystem.java | 10 +++-- .../com/saltosion/gladiator/util/Name.java | 7 +++- .../gladiator/util/SpriteLoader.java | 2 + 9 files changed, 87 insertions(+), 8 deletions(-) create mode 100644 core/assets/sprites/buttons/play.png create mode 100644 core/assets/sprites/buttons/playHover.png create mode 100644 core/src/com/saltosion/gladiator/gui/creators/MainMenuGUICreator.java create mode 100644 core/src/com/saltosion/gladiator/state/MainMenuState.java diff --git a/core/assets/sprites/buttons/play.png b/core/assets/sprites/buttons/play.png new file mode 100644 index 0000000000000000000000000000000000000000..5b0b50f033faf9ef89e5036c51aae9ed694a8ea5 GIT binary patch literal 1942 zcmeHH`#;lr82`+M+4dcq*=9F0Y%Yt1VRPLwnp@h2iBpD!QYa^0idK#;j*f^55#c1& zx}4;6x+#_N%B7rADczaZOVLH@&~d)!&p5Bwd0y}5c|Xtd!}G)Y^*qn+=%`Q#L&E?7 zAoGJa?7YSp03?WxP|4svoTCB2 z!DEboISN>yfTbxQnF2Bz27-(>qG1r$SR@sTqT`SZtPule#DY*v$k-N-;#inC5KQd} zXdVfM8IOeFks(JC+S$s?iHva~V_hgXX9~op;9RWnu2ifm6}N~AxzQj26)T`YLOR}) zVeZ2;_h49fF)f5F7zA${qR_@t#Ig{x2_iO8#I_XKlEfU6*v`tIL-gZV`f*79aBfEq zb0>3;TW{2eM&BWf~LuzLU7e_8=y|0j6!fm!y__>BPIyZ?1WPgYwh+@$8p)Va#6 z)wy|^4O)<`$ylH3x?Y>h_H-4v3biHfTKI_OI!(m@Vx8)Vv zF9}(iGQ{!L7Z(b$dTzx)FFs$tZpu&B->mLfgY1)u%#viq{Gy}f^;d%59mYbZzF2jf zs?O)dKo-oi2?r*o;u15e6?Wd;9~?&pc5U!d;z9C`vdzIMrOyZF<@Lro#@PcSpFU58 z==i|xpM-nz=B7)&v!7g0t*Kdj zzFL{tpkJYjuT^JHYEcJMCN%+PxHtS0<|=O01&?*0>G$t$$l1B5v=`lGdfO<-)lfxG zgoh3Az@`1qPrn&1*9hu3xCsmC?Q@&`y_Dlu@j;=00M54rAaq_yO(R8N0sFE?yBp^- z=fs;`QVPUB3?Z_AnLBq^NS8st(X!rnUTbkCzc z^z;#G-Gd3gmWH;Kk8+-lx-``(RIzKty1;-m=I*M}gN{h`15KUN_+^{huYW$+oJrWe zzfvM-AIt^e0|udV)xAZHKY0+}zo0-3v(<)5Ev|c;(#fINO5Yq)@+-2dm}s-4n&Xn! z0~}GqSn;9!Z%=aa%F>&a{c7GZlcap;?X(05i1(ZIFwLJ2rw{ zyVKv~;JTDe+wN}d3LsrON*K`eR-QH{ytq??IMV%c247e}-*hImSr}#9`AV!$OU&Kk z9T3@F^d=W&eltD=fU4ow?Tv<1-$gC_FIPNb$9=x8CckGXrkx4rFt1IySw}7u;K8A> zMBf{STE6;uUwnLR%>Cl2lL6A%k3|uk)RsS*a$4%Wzd@dH?WEScdNF$ zzAutgob#yWis6z(m!GxpbY$6V-e}DJVu=v2jHlW-+~qO+rg=kxvm!;bCDGwxQl!=5 zjOKw0kT{bC Yqf2G=*-?omUGS>_a#>WcUYfN1A7Q#WX8-^I literal 0 HcmV?d00001 diff --git a/core/assets/sprites/buttons/playHover.png b/core/assets/sprites/buttons/playHover.png new file mode 100644 index 0000000000000000000000000000000000000000..dc5d64b005393b7a04d1f18063f435e827fc7a2e GIT binary patch literal 2101 zcmeHH>01+a68?p7C*exS#gzad5Dq~SA&^LboFp8Eqak1bK{-Sc2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? zegR?{&$^Sc%c1Jd@2K=qFWBw5dl26vTgu?slk2A>qLFQP&lJ-8s-#dgj3e78s=Dad z2Zrq&Mf3mtWfarem${Uo$P2w6lV>#N61kj~13>**qv81pXV(V&%TSs5iCsiBuh80b z%>+EyKZ)}Ozv?5QAz#Sa@XcE4%7Xtf_Dws!I&;Xh$>Qm*J-eSzPEW-uZ>*|!j_UvU z-K)o&m8mmIT`#mJD7$CFhqp^mv&8fI7fhl%`3lXdljFS-x+(mFpxYBp7>VSzI<%+R_3 zGc@tEu>=HRQwHgegfeAnHtx~q79(KxW@lvjgEv1!tP$EO>1MyB+}NlbX}ngmY&7)` z!s$gV(TdpkC+NM}{S(h53C!U#uKR)X$a(%HYY2Lbg)y2df2*3-or5)Tfd1Tp4k4XS znrAgUl6ay*n8j^P_ew{6eHswfyj!EPk=vX*+WeWfj~*ghU@e(9u5D!9Zyel=7?@kG zum4x`i~kJh^o4Az=_u7lQU!%OVsq)2Iu%6GLwfS?`@(ms0oKy$v*!;!hVDUatvI?^ zZP}0++Qu7{;bQfqrz5WCKdZ9W7N6hxu(>vIaR0cX^p$kO(BR;p%%>nf-}hkLH|Em1 w{`~i|k6unq9}{9e2X%bIQGbakM>I{WLis}`Z`aBL=Kp?o0!|G3VnllNU)*)cb^rhX literal 0 HcmV?d00001 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"); } /**