From: fred-boy Date: Wed, 25 Apr 2018 13:05:48 +0000 (+0700) Subject: Add meta map X-Git-Tag: alpha0.4~100 X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=cdffa6e04f07103d94e904b82c4a32361e35b370;p=cavedroid.git Add meta map --- diff --git a/core/src/ru/deadsoftware/cavecraft/game/GameWorld.java b/core/src/ru/deadsoftware/cavecraft/game/GameWorld.java index 0c3ac52..fc0c247 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/GameWorld.java +++ b/core/src/ru/deadsoftware/cavecraft/game/GameWorld.java @@ -2,11 +2,13 @@ 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; + private ArrayMap metaMap; private int[][] foreMap; private int[][] backMap; @@ -70,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); @@ -99,6 +111,7 @@ public class GameWorld { WorldGen.genWorld(WIDTH,HEIGHT); foreMap = WorldGen.getForeMap(); backMap = WorldGen.getBackMap(); + metaMap = new ArrayMap(); WorldGen.clear(); }