From: fred-boy Date: Sun, 30 Sep 2018 16:51:44 +0000 (+0700) Subject: Start making survival mode X-Git-Tag: alpha0.4~76 X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=e31e819b4fc6afdc3612e0ada5066dab638e89ac;p=cavedroid.git Start making survival mode --- diff --git a/core/src/ru/deadsoftware/cavecraft/GameScreen.java b/core/src/ru/deadsoftware/cavecraft/GameScreen.java index 545ee3f..c77c9e0 100644 --- a/core/src/ru/deadsoftware/cavecraft/GameScreen.java +++ b/core/src/ru/deadsoftware/cavecraft/GameScreen.java @@ -12,6 +12,7 @@ public class GameScreen implements Screen { public static int FPS; public static boolean SHOW_DEBUG = false; + public static int NEW_GAME_MODE = 0; private GameProc gp; private Renderer renderer; @@ -58,7 +59,7 @@ public class GameScreen implements Screen { break; case NEW_GAME: - gp = new GameProc(); + gp = new GameProc(NEW_GAME_MODE); renderer = gp.renderer; Gdx.input.setInputProcessor(new InputHandlerGame(gp)); CaveGame.STATE = AppState.GAME_PLAY; @@ -89,6 +90,7 @@ public class GameScreen implements Screen { public void resize(int width, int height) { switch (CaveGame.STATE) { case MENU_MAIN: + menuRenderer = new MenuRenderer(CaveGame.TOUCH ? 320 : 480); renderer = menuRenderer; break; diff --git a/core/src/ru/deadsoftware/cavecraft/game/GameInput.java b/core/src/ru/deadsoftware/cavecraft/game/GameInput.java index 48388ac..687c6a9 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/GameInput.java +++ b/core/src/ru/deadsoftware/cavecraft/game/GameInput.java @@ -73,10 +73,10 @@ public class GameInput { gp.swim = true; } else if (gp.player.canJump) { gp.player.move.add(0, -7); - } else if (!gp.player.flyMode) { + } else if (!gp.player.flyMode && gp.player.gameMode == 1) { gp.player.flyMode = true; gp.player.move.y = 0; - } else { + } else if (gp.player.flyMode) { gp.player.move.y = -GamePhysics.PL_SPEED; } break; @@ -86,7 +86,14 @@ public class GameInput { break; case Input.Keys.E: - if (CaveGame.STATE == AppState.GAME_PLAY) CaveGame.STATE = AppState.GAME_CREATIVE_INV; + if (CaveGame.STATE == AppState.GAME_PLAY) switch (gp.player.gameMode) { + case 0: + //TODO survival inv + break; + case 1: + CaveGame.STATE = AppState.GAME_CREATIVE_INV; + break; + } else CaveGame.STATE = AppState.GAME_PLAY; break; diff --git a/core/src/ru/deadsoftware/cavecraft/game/GameProc.java b/core/src/ru/deadsoftware/cavecraft/game/GameProc.java index 14b7015..da02862 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/GameProc.java +++ b/core/src/ru/deadsoftware/cavecraft/game/GameProc.java @@ -44,10 +44,10 @@ public class GameProc implements Serializable { public int touchDownBtn; public long touchDownTime; - public GameProc() { + public GameProc(int gameMode) { world = new GameWorld(); world.generate(1024, 256); - player = new Player(world.getSpawnPoint()); + player = new Player(world.getSpawnPoint(), gameMode); drops = new ArrayList(); mobs = new ArrayList(); for (int i = 0; i < 16; i++) { @@ -411,17 +411,23 @@ public class GameProc implements Serializable { if (isTouchDown && touchDownBtn == Input.Buttons.LEFT) { if ((world.getForeMap(curX, curY) > 0 && GameItems.getBlock(world.getForeMap(curX, curY)).getHp() >= 0) || world.getBackMap(curX, curY) > 0 && GameItems.getBlock(world.getBackMap(curX, curY)).getHp() >= 0) { - blockDmg++; - if (world.getForeMap(curX, curY) > 0) { - if (blockDmg >= GameItems.getBlock(world.getForeMap(curX, curY)).getHp()) { - world.destroyForeMap(curX, curY, this); - blockDmg = 0; - } - } else if (world.getBackMap(curX, curY) > 0) { - if (blockDmg >= GameItems.getBlock(world.getBackMap(curX, curY)).getHp()) { - world.destroyBackMap(curX, curY, this); - blockDmg = 0; + if (player.gameMode == 0) { + blockDmg++; + if (world.getForeMap(curX, curY) > 0) { + if (blockDmg >= GameItems.getBlock(world.getForeMap(curX, curY)).getHp()) { + world.destroyForeMap(curX, curY, this); + blockDmg = 0; + } + } else if (world.getBackMap(curX, curY) > 0) { + if (blockDmg >= GameItems.getBlock(world.getBackMap(curX, curY)).getHp()) { + world.destroyBackMap(curX, curY, this); + blockDmg = 0; + } } + } else { + if (world.getForeMap(curX, curY) > 0) world.setForeMap(curX, curY, 0); + else if (world.getBackMap(curX, curY) > 0) world.setBackMap(curX, curY, 0); + isTouchDown = false; } } } diff --git a/core/src/ru/deadsoftware/cavecraft/game/GameRenderer.java b/core/src/ru/deadsoftware/cavecraft/game/GameRenderer.java index 162c77b..5560bf6 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/GameRenderer.java +++ b/core/src/ru/deadsoftware/cavecraft/game/GameRenderer.java @@ -295,6 +295,7 @@ public class GameRenderer extends Renderer { drawString("Mobs: " + gp.mobs.size(), 0, 30); drawString("Drops: " + gp.drops.size(), 0, 40); drawString("Block: " + GameItems.getBlockKey(gp.world.getForeMap(gp.curX, gp.curY)), 0, 50); + drawString("Game mode: " + gp.player.gameMode, 0, 60); } spriter.end(); } diff --git a/core/src/ru/deadsoftware/cavecraft/game/objects/Player.java b/core/src/ru/deadsoftware/cavecraft/game/objects/Player.java index 74f7249..4c7d962 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/objects/Player.java +++ b/core/src/ru/deadsoftware/cavecraft/game/objects/Player.java @@ -15,8 +15,10 @@ public class Player implements Serializable { public boolean canJump; public int[] inv; public boolean flyMode = false; + public int gameMode; - public Player(Vector2 spawnPoint) { + public Player(Vector2 spawnPoint, int gameMode) { + this.gameMode = gameMode; pos = spawnPoint.cpy(); move = new Vector2(0, 0); width = 4; diff --git a/core/src/ru/deadsoftware/cavecraft/menu/MenuRenderer.java b/core/src/ru/deadsoftware/cavecraft/menu/MenuRenderer.java index aab04d9..8aaab64 100644 --- a/core/src/ru/deadsoftware/cavecraft/menu/MenuRenderer.java +++ b/core/src/ru/deadsoftware/cavecraft/menu/MenuRenderer.java @@ -14,22 +14,38 @@ import ru.deadsoftware.cavecraft.misc.Renderer; public class MenuRenderer extends Renderer { public Array