From aec916cd141b0199a775b600964040544f437b6e Mon Sep 17 00:00:00 2001 From: PeaAshMeter Date: Sun, 26 Oct 2025 02:01:45 +0300 Subject: [PATCH] Rename tileMap to spriteAtlas and update references accordingly --- lib/level/procedural.lua | 2 +- .../tileMap.lua => utils/sprite_atlas.lua} | 24 +++++++++---------- 2 files changed, 13 insertions(+), 13 deletions(-) rename lib/{level/tileMap.lua => utils/sprite_atlas.lua} (58%) diff --git a/lib/level/procedural.lua b/lib/level/procedural.lua index e20a3b6..0722ca1 100644 --- a/lib/level/procedural.lua +++ b/lib/level/procedural.lua @@ -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"] diff --git a/lib/level/tileMap.lua b/lib/utils/sprite_atlas.lua similarity index 58% rename from lib/level/tileMap.lua rename to lib/utils/sprite_atlas.lua index bdc7f01..c51ae5c 100644 --- a/lib/level/tileMap.lua +++ b/lib/utils/sprite_atlas.lua @@ -1,9 +1,9 @@ ---- @class TileMap +--- @class SpriteAtlas --- @field tileSize integer --- @field atlas love.Image --- @field map table -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 }