aboutsummaryrefslogtreecommitdiff
path: root/client/map/kitchen_background.gd
diff options
context:
space:
mode:
Diffstat (limited to 'client/map/kitchen_background.gd')
-rw-r--r--client/map/kitchen_background.gd25
1 files changed, 13 insertions, 12 deletions
diff --git a/client/map/kitchen_background.gd b/client/map/kitchen_background.gd
index 4b728a94..a638ad5f 100644
--- a/client/map/kitchen_background.gd
+++ b/client/map/kitchen_background.gd
@@ -22,13 +22,13 @@ func _ready() -> void:
func init_map():
var map_tile = func (t): match t:
- ".": return "floor"
- "=": return "counter"
- "s": return "stove"
- "c": return "chair"
- "t": return "table"
- "o": return "oven"
- "#": return "wall"
+ ".": return ["floor"]
+ "=": return ["counter"]
+ "s": return ["stove"]
+ "c": return ["chair"]
+ "t": return ["table"]
+ "o": return ["oven"]
+ "#": return ["wall"]
_: push_error("unknown tile: ", t)
var tiles = [
"...............",
@@ -39,9 +39,10 @@ func init_map():
".............=#",
".............=#"
].map(func (l): return Array(l.split("")).map(map_tile))
- var gt = func (e): return null if e[1] >= tiles.size() else null if e[0] >= tiles[e[1]].size() else tiles[e[1]][e[0]]
- var co = Vector2i(floor(tiles[0].size() / 2), floor(tiles.size() - 2))
- for y in tiles.size():
- for x in tiles[y].size():
- map.set_tile(Vector2i(x,y) - co, gt.call([x,y]), [[x,y-1],[x-1,y],[x,y+1],[x+1,y]].map(gt))
+ var offset = Vector2i(floor(tiles[0].size() / 2), floor(tiles.size() - 2))
+ var pos_to_tile: Dictionary[Vector2i, Array] = {} # : Dictionary[Vector2i, Array[String]]
+ for y in range(tiles.size()):
+ for x in range(tiles[y].size()):
+ pos_to_tile[Vector2i(x,y) - offset] = tiles[y][x]
+ map.set_all_tiles(pos_to_tile)
map.flush()