Many changes all around. Started main menu.
Added Drawable, Sprite and SoundEffect classes. Added comments to Fader class.
This commit is contained in:
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