fucking hell
This commit is contained in:
@@ -13,6 +13,8 @@ return {
|
||||
Vector2D = require("lib.datatypes.Vector2D"),
|
||||
Dimension = require("lib.datatypes.Dimension"),
|
||||
Color = require("lib.datatypes.Color"),
|
||||
|
||||
Utils = require("lib.utils.JUtils"),
|
||||
|
||||
TextAlignment = {
|
||||
LEFT = "left",
|
||||
@@ -22,7 +24,7 @@ return {
|
||||
|
||||
Orientation = {
|
||||
VERTICAL = "vertical",
|
||||
HORIZONTAL = "horizontal"
|
||||
HORIZONTAL = "horizontal",
|
||||
},
|
||||
|
||||
parent = function(self, parent, child)
|
||||
|
@@ -25,4 +25,4 @@ function Slider:update(delta)
|
||||
|
||||
end
|
||||
|
||||
return slider
|
||||
return Slider
|
25
lib/datatypes/Point.lua
Normal file
25
lib/datatypes/Point.lua
Normal file
@@ -0,0 +1,25 @@
|
||||
local Point = {}
|
||||
|
||||
local meta = {}
|
||||
meta.__index = Point
|
||||
|
||||
function meta.__add(pointA, pointB)
|
||||
return Point:new(pointA.x + pointB.x, pointA.y + pointB.y)
|
||||
end
|
||||
|
||||
function meta.__tostring(vec)
|
||||
|
||||
end
|
||||
|
||||
setmetatable(Point, meta)
|
||||
|
||||
function Point:new(x, y)
|
||||
|
||||
local newObj = {}
|
||||
object.x = x or 0
|
||||
object.y = y or 0
|
||||
|
||||
return setmetatable(newObj, getmetatable(self))
|
||||
end
|
||||
|
||||
return Point
|
@@ -1,13 +1,25 @@
|
||||
local Vector2D = {}
|
||||
|
||||
setmetatable(Vector2D,{
|
||||
__index = Vector2D,
|
||||
__add = function(a,b) return Vector2D:new(a.x+b.x,a.y+b.y) end,
|
||||
__tostring = function(a) return "("..a.x..','..a.y..")" end
|
||||
})
|
||||
local meta = {}
|
||||
meta.__index = Vector2D
|
||||
|
||||
function Vector2D:new(x,y)
|
||||
return setmetatable({x=x or 0, y=y or 0}, getmetatable(self))
|
||||
end
|
||||
function meta.__add(vecA, vecB)
|
||||
return Vector2D:new(vecA.x + vecB.x, vecA.y + vecB.y)
|
||||
end
|
||||
|
||||
function meta.__tostring(vec)
|
||||
return string.format("Vector2D: %d, %d", vec.x, vec.y)
|
||||
end
|
||||
|
||||
setmetatable(Vector2D, meta)
|
||||
|
||||
function Vector2D:new(x, y)
|
||||
|
||||
local object = {}
|
||||
object.x = x or 0
|
||||
object.y = y or 0
|
||||
|
||||
return setmetatable(object, getmetatable(self))
|
||||
end
|
||||
|
||||
return Vector2D
|
9
lib/utils/JUtils.lua
Normal file
9
lib/utils/JUtils.lua
Normal file
@@ -0,0 +1,9 @@
|
||||
local function round(number, decimalPlaces)
|
||||
local placer = 10^(-decimalPlaces)
|
||||
return (math.floor(number)/placer)*placer
|
||||
end
|
||||
|
||||
|
||||
return {
|
||||
RoundNumber = round,
|
||||
}
|
44
main.lua
44
main.lua
@@ -8,49 +8,11 @@ local JUI = require("JUIlib")
|
||||
|
||||
local mainmenu = JUI.JUIScene:new()
|
||||
|
||||
local background = JUI.Frame:new()
|
||||
background:setName("Background")
|
||||
background:setSize(JUI.Dimension:new(0.6, 0.6))
|
||||
|
||||
local emptyColor = JUI.Label:new()
|
||||
emptyColor:setSize(JUI.Dimension:new(0.3, 0.1))
|
||||
emptyColor:setPosition(JUI.Dimension:new(0.2, 0.8))
|
||||
emptyColor:setBorderColor(JUI.Color:new(0.5, 0.5, 0.5))
|
||||
emptyColor:setTextSize(22)
|
||||
emptyColor:setCornerRounding(12)
|
||||
emptyColor:setBackgroundColor(JUI.Color:fromHex("#FAF"))
|
||||
emptyColor:setTextAlignment(JUI.TextAlignment.CENTER)
|
||||
emptyColor:setText("Bottom Text")
|
||||
local testSlider = JUI.Slider:new()
|
||||
|
||||
local button = JUI.Button:new()
|
||||
button:setName("Button")
|
||||
button:setSize(JUI.Dimension:new(0.3, 0.5))
|
||||
button:setPosition(JUI.Dimension:new(0.2, 0.2))
|
||||
button:setBackgroundColor(JUI.Color:fromHSL(1, 128, 196))
|
||||
|
||||
button.mouseClickDown:connect(function()
|
||||
button:setText("Thug")
|
||||
end)
|
||||
|
||||
button.mouseClickUp:connect(function()
|
||||
button:setText("not Thug")
|
||||
end)
|
||||
|
||||
button.mouseEnter:connect(function()
|
||||
button:setText("Inside")
|
||||
end)
|
||||
button.mouseExit:connect(function()
|
||||
button:setText("Outside")
|
||||
end)
|
||||
|
||||
JUI:parent(mainmenu, background)
|
||||
JUI:parent(mainmenu, emptyColor)
|
||||
JUI:parent(background, button)
|
||||
|
||||
local function round(number, decimalPlaces)
|
||||
local placer = 10^(-decimalPlaces)
|
||||
return (math.floor(number)/placer)*placer
|
||||
end
|
||||
JUI:parent(mainmenu, testSlider)
|
||||
|
||||
local windowCreationSuccess
|
||||
local debugInfoString = ""
|
||||
@@ -74,7 +36,7 @@ function love.update(delta)
|
||||
|
||||
mainmenu:update(delta)
|
||||
|
||||
luaEngineMemory = round(collectgarbage('count'), 0)
|
||||
luaEngineMemory = JUI.Utils.RoundNumber(collectgarbage('count'), 0)
|
||||
luaHighestMem = (luaEngineMemory > luaHighestMem) and luaEngineMemory or luaHighestMem
|
||||
|
||||
do
|
||||
|
Reference in New Issue
Block a user