ZLP1/scripts/menus.lua

83 lines
1.6 KiB
Lua

require "scripts/ui/button"
function MenuStep(menu)
-- first get mouse
local mouse_x, mouse_y = love.mouse.getPosition()
for _, element in pairs(List.UIElement) do
if element.type == "Button" then
element:checkMouse(mouse_x, mouse_y)
end
end
if menu == 1 then
if M_game_start:getVariable() == true then
MenuExit(menu,0)
stageStart()
elseif M_exit:getVariable() == true then
love.event.quit()
end
else
end
end
function MenuExit(from,to)
for _, element in pairs(List.UIElement) do
element = nil
end
List.UIElement = {}
if from == 1 then
M_game_start = nil
M_exit = nil
end
currentMenu = to or 0
end
function MenuDisplay(menu)
for _, element in pairs(List.UIElement) do
element:Draw()
end
if menu == 1 then
love.graphics.print(tostring(M_exit[1]), windowWidth-100, windowHeight-10)
else
end
end
function MenuInit(menu)
-- main menu
if menu == 1 then
-- elements
M_game_start = interfaceButton:New(
windowWidth/2,
2/10*windowHeight,
windowWidth/6,
windowWidth/12,
{false,true},
1,
{
text = "Press here to start",
color = {0,0,0.5},
color2 = {1,1,1},
alpha = 1,
scale = 1,
scale_x = 1,
scale_y = 1
})
M_exit = interfaceButton:New(
windowWidth/2,
500,
windowWidth/6,
windowWidth/12,
{false,true},
1,
{
color = {1,0,0.5},
color2 = {1,1,1},
alpha = 1,
scale = 1,
scale_x = 1,
scale_y = 1
})
end
end