From 597ab66d10b43233da31893d0d074485d5aa0bd2 Mon Sep 17 00:00:00 2001 From: fred-boy Date: Wed, 25 Apr 2018 23:04:18 +0700 Subject: [PATCH] Remove meta map Clean up --- android/assets/gamelogo_s.png | Bin 4560 -> 0 bytes .../cavecraft/game/GameInput.java | 7 ++-- .../cavecraft/game/GameRenderer.java | 2 +- .../cavecraft/game/GameSaver.java | 2 - .../cavecraft/game/GameWorld.java | 36 ++++++------------ .../ru/deadsoftware/cavecraft/game/Items.java | 21 ++++++++-- .../deadsoftware/cavecraft/misc/Assets.java | 2 +- 7 files changed, 36 insertions(+), 34 deletions(-) delete mode 100644 android/assets/gamelogo_s.png diff --git a/android/assets/gamelogo_s.png b/android/assets/gamelogo_s.png deleted file mode 100644 index e91b200787669508a43414db0d8272d55379eabf..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4560 zcmXX~1yoeu*L{=>-5`jB3^)SPLpKZ|ARr8(G}0YPN(?0}EnOlobc2d?NH<6~A|MPY zCExq~*SFrg@2+*%x_6!P&OZC>b0f8$E0Yj15CQ-|qN<|!0-Q_0aUXII{5l6Wc7W48 z3pHg$;O@UCueCS{Tp@5(G4uccBC7ue7Lbv39{?y^RTbrQZI=&T`8n!Nf4MvGSsYpR z+po`-a?)`ok}{z>V{}J8x8VQh1}97%NYEcFWTB8FgfMJrC-f51qA4teAou+Nc{w%t zm}I3ShY{1qlo|>|74p9tny_Sq*t{2)wDT3W>Vx&_Hh>;sVjm!&T~p7{<1U&hh`Di;@x zB#+v0)Z60X;*NuZv0|q&qbH&_D@HtYOuoPJU4TtPfO_HJJW&f4nxCKlNn`zPizJ!T zML07dJ>5`1Kp>F_AdM*OKD;PwYg-u;ja4Z;Bw+0y7~rI5Vj95<+TY)&%pJv#?>GB@`!DKCLF6US4%#rP97}5Y`V+f;HEVYtU1!M&JXM z!H~5_;-kyUO9oAw*Lh-MVu0D&Vhh6MgK#DZiiL$TvKlY40Fv}0)PVc5Y4trdYDBC> zWK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jJ!gTkJOmTaGdtqc- zQBn(flofMbRe$Fnk(*f=;0zQcnTbtM6HKm|p(U48M|8}KHoVXqWCzT*GOEJgHBRyG znYM^cnBl#7kWR{FTaAgk3*Px$Xv!z&Db6hsGzK-$`Tw1h=6J;~@{7OPUWHtHftMV2 cUVVXB_EkZWc^yvQ!3!Bc74clLQr-;pf9mbQVgLXD diff --git a/core/src/ru/deadsoftware/cavecraft/game/GameInput.java b/core/src/ru/deadsoftware/cavecraft/game/GameInput.java index e177f40..2e54ad3 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/GameInput.java +++ b/core/src/ru/deadsoftware/cavecraft/game/GameInput.java @@ -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) { diff --git a/core/src/ru/deadsoftware/cavecraft/game/GameRenderer.java b/core/src/ru/deadsoftware/cavecraft/game/GameRenderer.java index 38c79f1..7ab146b 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/GameRenderer.java +++ b/core/src/ru/deadsoftware/cavecraft/game/GameRenderer.java @@ -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(); gameProc.physics = new GamePhysics(gameProc); gameProc.resetRenderer(); } catch (Exception e) { diff --git a/core/src/ru/deadsoftware/cavecraft/game/GameWorld.java b/core/src/ru/deadsoftware/cavecraft/game/GameWorld.java index 5f5a407..4a14c71 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/GameWorld.java +++ b/core/src/ru/deadsoftware/cavecraft/game/GameWorld.java @@ -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 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(); WorldGen.clear(); } diff --git a/core/src/ru/deadsoftware/cavecraft/game/Items.java b/core/src/ru/deadsoftware/cavecraft/game/Items.java index 93b9a1f..6d49b5d 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/Items.java +++ b/core/src/ru/deadsoftware/cavecraft/game/Items.java @@ -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() { diff --git a/core/src/ru/deadsoftware/cavecraft/misc/Assets.java b/core/src/ru/deadsoftware/cavecraft/misc/Assets.java index 28f3508..87e04af 100644 --- a/core/src/ru/deadsoftware/cavecraft/misc/Assets.java +++ b/core/src/ru/deadsoftware/cavecraft/misc/Assets.java @@ -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; -- 2.29.2