Rename tileMap to spriteAtlas and update references accordingly

This commit is contained in:
PeaAshMeter 2025-10-26 02:01:45 +03:00
parent 2fc1a92ad1
commit aec916cd14
2 changed files with 13 additions and 13 deletions

View File

@ -5,7 +5,7 @@ local function new(template, size)
local map = {}
-- паттерн-матчинг для самых маленьких
if template == "flower_plains" then
local tileMap = require("lib.level.tileMap").load(Tree.assets.files.tiles.grass)
local tileMap = require("lib.utils.sprite_atlas").load(Tree.assets.files.tiles.grass)
for y = 0, size.y - 1 do
for x = 0, size.x - 1 do
local type = tileMap.map["flower_grass"]

View File

@ -1,9 +1,9 @@
--- @class TileMap
--- @class SpriteAtlas
--- @field tileSize integer
--- @field atlas love.Image
--- @field map table<string, love.Quad>
local tileMap = {}
tileMap.__index = tileMap
local spriteAtlas = {}
spriteAtlas.__index = spriteAtlas
--- @param path table
local function load(path)
@ -12,7 +12,7 @@ local function load(path)
--- @type table
local manifest = path.manifest
local _tileMap = {
local _spriteAtlas = {
tileSize = manifest.tileSize,
atlas = atlas,
map = {}
@ -31,17 +31,17 @@ local function load(path)
end
local cnt = 0
for y = 0, atlas:getHeight() - 1, _tileMap.tileSize do
for x = 0, atlas:getWidth() - 1, _tileMap.tileSize do
for y = 0, atlas:getHeight() - 1, _spriteAtlas.tileSize do
for x = 0, atlas:getWidth() - 1, _spriteAtlas.tileSize do
if layout[cnt] then
for _, group in ipairs(layout[cnt]) do
print(x, y, _tileMap.tileSize, atlas, false)
local quad = love.graphics.newQuad(x, y, _tileMap.tileSize, _tileMap.tileSize, atlas)
print(x, y, _spriteAtlas.tileSize, atlas, false)
local quad = love.graphics.newQuad(x, y, _spriteAtlas.tileSize, _spriteAtlas.tileSize, atlas)
if _tileMap.map[group] then
table.insert(_tileMap.map[group], quad)
if _spriteAtlas.map[group] then
table.insert(_spriteAtlas.map[group], quad)
else
_tileMap.map[group] = { quad }
_spriteAtlas.map[group] = { quad }
end
end
end
@ -49,7 +49,7 @@ local function load(path)
end
end
return setmetatable(_tileMap, tileMap)
return setmetatable(_spriteAtlas, spriteAtlas)
end
return { load = load }