aboutsummaryrefslogtreecommitdiff
path: root/src/textures.lua
diff options
context:
space:
mode:
authorne_mene <[email protected]>2026-03-08 22:21:42 +0100
committerne_mene <[email protected]>2026-03-08 22:21:42 +0100
commitb744faa2e42ed37459fe3edb69c1149146233e5b (patch)
tree25f238d3e467c7cf43e619b579e0df89762b1cca /src/textures.lua
parent95d50b15634bf4799a2005e381d82c110fbff39b (diff)
let there be light
Diffstat (limited to 'src/textures.lua')
-rw-r--r--src/textures.lua26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/textures.lua b/src/textures.lua
new file mode 100644
index 0000000..5a3a4f9
--- /dev/null
+++ b/src/textures.lua
@@ -0,0 +1,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