DEADSOFTWARE

Add map on M
authorfred-boy <fredboy@protonmail.com>
Fri, 27 Sep 2019 11:15:08 +0000 (18:15 +0700)
committerfred-boy <fredboy@protonmail.com>
Sun, 29 Sep 2019 04:39:17 +0000 (11:39 +0700)
core/src/ru/deadsoftware/cavedroid/GameScreen.java
core/src/ru/deadsoftware/cavedroid/game/GameInput.java
core/src/ru/deadsoftware/cavedroid/game/GameRenderer.java

index 759cbc0db800c5e8467ad7b18f59578c34565ed0..4717818a46d3f008f2c8383f20350bcce9ac34b4 100644 (file)
@@ -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();
     }
 
index 50ad5e4bf3b8dc34e7b763e3f79d61e64ee75bf0..85d736dd4cd99c1e21d8b3cf7fa0231b6066aa6c 100644 (file)
@@ -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;
         }
     }
 
index a34f0c871e5ba786f71d25598998cf6de00d5d6d..9e54c9a5a74a54f4932f609124bc89088740acfe 100644 (file)
@@ -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();
+
+
     }
 
 }