You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
love2d-tank/Win/DrawWin.lua

38 lines
999 B

local function winner()
local width = love.graphics.getWidth()
local height = love.graphics.getHeight()
local opacity = 0.3
local s = ""
if not _G.P1_WIN then
s = "P1 Win! R - Restart"
elseif not _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) -- who won
love.graphics.print(
"" .. _G.P1_COUNT .. ":" .. "" .. _G.P2_COUNT,
(centreX - sw / 2),
(centreY - sh / 2) - sh / 1.5
) -- score
end
end
function DrawWin()
winner()
love.graphics.setColor(255, 255, 255) -- reset colours
end