X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=core%2Fsrc%2Fru%2Fdeadsoftware%2Fcavecraft%2Fgame%2FGameWorld.java;h=5f5a407d44a68c03e23a7ddeb848c61dd3abb26d;hb=e14d8af238926a5cbfc067cfc9a9b032e51f1cac;hp=e86fb3a5e5a5ecbf0c5b2ada365a7ef61c4aee3f;hpb=9bc9e7fc15cb9c4bdde3c5c7e0c93097c7395d0a;p=cavedroid.git diff --git a/core/src/ru/deadsoftware/cavecraft/game/GameWorld.java b/core/src/ru/deadsoftware/cavecraft/game/GameWorld.java index e86fb3a..5f5a407 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/GameWorld.java +++ b/core/src/ru/deadsoftware/cavecraft/game/GameWorld.java @@ -2,12 +2,13 @@ package ru.deadsoftware.cavecraft.game; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.math.Vector2; -import ru.deadsoftware.cavecraft.Items; +import com.badlogic.gdx.utils.ArrayMap; public class GameWorld { private int WIDTH, HEIGHT; + public ArrayMap metaMap; private int[][] foreMap; private int[][] backMap; @@ -71,6 +72,16 @@ public class GameWorld { } } + 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); @@ -78,7 +89,7 @@ public class GameWorld { } public void placeToBackground(int x, int y, int value) { - if (value==0 || (getBackMap(x,y) == 0 && !Items.BLOCKS.getValueAt(value).foreground)) { + if (value==0 || (getBackMap(x,y) == 0 && !Items.BLOCKS.getValueAt(value).background)) { setBackMap(x,y,value); } } @@ -100,6 +111,7 @@ public class GameWorld { WorldGen.genWorld(WIDTH,HEIGHT); foreMap = WorldGen.getForeMap(); backMap = WorldGen.getBackMap(); + metaMap = new ArrayMap(); WorldGen.clear(); }