aboutsummaryrefslogtreecommitdiff
path: root/src/textures.lua
blob: 5a3a4f99eb4c0430ff8bdd56aee636ee766932b2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
require "string"
local img_bank = {}

local lf = love.filesystem
function load_textures_from(path)
  path = path or "assets/images"
  local files = lf.getDirectoryItems(path)

  for _, file in ipairs(files) do
    local filepath = path.."/"..file

    if lf.getInfo(filepath).type == "directory" then
      load_textures_from(filepath)
    else
      if string.find(filepath, ".png") then
        local name = string.gsub(filepath, ".png", "")
        name = string.gsub(name, "assets/images/", "")
        img_bank[name] = love.graphics.newImage(filepath)
      end
    end
  end
end

function get_tex(name)
  return img_bank[name]
end