dynamic sprite loading

This commit is contained in:
jill 2021-01-26 00:17:32 +03:00
parent c575497b3f
commit 738398fc2b
Signed by: oat
GPG key ID: DD83A9617A252385
2 changed files with 21 additions and 3 deletions

View file

@ -1,6 +1,8 @@
function love.conf(t) function love.conf(t)
t.version = "11.1" t.version = '11.1'
t.release = false t.release = false
t.identity = 'notsanequarium'
t.appendidentity = true
t.window.title = 'notsanequarium' t.window.title = 'notsanequarium'
t.window.resizable = true t.window.resizable = true
t.window.vsync = false t.window.vsync = false
@ -9,6 +11,13 @@ function love.conf(t)
t.window.width = 640 t.window.width = 640
t.window.height = 480 t.window.height = 480
t.modules.physics = false
t.modules.joystick = false
t.modules.video = false
t.modules.data = false
t.modules.math = false
t.modules.thread = false
-- t.window.msaa = 2 -- t.window.msaa = 2
t.releases = { t.releases = {

View file

@ -1,11 +1,13 @@
require 'lib.audio' require 'lib.audio'
local assets = {} local assets = {}
local rawsprites = {}
function assets.clear() function assets.clear()
print(" clearing assets") print(" clearing assets")
sprites = {} sprites = {}
rawsprites = {}
sound_path = {} sound_path = {}
music_path = {} music_path = {}
end end
@ -13,8 +15,15 @@ end
function assets.load(base) function assets.load(base)
print(" loading " .. base) print(" loading " .. base)
assets.addSprites(base) setmetatable(sprites, {__index = function(tbl, i)
print("✓ added sprites") if rawsprites[i] then return rawsprites[i] end
local sprite = love.graphics.newImage('assets/sprites/' .. i .. '.png')
rawsprites[i] = sprite
return sprite
end})
--assets.addSprites(base)
--print("✓ added sprites")
assets.addAudio(base) assets.addAudio(base)
print("✓ added audio") print("✓ added audio")