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

40 lines
1018 B

local function winner()
3 months ago
local width = love.graphics.getWidth() / _G.X_SCALE
local height = love.graphics.getHeight() / _G.Y_SCALE
local opacity = 0.3
local s = ""
4 months ago
if _G.P1_WIN then
s = "P1 Win! R - Restart"
4 months ago
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
4 months ago
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