Map editor tiles improvement

This commit is contained in:
Dennis Postma 2024-11-05 21:31:28 +01:00
parent e1b39c42ec
commit e711e124ce

View File

@ -192,14 +192,17 @@ onMounted(() => {
return return
} }
// First fill the entire map with blank tiles // First fill the entire map with blank tiles using current zone dimensions
const blankTiles = createTileArray(tileMap.width, tileMap.height, 'blank_tile') 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 const zoneTiles = zoneEditorStore.zone.tiles
for (let y = 0; y < zoneTiles.length; y++) { for (let y = 0; y < zoneEditorStore.zone.height; y++) {
for (let x = 0; x < zoneTiles[y].length; x++) { for (let x = 0; x < zoneEditorStore.zone.width; x++) {
blankTiles[y][x] = zoneTiles[y][x] // Only copy if the source tiles array has this position
if (zoneTiles[y] && zoneTiles[y][x] !== undefined) {
blankTiles[y][x] = zoneTiles[y][x]
}
} }
} }