From e711e124ce781eec6ff0bca5a1fec6d5408e561c Mon Sep 17 00:00:00 2001 From: Dennis Postma Date: Tue, 5 Nov 2024 21:31:28 +0100 Subject: [PATCH] Map editor tiles improvement --- .../zoneEditor/zonePartials/ZoneTiles.vue | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/components/gameMaster/zoneEditor/zonePartials/ZoneTiles.vue b/src/components/gameMaster/zoneEditor/zonePartials/ZoneTiles.vue index 548c867..d2dbf34 100644 --- a/src/components/gameMaster/zoneEditor/zonePartials/ZoneTiles.vue +++ b/src/components/gameMaster/zoneEditor/zonePartials/ZoneTiles.vue @@ -192,14 +192,17 @@ onMounted(() => { return } - // First fill the entire map with blank tiles - const blankTiles = createTileArray(tileMap.width, tileMap.height, 'blank_tile') + // First fill the entire map with blank tiles using current zone dimensions + const blankTiles = createTileArray(zoneEditorStore.zone.width, zoneEditorStore.zone.height, 'blank_tile') - // Then overlay the zone tiles on top + // Then overlay the zone tiles, but only within the current zone dimensions const zoneTiles = zoneEditorStore.zone.tiles - for (let y = 0; y < zoneTiles.length; y++) { - for (let x = 0; x < zoneTiles[y].length; x++) { - blankTiles[y][x] = zoneTiles[y][x] + for (let y = 0; y < zoneEditorStore.zone.height; y++) { + for (let x = 0; x < zoneEditorStore.zone.width; x++) { + // Only copy if the source tiles array has this position + if (zoneTiles[y] && zoneTiles[y][x] !== undefined) { + blankTiles[y][x] = zoneTiles[y][x] + } } }