Welcome! Share code as fast as possible.

local Assets = {
	screen = {
		x = 0,
		y = 0,
		width = 600,
		height = 600
	}
}

-- Removes .png from the filename
local function removePNG(filename)
	return filename:gsub("%.png$", "")
end

-- Load sprites from folders inside 'Sprites'
local function loadSprites()
	local spriteRoot = "Sprites"
	if not love.filesystem.getInfo(spriteRoot) then
		error("Missing 'Sprites' directory.")
	end

	local categories = love.filesystem.getDirectoryItems(spriteRoot)
	for _, category in ipairs(categories) do
		local categoryPath = spriteRoot .. "/" .. category
		local info = love.filesystem.getInfo(categoryPath)
		if info and info.type == "directory" then
			Assets[category] = {}
			local files = love.filesystem.getDirectoryItems(categoryPath)
			for _, file in ipairs(files) do
				if file:match("%.png$") then
					local path = categoryPath .. "/" .. file
					local sprite = love.graphics.newImage(path)
					local assetName = removePNG(file)
					Assets[category][assetName] = {
						sprite = sprite,
						width = sprite:getWidth(),
						height = sprite:getHeight(),
						name = assetName
					}
				end
			end
		end
	end
end

loadSprites()
return Assets