Added text buttons and button groups.
This commit is contained in:
@@ -31,6 +31,11 @@ function Asset:unload()
|
||||
end
|
||||
|
||||
|
||||
function Asset:is_loaded()
|
||||
return false
|
||||
end
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
-- Module return
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
@@ -42,7 +42,7 @@ function AssetManager:_init()
|
||||
Drawable._init(self)
|
||||
self.assets = {}
|
||||
self.bckg = Sprite('imgs/floppy.png')
|
||||
self.font = Font('fonts/Concrete.ttf', 40)
|
||||
self.font = Font('fonts/BBrick.ttf', 40)
|
||||
self.co = nil
|
||||
|
||||
self.bckg:load()
|
||||
|
||||
@@ -2,15 +2,14 @@
|
||||
-- Methods
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
-- Single inheritance version of the sample code from
|
||||
-- http://lua-users.org/wiki/ObjectOrientationTutorial
|
||||
local function make_class(BaseClass)
|
||||
-- Code from http://lua-users.org/wiki/ObjectOrientationTutorial
|
||||
local function make_class(...)
|
||||
-- "cls" is the new class
|
||||
local cls = {}
|
||||
local cls, bases = {}, {...}
|
||||
|
||||
-- copy base class contents into the new class
|
||||
if BaseClass ~= nil then
|
||||
for k, v in pairs(BaseClass) do
|
||||
for _, base in ipairs(bases) do
|
||||
for k, v in pairs(base) do
|
||||
cls[k] = v
|
||||
end
|
||||
end
|
||||
@@ -19,10 +18,11 @@ local function make_class(BaseClass)
|
||||
-- so you can do an "instance of" check using my_instance.is_a[MyClass]
|
||||
cls.__index, cls.is_a = cls, {[cls] = true}
|
||||
|
||||
if BaseClass ~= nil then
|
||||
for k, _ in pairs(BaseClass.is_a) do
|
||||
cls.is_a[k] = true
|
||||
for _, base in ipairs(bases) do
|
||||
for c in pairs(base.is_a) do
|
||||
cls.is_a[c] = true
|
||||
end
|
||||
cls.is_a[base] = true
|
||||
end
|
||||
|
||||
-- the class's __call metamethod
|
||||
|
||||
17
src/utils/colls.lua
Normal file
17
src/utils/colls.lua
Normal file
@@ -0,0 +1,17 @@
|
||||
------------------------------------------------------------------------------
|
||||
-- Module definitions
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
local collisions = {
|
||||
-- Default setting values.
|
||||
point_in_square = function(x, y, ox, oy, w, h)
|
||||
return x >= ox and x <= ox + w and y >= oy and y <= oy + h
|
||||
end,
|
||||
}
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
-- Module return
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
return collisions
|
||||
30
src/utils/color.lua
Normal file
30
src/utils/color.lua
Normal file
@@ -0,0 +1,30 @@
|
||||
------------------------------------------------------------------------------
|
||||
-- Imports
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
local make_class = require 'src.utils.classes'
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
-- Class definitions
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
local Color = make_class()
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
-- Class methods
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
function Color:_init(r, g, b)
|
||||
self.r = r ~= nil and r or 255
|
||||
self.g = g ~= nil and g or 255
|
||||
self.b = b ~= nil and b or 255
|
||||
end
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
-- Module return
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
return Color
|
||||
Reference in New Issue
Block a user