parent
53aa6d698d
commit
99b420cc7f
@ -1,44 +1,43 @@ |
|||||||
local function button(x,y, w, h, text, selected) |
local function button(x, y, w, h, text, selected) |
||||||
--x,y is the top left corner of the button |
--x,y is the top left corner of the button |
||||||
local rounding = 30 -- used for rounding the buttons |
local rounding = 30 -- used for rounding the buttons |
||||||
|
|
||||||
if not selected then |
if not selected then |
||||||
love.graphics.setColor(love.math.colorFromBytes(41,134,204)) |
love.graphics.setColor(love.math.colorFromBytes(41, 134, 204)) |
||||||
elseif selected then |
elseif selected then |
||||||
love.graphics.setColor(love.math.colorFromBytes(244,67,54)) |
love.graphics.setColor(love.math.colorFromBytes(244, 67, 54)) |
||||||
end |
end |
||||||
-- Draw rectangle |
-- Draw rectangle |
||||||
love.graphics.rectangle("line", x, y, w, h, rounding, rounding) |
love.graphics.rectangle("line", x, y, w, h, rounding, rounding) |
||||||
|
|
||||||
-- Get width and height of text |
-- Get width and height of text |
||||||
local tw = MenuFont:getWidth(text) |
local tw = MenuFont:getWidth(text) |
||||||
local th = MenuFont:getHeight(text) |
local th = MenuFont:getHeight(text) |
||||||
-- Calculate position to center the text |
-- Calculate position to center the text |
||||||
local textX = x + (w - tw) / 2 |
local textX = x + (w - tw) / 2 |
||||||
local textY = y + (h - th) / 2 |
local textY = y + (h - th) / 2 |
||||||
-- Place text inside the rectangle |
-- Place text inside the rectangle |
||||||
love.graphics.setFont(MenuFont) |
love.graphics.setFont(MenuFont) |
||||||
love.graphics.print(text, textX, textY) |
love.graphics.print(text, textX, textY) |
||||||
end |
end |
||||||
|
|
||||||
local function title() |
local function title() |
||||||
local height = love.graphics.getHeight() |
local height = love.graphics.getHeight() |
||||||
local width = love.graphics.getWidth() |
local width = love.graphics.getWidth() |
||||||
love.graphics.setFont(GameFont) |
love.graphics.setFont(GameFont) |
||||||
love.graphics.setColor(0.5,1,1) |
love.graphics.setColor(0.5, 1, 1) |
||||||
love.graphics.rectangle("fill", 0, 0, width, height) |
love.graphics.rectangle("fill", 0, 0, width, height) |
||||||
love.graphics.setColor(0,0,0) |
love.graphics.setColor(0, 0, 0) |
||||||
love.graphics.print("MENU", 100,100) |
love.graphics.print("MENU", 100, 100) |
||||||
end |
end |
||||||
|
|
||||||
|
|
||||||
function DrawMenu() |
function DrawMenu() |
||||||
local bwidth, bheight = 300, 140 |
local bwidth, bheight = 300, 140 |
||||||
title() |
title() |
||||||
button(100, 200, bwidth, bheight, "Play", MENU_POS == 0 and true or false) |
button(100, 200, bwidth, bheight, "Play", MENU_POS == 0 and true or false) |
||||||
button(100, 350, bwidth, bheight, "???", MENU_POS == 1 and true or false) |
button(100, 350, bwidth, bheight, "???", MENU_POS == 1 and true or false) |
||||||
button(100, 500, bwidth, bheight, "???", MENU_POS == 2 and true or false) |
button(100, 500, bwidth, bheight, "???", MENU_POS == 2 and true or false) |
||||||
button(100, 650, bwidth, bheight, "Quit", MENU_POS == 3 and true or false) |
button(100, 650, bwidth, bheight, "Quit", MENU_POS == 3 and true or false) |
||||||
|
|
||||||
love.graphics.setColor(255,255,255) -- reset colours |
love.graphics.setColor(255, 255, 255) -- reset colours |
||||||
end |
end |
||||||
|
@ -1,2 +1 @@ |
|||||||
function UpdateMenu(dt) |
function UpdateMenu(dt) end |
||||||
end |
|
||||||
|
@ -1,45 +1,44 @@ |
|||||||
local function button(x,y, w, h, text, selected) |
local function button(x, y, w, h, text, selected) |
||||||
--x,y is the top left corner of the button |
--x,y is the top left corner of the button |
||||||
local rounding = 30 -- used for rounding the buttons |
local rounding = 30 -- used for rounding the buttons |
||||||
|
|
||||||
if not selected then |
if not selected then |
||||||
love.graphics.setColor(love.math.colorFromBytes(41,134,204)) |
love.graphics.setColor(love.math.colorFromBytes(41, 134, 204)) |
||||||
elseif selected then |
elseif selected then |
||||||
love.graphics.setColor(love.math.colorFromBytes(244,67,54)) |
love.graphics.setColor(love.math.colorFromBytes(244, 67, 54)) |
||||||
end |
end |
||||||
-- Draw rectangle |
-- Draw rectangle |
||||||
love.graphics.rectangle("fill", x, y, w, h, rounding, rounding) |
love.graphics.rectangle("fill", x, y, w, h, rounding, rounding) |
||||||
|
|
||||||
-- Get width and height of text |
-- Get width and height of text |
||||||
local tw = MenuFont:getWidth(text) |
local tw = MenuFont:getWidth(text) |
||||||
local th = MenuFont:getHeight(text) |
local th = MenuFont:getHeight(text) |
||||||
-- Calculate position to center the text |
-- Calculate position to center the text |
||||||
local textX = x + (w - tw) / 2 |
local textX = x + (w - tw) / 2 |
||||||
local textY = y + (h - th) / 2 |
local textY = y + (h - th) / 2 |
||||||
-- Place text inside the rectangle |
-- Place text inside the rectangle |
||||||
love.graphics.setFont(MenuFont) |
love.graphics.setFont(MenuFont) |
||||||
love.graphics.setColor(1,1,1) -- reset colours |
love.graphics.setColor(1, 1, 1) -- reset colours |
||||||
love.graphics.print(text, textX, textY) |
love.graphics.print(text, textX, textY) |
||||||
end |
end |
||||||
|
|
||||||
|
|
||||||
function DrawPause() |
function DrawPause() |
||||||
local opacity = 0.3 |
local opacity = 0.3 |
||||||
local height = love.graphics.getHeight() |
local height = love.graphics.getHeight() |
||||||
local width = love.graphics.getWidth() |
local width = love.graphics.getWidth() |
||||||
local bwidth, bheight = 300, 140 |
local bwidth, bheight = 300, 140 |
||||||
love.graphics.setFont(GameFont) |
love.graphics.setFont(GameFont) |
||||||
|
|
||||||
DrawGame() --Draw a single frame of the game |
DrawGame() --Draw a single frame of the game |
||||||
love.graphics.setColor(0.1,0.1,0.1, opacity) --overlay opaque img |
love.graphics.setColor(0.1, 0.1, 0.1, opacity) --overlay opaque img |
||||||
love.graphics.rectangle("fill", 0, 0, width, height) |
love.graphics.rectangle("fill", 0, 0, width, height) |
||||||
|
|
||||||
love.graphics.setColor(1,1,1) |
love.graphics.setColor(1, 1, 1) |
||||||
love.graphics.print("PAUSED", 100,100) |
love.graphics.print("PAUSED", 100, 100) |
||||||
--love.graphics.print("" .. PAUSE_POS, 200,200) |
--love.graphics.print("" .. PAUSE_POS, 200,200) |
||||||
|
|
||||||
button(100, 200, bwidth, bheight, "Return", PAUSE_POS == 0 and true or false) |
button(100, 200, bwidth, bheight, "Return", PAUSE_POS == 0 and true or false) |
||||||
button(100, 350, bwidth, bheight, "Menu", PAUSE_POS == 1 and true or false) |
button(100, 350, bwidth, bheight, "Menu", PAUSE_POS == 1 and true or false) |
||||||
button(100, 500, bwidth, bheight, "Quit", PAUSE_POS == 2 and true or false) |
button(100, 500, bwidth, bheight, "Quit", PAUSE_POS == 2 and true or false) |
||||||
love.graphics.setColor(255,255,255) -- reset colours |
love.graphics.setColor(255, 255, 255) -- reset colours |
||||||
end |
end |
||||||
|
@ -1,2 +1 @@ |
|||||||
function UpdatePause(dt) |
function UpdatePause(dt) end |
||||||
end |
|
||||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
Reference in new issue