From 1958f724d1c0c14273167f68f5d479f796370fc2 Mon Sep 17 00:00:00 2001 From: Sem van der Hoeven Date: Fri, 15 May 2020 19:12:56 +0200 Subject: [PATCH] add begin of map class --- core/src/netwerkprog/game/client/Map.java | 31 +++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/core/src/netwerkprog/game/client/Map.java b/core/src/netwerkprog/game/client/Map.java index 509aae1..672034a 100644 --- a/core/src/netwerkprog/game/client/Map.java +++ b/core/src/netwerkprog/game/client/Map.java @@ -1,4 +1,35 @@ package netwerkprog.game.client; public class Map { + private char[][] map; + + public Map(int size) { + this(size,size); + } + + public Map(int width, int height) { + this.map = new char[height][width]; + } + + public char get(int x, int y) { + return this.map[y][x]; + } + + /** + * gets the height of this map + * @return -1 if the map is null or is empty, otherwise the height. + */ + public int getHeight() { + return this.map == null || this.map.length == 0 ? -1 : this.map.length; + } + + /** + * gets the width of this map + * @return -1 if the map is null or is empty, otherwise the width + */ + public int getWidth() { + return this.map == null || this.map.length == 0 ? -1 : this.map[0].length; + } + + }