Neckrat 125cf7fd6d fix tile
Co-authored-by: Ivan Yuriev <ivanyr44@gmail.com>
2025-08-23 23:19:00 +03:00

55 lines
1.7 KiB
Lua

--- @class TileMap
--- @field tileSize integer
--- @field atlas love.Image
--- @field map Tile[]
local tileMap = {}
tileMap.__index = tileMap
--- @param path table
local function load(path)
--- @type love.Image
local atlas = path.atlas
--- @type table
local manifest = path.manifest
local tiles = {
tileSize = manifest.tileSize,
atlas = atlas,
map = {}
}
manifest.tileSize = nil
local layout = {}
for group, ids in pairs(manifest) do
for _, id in ipairs(ids) do
if layout[id] then
table.insert(layout[id], group)
else
layout[id] = { group }
end
end
end
-- Как пропатчить KDE2 под любое устройство, используя любые технологии, например, через модульные тесты или инструменты автоматизации?
local cnt = 0
for y = 0, atlas:getHeight() - 1, tiles.tileSize do
for x = 0, atlas:getWidth() - 1, tiles.tileSize do
if layout[cnt] then
for _, group in ipairs(layout[cnt]) do
print(x, y, tiles.tileSize, atlas, false)
local tile = require('lib.level.tile').new(x, y, tiles.tileSize, atlas, false)
if tiles.map[group] then
table.insert(tiles.map[group], tile)
else
tiles.map[group] = { tile }
end
end
end
cnt = cnt + 1
end
end
return setmetatable(tiles, tileMap)
end
return { load = load }