DEADSOFTWARE

Remove meta map
authorfred-boy <fred-boy@protonmail.com>
Wed, 25 Apr 2018 16:04:18 +0000 (23:04 +0700)
committerfred-boy <fred-boy@protonmail.com>
Wed, 25 Apr 2018 16:04:18 +0000 (23:04 +0700)
Clean up

android/assets/gamelogo_s.png [deleted file]
core/src/ru/deadsoftware/cavecraft/game/GameInput.java
core/src/ru/deadsoftware/cavecraft/game/GameRenderer.java
core/src/ru/deadsoftware/cavecraft/game/GameSaver.java
core/src/ru/deadsoftware/cavecraft/game/GameWorld.java
core/src/ru/deadsoftware/cavecraft/game/Items.java
core/src/ru/deadsoftware/cavecraft/misc/Assets.java

diff --git a/android/assets/gamelogo_s.png b/android/assets/gamelogo_s.png
deleted file mode 100644 (file)
index e91b200..0000000
Binary files a/android/assets/gamelogo_s.png and /dev/null differ
index e177f40cf043e410458884c8b316650f99a56638..2e54ad3ee1f29f921b34331a45593ce4255f82cd 100644 (file)
@@ -121,12 +121,13 @@ public class GameInput {
             }
         } else if (CaveGame.STATE == AppState.GAME_CREATIVE_INV) {
             CaveGame.STATE = AppState.GAME_PLAY;
+        } else {
+            gameProc.touchDownTime = TimeUtils.millis();
+            gameProc.isTouchDown = true;
+            gameProc.touchDownButton = button;
         }
         gameProc.touchDownX = screenX;
         gameProc.touchDownY = screenY;
-        gameProc.touchDownTime = TimeUtils.millis();
-        gameProc.isTouchDown = true;
-        gameProc.touchDownButton = button;
     }
 
     public void touchUp(int screenX, int screenY, int button) {
index 38c79f1641b3e335ab2838ba80a873d58998fa03..7ab146b7235c7342b0a61b56e6bd2b98e4218a9d 100644 (file)
@@ -121,7 +121,7 @@ public class GameRenderer extends Renderer {
         float y = camera.viewportHeight/2-Assets.creativeInv.getRegionHeight()/2;
         spriteBatch.draw(Assets.creativeInv, x, y);
         spriteBatch.draw(Assets.creativeScroll, x+156,
-                y+18+(gameProc.creativeScroll*(72/(gameProc.maxCreativeScroll+1))));
+                y+18+(gameProc.creativeScroll*(72/gameProc.maxCreativeScroll)));
         for (int i=gameProc.creativeScroll*40; i<(gameProc.creativeScroll+1)*40; i++) {
             if (i>0 && i<Items.BLOCKS.size)
                 spriteBatch.draw(Assets.blockTextures[Items.BLOCKS.getValueAt(i).getTexture()],
index 2b5b906d877a3dadcd77baca27e1e346d8eeeff1..aab81f54ecb26d101c315e0fbe8c98bd4dab1e8f 100644 (file)
@@ -2,7 +2,6 @@ package ru.deadsoftware.cavecraft.game;
 
 import com.badlogic.gdx.Gdx;
 import com.badlogic.gdx.files.FileHandle;
-import com.badlogic.gdx.utils.ArrayMap;
 import ru.deadsoftware.cavecraft.CaveGame;
 
 import java.io.*;
@@ -79,7 +78,6 @@ public class GameSaver {
                     loadMap(Gdx.files.absolute(CaveGame.GAME_FOLDER + "/saves/foremap.sav")),
                     loadMap(Gdx.files.absolute(CaveGame.GAME_FOLDER + "/saves/backmap.sav"))
             );
-            gameProc.world.metaMap = new ArrayMap<String, Integer>();
             gameProc.physics = new GamePhysics(gameProc);
             gameProc.resetRenderer();
         } catch (Exception e) {
index 5f5a407d44a68c03e23a7ddeb848c61dd3abb26d..4a14c7123f7935203a6206f9ff5559475a20e862 100644 (file)
@@ -2,13 +2,10 @@ package ru.deadsoftware.cavecraft.game;
 
 import com.badlogic.gdx.Gdx;
 import com.badlogic.gdx.math.Vector2;
-import com.badlogic.gdx.utils.ArrayMap;
 
 public class GameWorld {
 
     private int WIDTH, HEIGHT;
-
-    public ArrayMap<String, Integer> metaMap;
     private int[][] foreMap;
     private int[][] backMap;
 
@@ -28,11 +25,16 @@ public class GameWorld {
         return backMap;
     }
 
+    private int transformX(int x) {
+        x = x%getWidth();
+        if (x<0) x=getWidth()-Math.abs(x);
+        return x;
+    }
+
     public int getForeMap(int x, int y) {
         int map = 0;
         try {
-            x = x%getWidth();
-            if (x<0) x=getWidth()-Math.abs(x);
+            x = transformX(x);
             map = foreMap[x][y];
         } catch (ArrayIndexOutOfBoundsException e) {
             Gdx.app.error("GameWorld",e.toString());
@@ -42,8 +44,7 @@ public class GameWorld {
 
     public void setForeMap(int x, int y, int value) {
         try {
-            x = x%getWidth();
-            if (x<0) x=getWidth()-Math.abs(x);
+            x = transformX(x);
             foreMap[x][y] = value;
         } catch (ArrayIndexOutOfBoundsException e) {
             Gdx.app.error("GameWorld", e.toString());
@@ -53,8 +54,7 @@ public class GameWorld {
     public int getBackMap(int x, int y) {
         int map = 0;
         try {
-            x = x%getWidth();
-            if (x<0) x=getWidth()-Math.abs(x);
+            x = transformX(x);
             map = backMap[x][y];
         } catch (ArrayIndexOutOfBoundsException e) {
             Gdx.app.error("GameWorld",e.toString());
@@ -64,32 +64,21 @@ public class GameWorld {
 
     public void setBackMap(int x, int y, int value) {
         try {
-            x = x%getWidth();
-            if (x<0) x=getWidth()-Math.abs(x);
+            x = transformX(x);
             backMap[x][y] = value;
         } catch (ArrayIndexOutOfBoundsException e) {
             Gdx.app.error("GameWorld", e.toString());
         }
     }
 
-    public int getMeta(int x, int y) {
-        if (metaMap.containsKey(x+"_"+y)) return metaMap.get(x+"_"+y);
-            else return 0;
-    }
-
-    public void setMeta(int x, int y, int value) {
-        if (metaMap.containsKey(x+"_"+y)) metaMap.removeKey(x+"_"+y);
-        metaMap.put(x+"_"+y, value);
-    }
-
     public void placeToForeground(int x, int y, int value) {
         if (getForeMap(x,y) == 0 || value == 0) {
-            setForeMap(x,y,value);
+            setForeMap(x, y, value);
         }
     }
 
     public void placeToBackground(int x, int y, int value) {
-        if (value==0 || (getBackMap(x,y) == 0 && !Items.BLOCKS.getValueAt(value).background)) {
+        if (value==0 || (getBackMap(x,y) == 0 && Items.BLOCKS.getValueAt(value).collision)) {
             setBackMap(x,y,value);
         }
     }
@@ -111,7 +100,6 @@ public class GameWorld {
         WorldGen.genWorld(WIDTH,HEIGHT);
         foreMap = WorldGen.getForeMap();
         backMap = WorldGen.getBackMap();
-        metaMap = new ArrayMap<String, Integer>();
         WorldGen.clear();
     }
 
index 93b9a1f8ee1bb03b62646ef09912a960e58cd954..6d49b5d16f655d1bf8c37ca574fb3c6628715077 100644 (file)
@@ -2,7 +2,6 @@ package ru.deadsoftware.cavecraft.game;
 
 import com.badlogic.gdx.utils.ArrayMap;
 import ru.deadsoftware.cavecraft.game.objects.Block;
-import ru.deadsoftware.cavecraft.misc.Assets;
 
 public class Items {
 
@@ -32,7 +31,8 @@ public class Items {
         BLOCKS.put("lapis_block", new Block(19));
         BLOCKS.put("sandstone", new Block(20));
         BLOCKS.put("noteblock", new Block(21));
-        BLOCKS.put("bed", new Block(0,8,16,8,22,false,true,true));
+        BLOCKS.put("bed_l", new Block(22,false,true,true));
+        BLOCKS.put("bed_r", new Block(23, false,true, true));
         BLOCKS.put("cobweb", new Block(24,false,false,true));
         BLOCKS.put("tallgrass", new Block(25,false,false,true));
         BLOCKS.put("deadbush", new Block(26,false,false,true));
@@ -41,7 +41,22 @@ public class Items {
         BLOCKS.put("rose", new Block(29,false,false,true));
         BLOCKS.put("brown_mushroom", new Block(30,false,false,true));
         BLOCKS.put("red_mushroom", new Block(31,false,false,true));
-        BLOCKS.put("wool", new Block(32,false,true,false));
+        BLOCKS.put("wool_while", new Block(32,true,false,false));
+        BLOCKS.put("wool_orange", new Block(33,true,false,false));
+        BLOCKS.put("wool_magenta", new Block(34,true,false,false));
+        BLOCKS.put("wool_lightblue", new Block(35,true,false,false));
+        BLOCKS.put("wool_yellow", new Block(36,true,false,false));
+        BLOCKS.put("wool_lime", new Block(37,true,false,false));
+        BLOCKS.put("wool_pink", new Block(38,true,false,false));
+        BLOCKS.put("wool_gray", new Block(39,true,false,false));
+        BLOCKS.put("wool_lightgray", new Block(40,true,false,false));
+        BLOCKS.put("wool_cyan", new Block(41,true,false,false));
+        BLOCKS.put("wool_purple", new Block(42,true,false,false));
+        BLOCKS.put("wool_blue", new Block(43,true,false,false));
+        BLOCKS.put("wool_brown", new Block(44,true,false,false));
+        BLOCKS.put("wool_green", new Block(45,true,false,false));
+        BLOCKS.put("wool_red", new Block(46,true,false,false));
+        BLOCKS.put("wool_black", new Block(47,true,false,false));
     }
 
     public static void load() {
index 28f3508d8172b12110ddd5ca6972d9bf2e65e6bd..87e04af1f6eb5c6ed8521b21b1fca78fc86982e0 100644 (file)
@@ -10,7 +10,7 @@ import ru.deadsoftware.cavecraft.CaveGame;
 
 public class Assets {
 
-    public static final int BLOCK_TEXTURES = 47;
+    public static final int BLOCK_TEXTURES = 48;
 
     private static GlyphLayout layout;