DEADSOFTWARE

Rename GameState.java -> AppState.java
authorfred-boy <fred-boy@protonmail.com>
Tue, 24 Apr 2018 10:48:56 +0000 (17:48 +0700)
committerfred-boy <fred-boy@protonmail.com>
Tue, 24 Apr 2018 10:48:56 +0000 (17:48 +0700)
core/src/ru/deadsoftware/cavecraft/AppState.java [moved from core/src/ru/deadsoftware/cavecraft/GameState.java with 64% similarity]
core/src/ru/deadsoftware/cavecraft/CaveGame.java
core/src/ru/deadsoftware/cavecraft/GameScreen.java
core/src/ru/deadsoftware/cavecraft/game/GameInput.java
core/src/ru/deadsoftware/cavecraft/game/GameProc.java
core/src/ru/deadsoftware/cavecraft/menu/MenuRenderer.java

similarity index 64%
rename from core/src/ru/deadsoftware/cavecraft/GameState.java
rename to core/src/ru/deadsoftware/cavecraft/AppState.java
index 8f110642fc404386ff51b978678f684f67cef300..e38e701ff2999a032cf101d8c82dad1dce11bcaa 100644 (file)
@@ -1,9 +1,12 @@
 package ru.deadsoftware.cavecraft;
 
-public enum GameState {
-    RESTART,
+public enum AppState {
+    GOTO_GAME,
     GOTO_MENU,
+
     MENU_MAIN,
+    MENU_GENWORLD,
+
     GAME_PLAY,
     GAME_CREATIVE_INV
 }
index 31b763a3e7106d87c1fe26abc0686f6487c51b11..72481c2b66a695af66746f944bf5440379b164a9 100644 (file)
@@ -8,7 +8,7 @@ public class CaveGame extends Game {
        public static final String VERSION = "alpha 0.3-dev";
        public static String GAME_FOLDER;
 
-       public static GameState STATE;
+       public static AppState STATE;
 
        public static boolean TOUCH;
 
@@ -18,7 +18,7 @@ public class CaveGame extends Game {
 
        public CaveGame(boolean touch) {
                TOUCH = touch;
-               STATE = GameState.MENU_MAIN;
+               STATE = AppState.MENU_MAIN;
        }
 
        @Override
index 52c3dcf5c8f2dbf1cedd7952d97fefe8a2648e82..1c6ad795349289701f3a2bfaeb29503a799f0fba 100644 (file)
@@ -53,17 +53,17 @@ public class GameScreen implements Screen {
                 menu();
                 break;
 
-            case RESTART:
+            case GOTO_GAME:
                 gameProc = new GameProc();
                 renderer = gameProc.renderer;
                 Gdx.input.setInputProcessor(new InputHandlerGame(gameProc));
-                CaveGame.STATE = GameState.GAME_PLAY;
+                CaveGame.STATE = AppState.GAME_PLAY;
                 break;
 
             case GOTO_MENU:
                 renderer = menuRenderer;
                 Gdx.input.setInputProcessor(new InputHandlerMenu(menuRenderer));
-                CaveGame.STATE = GameState.MENU_MAIN;
+                CaveGame.STATE = AppState.MENU_MAIN;
                 break;
         }
         renderer.render();
index f05f56376d3524625ef798a10b49b34dcb12651d..10e0e43f0047bad021e6f5b29120b8afc38f6586 100644 (file)
@@ -1,9 +1,9 @@
 package ru.deadsoftware.cavecraft.game;
 
-import com.badlogic.gdx.Gdx;
 import com.badlogic.gdx.Input;
 import com.badlogic.gdx.utils.TimeUtils;
 import ru.deadsoftware.cavecraft.*;
+import ru.deadsoftware.cavecraft.AppState;
 
 public class GameInput {
 
@@ -73,16 +73,16 @@ public class GameInput {
                 break;
 
             case Input.Keys.E:
-                if (CaveGame.STATE == GameState.GAME_PLAY) CaveGame.STATE = GameState.GAME_CREATIVE_INV;
-                    else CaveGame.STATE = GameState.GAME_PLAY;
+                if (CaveGame.STATE == AppState.GAME_PLAY) CaveGame.STATE = AppState.GAME_CREATIVE_INV;
+                    else CaveGame.STATE = AppState.GAME_PLAY;
                 break;
 
             case Input.Keys.N:
-                CaveGame.STATE = GameState.RESTART;
+                CaveGame.STATE = AppState.GOTO_GAME;
                 break;
 
             case Input.Keys.ESCAPE: case Input.Keys.BACK:
-                CaveGame.STATE = GameState.GOTO_MENU;
+                CaveGame.STATE = AppState.GOTO_MENU;
                 break;
         }
     }
@@ -103,7 +103,7 @@ public class GameInput {
     }
 
     public void touchDown(int screenX, int screenY, int button) {
-        if (CaveGame.STATE == GameState.GAME_CREATIVE_INV &&
+        if (CaveGame.STATE == AppState.GAME_CREATIVE_INV &&
                 screenX>gameProc.renderer.camera.viewportWidth/2-Assets.creativeInv.getRegionWidth()/2 &&
                 screenX<gameProc.renderer.camera.viewportWidth/2+Assets.creativeInv.getRegionWidth()/2 &&
                 screenY>gameProc.renderer.camera.viewportHeight/2-Assets.creativeInv.getRegionHeight()/2 &&
@@ -117,8 +117,8 @@ public class GameInput {
                 }
                 gameProc.player.inventory[0] = item;
             }
-        } else if (CaveGame.STATE == GameState.GAME_CREATIVE_INV) {
-            CaveGame.STATE = GameState.GAME_PLAY;
+        } else if (CaveGame.STATE == AppState.GAME_CREATIVE_INV) {
+            CaveGame.STATE = AppState.GAME_PLAY;
         } else {
             gameProc.touchDownX = screenX;
             gameProc.touchDownY = screenY;
index a4a6c94f698892faf86e7fd98cd3f30a27e7a088..a2107fa956fd9bc0948d2e02fd0f770b511b1183 100644 (file)
@@ -5,6 +5,7 @@ import com.badlogic.gdx.Input;
 import com.badlogic.gdx.utils.Array;
 import com.badlogic.gdx.utils.TimeUtils;
 import ru.deadsoftware.cavecraft.*;
+import ru.deadsoftware.cavecraft.AppState;
 import ru.deadsoftware.cavecraft.game.mobs.Mob;
 import ru.deadsoftware.cavecraft.game.mobs.Pig;
 import ru.deadsoftware.cavecraft.game.objects.Player;
@@ -121,7 +122,7 @@ public class GameProc {
                     touchDownY< Assets.invBar.getRegionHeight() &&
                     touchDownX>renderer.camera.viewportWidth/2-Assets.invBar.getRegionWidth()/2 &&
                     touchDownX<renderer.camera.viewportWidth/2+Assets.invBar.getRegionWidth()/2) {
-                CaveGame.STATE = GameState.GAME_CREATIVE_INV;
+                CaveGame.STATE = AppState.GAME_CREATIVE_INV;
             }
             isTouchDown = false;
         }
index c8cbc288a252b50adc40841a7761aec2b97deb08..aa2897db09265c1471b64578ba6cf7c4063ee0b7 100644 (file)
@@ -3,6 +3,7 @@ package ru.deadsoftware.cavecraft.menu;
 import com.badlogic.gdx.Gdx;
 import com.badlogic.gdx.utils.Array;
 import ru.deadsoftware.cavecraft.*;
+import ru.deadsoftware.cavecraft.AppState;
 import ru.deadsoftware.cavecraft.menu.objects.Button;
 
 public class MenuRenderer extends Renderer {
@@ -18,7 +19,7 @@ public class MenuRenderer extends Renderer {
 
     public void buttonClicked(Button button) {
         if (button.getLabel().toLowerCase().equals("play")) {
-            CaveGame.STATE = GameState.RESTART;
+            CaveGame.STATE = AppState.GOTO_GAME;
         } else if (button.getLabel().toLowerCase().equals("quit")) {
             Gdx.app.exit();
         }