From 70a616b4a7a4a07b3bb41f0b906ad81ef93f96dc Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Wed, 31 Oct 2018 00:18:29 +0100 Subject: view/MapView: add support for multiple layers and holes --- src/view/MapView.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/view/MapView.ts b/src/view/MapView.ts index 5c30f20..f6736e2 100644 --- a/src/view/MapView.ts +++ b/src/view/MapView.ts @@ -20,7 +20,8 @@ export default class MapView { for (let x = 0; x < map.data.width; x++) for (let y = 0; y < map.data.height; y++) - this.addTile(vertexData, textureData, x, y, map.data.layers[0][y][x]); + for (const layer of map.data.layers) + this.addTile(vertexData, textureData, x, y, layer[y][x]); const gl = r.getContext(); @@ -64,6 +65,9 @@ export default class MapView { } private addTile(vertexData: number[], textureData: number[], x: number, y: number, tile: string) { + if (tile === ' ') + return; + const tilePos = this.tileMap.tiles.get(tile); if (!tilePos) throw new Error('invalid tile specifier in map data'); -- cgit v1.2.3