Many changes all around. Started main menu.

Added Drawable, Sprite and SoundEffect classes.
Added comments to Fader class.
This commit is contained in:
2025-10-05 02:26:39 -04:00
parent fe8944b526
commit 7f8d79e00f
12 changed files with 395 additions and 66 deletions

35
src/ui/cursor.lua Normal file
View File

@@ -0,0 +1,35 @@
------------------------------------------------------------------------------
-- Imports
------------------------------------------------------------------------------
local make_class = require 'src.utils.classes'
local Sprite = require 'src.ui.sprite'
------------------------------------------------------------------------------
-- Class definitions
------------------------------------------------------------------------------
local Cursor = make_class(Sprite)
------------------------------------------------------------------------------
-- Class methods
------------------------------------------------------------------------------
function Cursor:_init(x, y)
Sprite._init(self, 'imgs/pointer.png', x, y)
end
function Cursor:mousemoved(x, y)
self.x = x
self.y = y
end
------------------------------------------------------------------------------
-- Module return
------------------------------------------------------------------------------
return Cursor

66
src/ui/drawable.lua Normal file
View File

@@ -0,0 +1,66 @@
------------------------------------------------------------------------------
-- Imports
------------------------------------------------------------------------------
local make_class = require 'src.utils.classes'
------------------------------------------------------------------------------
-- Class definitions
------------------------------------------------------------------------------
local Drawable = make_class()
------------------------------------------------------------------------------
-- Class methods
------------------------------------------------------------------------------
function Drawable:_init()
end
function Drawable:load()
end
function Drawable:update(_)
end
function Drawable:draw()
end
function Drawable:unload()
end
function Drawable:keypressed(_, _ , _)
end
function Drawable:textinput(_)
end
function Drawable:keyreleased(_, _)
end
function Drawable:mousemoved(_, _, _, _)
end
function Drawable:mousepressed(_, _, _)
end
function Drawable:mousereleased(_, _, _)
end
------------------------------------------------------------------------------
-- Module return
------------------------------------------------------------------------------
return Drawable

48
src/ui/sprite.lua Normal file
View File

@@ -0,0 +1,48 @@
------------------------------------------------------------------------------
-- Imports
------------------------------------------------------------------------------
local love = require 'love'
local make_class = require 'src.utils.classes'
local Drawable = require 'src.ui.drawable'
------------------------------------------------------------------------------
-- Class definitions
------------------------------------------------------------------------------
local Sprite = make_class(Drawable)
------------------------------------------------------------------------------
-- Class methods
------------------------------------------------------------------------------
function Sprite:_init(sprite_name, x, y)
self.sprite_name = sprite_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)
end
function Sprite:draw()
if self.sprite ~= nil then
love.graphics.draw(self.sprite, self.x, self.y)
end
end
function Sprite:unload()
self.sprite = nil
end
------------------------------------------------------------------------------
-- Module return
------------------------------------------------------------------------------
return Sprite