Added assets manager singleton.

This commit is contained in:
2025-10-05 17:47:17 -04:00
parent 03b5d1dafb
commit 82d2a89a0a
12 changed files with 329 additions and 35 deletions

View File

@@ -16,7 +16,8 @@ local Drawable = make_class(Asset)
-- Class methods
------------------------------------------------------------------------------
function Drawable:_init()
function Drawable:_init(file_name)
Asset._init(self, file_name)
end

View File

@@ -17,15 +17,15 @@ local Sprite = make_class(Drawable)
-- Class methods
------------------------------------------------------------------------------
function Sprite:_init(sprite_name, x, y)
self.sprite_name = string.format('assets/%s', sprite_name)
function Sprite:_init(file_name, x, y)
Drawable._init(self, file_name)
self.x = (x ~= nil and x) or 0
self.y = (y ~= nil and y) or 0
end
function Sprite:load()
self.sprite = love.graphics.newImage(self.sprite_name)
self.sprite = love.graphics.newImage(self.file_name)
end