Update lib/tilesheet.lua

This commit is contained in:
tangent committed 2026-10-29 18:13:08 -06:00
1 parent 3cf682ba71
commit 65ccd0e0db
1 file changed
+16
+16
View File
@@ -36,10 +36,26 @@ local tilesheet.load = function(data_or_path)
tile_image = load_image(data_or_path)
end
-- this mess feels kinda wasteful/repetitive
local image_width, image_height = tile_image:getDimensions()
local tile_usage = {}
for x = 1, image_width / tile_size do
tile_usage[x] = {}
for y = 1, image_height / tile_size do
tile_usage[x][y] = false
end
end
if type(data_or_path) == "table" then
for name, tile_data in pairs(data_or_path.tiles) do
tile_usage[tile_data.x][tile_data.y] = true
end
end
tilesheet.active_sheet = {
image = tile_image,
size = tile_size,
tiles = tiles,
tile_usage = tile_usage,
}
return tiles