70 lines
1.6 KiB
Lua
70 lines
1.6 KiB
Lua
function DrawGameOver()
|
|
local s = ""
|
|
if HasP1Won then
|
|
s = "Player 1 Wins"
|
|
elseif HasP2Won then
|
|
s = "Player 2 Wins"
|
|
end
|
|
if HasP1Won or HasP2Won then
|
|
love.graphics.setFont(GameFont)
|
|
local sw, sh = GameFont:getWidth(s), GameFont:getHeight(s)
|
|
local ssw, ssh = GameSubFont:getWidth("R to Restart"), GameSubFont:getHeight("R to Restart")
|
|
local centreX = love.graphics.getWidth() / 2
|
|
local centreY = love.graphics.getHeight() / 2
|
|
love.graphics.print(s, centreX - sw / 2, centreY - sh / 2)
|
|
love.graphics.setFont(GameSubFont)
|
|
love.graphics.print("R to Restart", (centreX - ssw / 2) + (sw / 4), (centreY - ssh / 2) + (sh / 2) + 30)
|
|
end
|
|
end
|
|
|
|
function DisplayHealth()
|
|
local height = love.graphics.getHeight()
|
|
local width = love.graphics.getWidth()
|
|
love.graphics.print("" .. UserPlayer1.health, width - 70, height - 95)
|
|
love.graphics.print("" .. UserPlayer2.health, 5, 5)
|
|
end
|
|
|
|
function drawFPS()
|
|
love.graphics.setColor(1, 1, 1) -- RGB values for white are (1, 1, 1)
|
|
love.graphics.setFont(DebugFont)
|
|
love.graphics.print("FPS: " .. love.timer.getFPS(), 1200, 10)
|
|
end
|
|
|
|
function drawBg()
|
|
for _, v in ipairs(Backgrounds) do
|
|
v:draw()
|
|
end
|
|
end
|
|
|
|
function drawGame()
|
|
if Debug then
|
|
drawFPS()
|
|
end
|
|
love.graphics.setFont(GameFont)
|
|
|
|
ScrnEffect(function()
|
|
drawBg()
|
|
DisplayHealth()
|
|
DrawGameOver()
|
|
|
|
--Wrap the items we want to draw with a shader from Moonshine
|
|
--inside a function
|
|
-- Bullets Draw
|
|
for _, v in ipairs(Bullets1) do
|
|
v:draw()
|
|
end
|
|
for _, v in ipairs(Bullets2) do
|
|
v:draw()
|
|
end
|
|
|
|
-- Players Draw
|
|
UserPlayer1:draw()
|
|
UserPlayer2:draw()
|
|
|
|
-- Walls Draw
|
|
for _, v in ipairs(Walls) do
|
|
v:draw()
|
|
end
|
|
end)
|
|
end
|