From 084218324e5251bde73361f90549563c16026b34 Mon Sep 17 00:00:00 2001 From: fred-boy Date: Fri, 27 Sep 2019 18:15:08 +0700 Subject: [PATCH] Add map on M --- .../ru/deadsoftware/cavedroid/GameScreen.java | 5 ++- .../cavedroid/game/GameInput.java | 4 ++ .../cavedroid/game/GameRenderer.java | 38 ++++++++++++++++++- 3 files changed, 44 insertions(+), 3 deletions(-) diff --git a/core/src/ru/deadsoftware/cavedroid/GameScreen.java b/core/src/ru/deadsoftware/cavedroid/GameScreen.java index 759cbc0..4717818 100644 --- a/core/src/ru/deadsoftware/cavedroid/GameScreen.java +++ b/core/src/ru/deadsoftware/cavedroid/GameScreen.java @@ -12,6 +12,7 @@ public class GameScreen implements Screen { public static int FPS; public static boolean SHOW_DEBUG = true; + public static boolean SHOW_MAP = false; public static int NEW_GAME_MODE = 0; public static GameProc GP; @@ -27,11 +28,11 @@ public class GameScreen implements Screen { Gdx.input.setInputProcessor(new InputHandlerMenu(menuRenderer)); } - public static int getWidth() { + public static float getWidth() { return Gdx.graphics.getWidth(); } - public static int getHeight() { + public static float getHeight() { return Gdx.graphics.getHeight(); } diff --git a/core/src/ru/deadsoftware/cavedroid/game/GameInput.java b/core/src/ru/deadsoftware/cavedroid/game/GameInput.java index 50ad5e4..85d736d 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/GameInput.java +++ b/core/src/ru/deadsoftware/cavedroid/game/GameInput.java @@ -115,6 +115,10 @@ public class GameInput { case Input.Keys.F1: GameScreen.SHOW_DEBUG = !GameScreen.SHOW_DEBUG; break; + + case Input.Keys.M: + GameScreen.SHOW_MAP = !GameScreen.SHOW_MAP; + break; } } diff --git a/core/src/ru/deadsoftware/cavedroid/game/GameRenderer.java b/core/src/ru/deadsoftware/cavedroid/game/GameRenderer.java index a34f0c8..9e54c9a 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/GameRenderer.java +++ b/core/src/ru/deadsoftware/cavedroid/game/GameRenderer.java @@ -1,6 +1,7 @@ package ru.deadsoftware.cavedroid.game; import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.GL20; import com.badlogic.gdx.graphics.glutils.ShapeRenderer; import ru.deadsoftware.cavedroid.CaveGame; @@ -74,7 +75,8 @@ public class GameRenderer extends Renderer { for (int y = minY; y < maxY; y++) { for (int x = minX; x < maxX; x++) { if ((GP.world.getForeMap(x, y) == 0 || GameItems.getBlock(GP.world.getForeMap(x, y)).isTransparent()) - && GP.world.getBackMap(x, y) > 0) shaper.rect(drawX(x), drawY(y), 16, 16); + && GP.world.getBackMap(x, y) > 0) + shaper.rect(drawX(x), drawY(y), 16, 16); } } shaper.end(); @@ -198,6 +200,38 @@ public class GameRenderer extends Renderer { if (CaveGame.TOUCH) drawTouchGui(); + spriter.end(); + + if(GameScreen.SHOW_MAP) { + //DRAW MAP + shaper.begin(ShapeRenderer.ShapeType.Filled); + shaper.setColor(Color.LIGHT_GRAY); + shaper.rect(0, 0, GP.world.getWidth(), 128); + for (int y = 128; y < 256; y++) { + for (int x = 0; x < getWidth(); x++) { + if (GP.world.getForeMap(x, y) > 0 || GP.world.getBackMap(x, y) > 0) { + if (GameItems.isWater(GP.world.getForeMap(x, y))) { + shaper.setColor(Color.BLUE); + } else if (GameItems.isLava(GP.world.getForeMap(x, y))) { + shaper.setColor(Color.RED); + } else { + if (GP.world.getForeMap(x, y) > 0) { + shaper.setColor(Color.BLACK); + } else { + shaper.setColor(Color.DARK_GRAY); + } + } + shaper.rect(x, y - 128, 1, 1); + } + } + } + shaper.setColor(Color.OLIVE); + shaper.rect(GP.player.pos.x / 16, GP.player.pos.y / 16 - 128, 1, 2); + shaper.end(); + //================= + } + spriter.begin(); + if (GameScreen.SHOW_DEBUG) { drawString("FPS: " + GameScreen.FPS, 0, 0); drawString("X: " + (int) (GP.player.pos.x / 16), 0, 10); @@ -210,6 +244,8 @@ public class GameRenderer extends Renderer { drawString("Game mode: " + GP.player.gameMode, 0, 80); } spriter.end(); + + } } -- 2.29.2