From e83ee4ec64619d526e582f24e57e723f37d33bbd Mon Sep 17 00:00:00 2001 From: Simon Kellet Date: Sun, 21 Jul 2024 19:47:41 +0100 Subject: [PATCH] there is now a win screen --- Win/DrawWin.lua | 34 ++++++++++++++++++++++++++++++++++ Win/UpdateWin.lua | 1 + 2 files changed, 35 insertions(+) create mode 100644 Win/DrawWin.lua create mode 100644 Win/UpdateWin.lua diff --git a/Win/DrawWin.lua b/Win/DrawWin.lua new file mode 100644 index 0000000..6d4719c --- /dev/null +++ b/Win/DrawWin.lua @@ -0,0 +1,34 @@ +local function winner() + local width = love.graphics.getWidth() + local height = love.graphics.getHeight() + local opacity = 0.3 + local s = "" + + if _G.P1_WIN then + s = "P1 Win! R - Restart" + end + if _G.P2_WIN then + s = "P2 Win! R - Restart" + end + + if _G.P1_WIN or _G.P2_WIN then + -- Overlay + DrawGame() --Draw a single frame of the game + love.graphics.setColor(0.1, 0.1, 0.1, opacity) --overlay opaque img + love.graphics.rectangle("fill", 0, 0, width, height) + + -- Who won text + local sw, sh = MenuFont:getWidth(s), GameFont:getHeight(s) + local centreX = width / 2 + local centreY = height / 2 + + love.graphics.setFont(MenuFont) + love.graphics.setColor(1, 1, 1) -- white + love.graphics.print(s, centreX - sw / 2, centreY - sh / 2) + end +end + +function DrawWin() + winner() + love.graphics.setColor(255, 255, 255) -- reset colours +end diff --git a/Win/UpdateWin.lua b/Win/UpdateWin.lua new file mode 100644 index 0000000..4c713ab --- /dev/null +++ b/Win/UpdateWin.lua @@ -0,0 +1 @@ +function UpdateWin(dt) end