From: fred-boy Date: Tue, 24 Apr 2018 15:43:12 +0000 (+0700) Subject: Fix bugs X-Git-Tag: alpha0.3~7 X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=0d7e23d2bdd65c0f7510b2db6ee7f4159dd25da6;p=cavedroid.git Fix bugs --- diff --git a/core/src/ru/deadsoftware/cavecraft/AppState.java b/core/src/ru/deadsoftware/cavecraft/AppState.java index 233bbb6..be65138 100644 --- a/core/src/ru/deadsoftware/cavecraft/AppState.java +++ b/core/src/ru/deadsoftware/cavecraft/AppState.java @@ -5,6 +5,10 @@ public enum AppState { GOTO_LOAD_GAME, GOTO_MENU, + NEW_GAME, + LOAD_GAME, + SAVE_GAME, + MENU_MAIN, GAME_PLAY, diff --git a/core/src/ru/deadsoftware/cavecraft/GameScreen.java b/core/src/ru/deadsoftware/cavecraft/GameScreen.java index 682319d..6d4f4d9 100644 --- a/core/src/ru/deadsoftware/cavecraft/GameScreen.java +++ b/core/src/ru/deadsoftware/cavecraft/GameScreen.java @@ -53,24 +53,28 @@ public class GameScreen implements Screen { menu(); break; - case GOTO_NEW_GAME: + case NEW_GAME: gameProc = new GameProc(); renderer = gameProc.renderer; Gdx.input.setInputProcessor(new InputHandlerGame(gameProc)); CaveGame.STATE = AppState.GAME_PLAY; break; - case GOTO_LOAD_GAME:_GAME: + case LOAD_GAME: gameProc = GameSaver.load(); renderer = gameProc.renderer; Gdx.input.setInputProcessor(new InputHandlerGame(gameProc)); CaveGame.STATE = AppState.GAME_PLAY; break; + case SAVE_GAME: + GameSaver.save(gameProc); + CaveGame.STATE = AppState.MENU_MAIN; + break; + case GOTO_MENU: renderer = menuRenderer; Gdx.input.setInputProcessor(new InputHandlerMenu(menuRenderer)); - CaveGame.STATE = AppState.MENU_MAIN; break; } renderer.render(); diff --git a/core/src/ru/deadsoftware/cavecraft/game/GameInput.java b/core/src/ru/deadsoftware/cavecraft/game/GameInput.java index cddeb4d..2ff2fa3 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/GameInput.java +++ b/core/src/ru/deadsoftware/cavecraft/game/GameInput.java @@ -79,12 +79,7 @@ public class GameInput { else CaveGame.STATE = AppState.GAME_PLAY; break; - case Input.Keys.N: - CaveGame.STATE = AppState.GOTO_NEW_GAME; - break; - case Input.Keys.ESCAPE: case Input.Keys.BACK: - GameSaver.save(gameProc); CaveGame.STATE = AppState.GOTO_MENU; break; } diff --git a/core/src/ru/deadsoftware/cavecraft/game/GameSaver.java b/core/src/ru/deadsoftware/cavecraft/game/GameSaver.java index 070b5c2..fccc7bc 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/GameSaver.java +++ b/core/src/ru/deadsoftware/cavecraft/game/GameSaver.java @@ -27,7 +27,7 @@ public class GameSaver { byte[] bytes = ByteBuffer.allocate(4).putInt(i).array(); file.writeBytes(bytes, append); } - + private static void saveMap(FileHandle file, int[][] map) { int rl,bl; int width = map.length; @@ -43,7 +43,6 @@ public class GameSaver { if (x==map.length-1) rl++; writeInt(file, rl, true); writeInt(file, bl, true); - System.out.printf("%d. Run:%d; Block:%s\n",y, rl, Items.BLOCKS.getKeyAt(bl)); rl=0; bl=map[x][y]; } @@ -67,7 +66,6 @@ public class GameSaver { for (int x=0; x0) { @@ -54,15 +48,8 @@ public class MenuRenderer extends Renderer { } } - private void drawGenWorld() { - for (int x=0; x<=getWidth()/16; x++) - for (int y=0; y<=getHeight()/16; y++) { - spriteBatch.draw(Items.BLOCKS.get("dirt").getTexture(), x * 16, y * 16); - spriteBatch.draw(Assets.shade,x*16,y*16); - } - spriteBatch.draw(Assets.gameLogo, getWidth()/2-Assets.gameLogo.getWidth()/2, 0); - drawString("Generating World..."); - spriteBatch.flush(); + public void drawLabel(String str) { + drawString(str); } @Override @@ -77,10 +64,19 @@ public class MenuRenderer extends Renderer { switch (CaveGame.STATE) { case MENU_MAIN: drawMenuMain(); break; + case GOTO_NEW_GAME: case GOTO_LOAD_GAME: drawLabel("Generating World..."); break; + case GOTO_MENU: drawLabel("Saving Game..."); break; } drawString("CaveCraft "+CaveGame.VERSION,0, getHeight()-Assets.getStringHeight("CaveCraft "+CaveGame.VERSION)*1.5f); spriteBatch.end(); + + switch (CaveGame.STATE) { + case GOTO_NEW_GAME: CaveGame.STATE = AppState.NEW_GAME; break; + case GOTO_LOAD_GAME: CaveGame.STATE = AppState.LOAD_GAME; break; + case GOTO_MENU: CaveGame.STATE = AppState.SAVE_GAME; break; + } + } }