Many changes all around. Started main menu.
Added Drawable, Sprite and SoundEffect classes. Added comments to Fader class.
This commit is contained in:
35
src/ui/cursor.lua
Normal file
35
src/ui/cursor.lua
Normal 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
66
src/ui/drawable.lua
Normal 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
48
src/ui/sprite.lua
Normal 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
|
||||
Reference in New Issue
Block a user