49 lines
1.1 KiB
Lua
49 lines
1.1 KiB
Lua
function DrawGameOver()
|
|
local s = ""
|
|
if HasP1Won then
|
|
s = "Player 1 Wins"
|
|
elseif HasP2Won then
|
|
s = "Player 2 Wins"
|
|
end
|
|
local sw, sh = GameFont:getWidth(s), GameFont:getHeight(s)
|
|
local centreX = love.graphics.getWidth() / 2
|
|
local centreY = love.graphics.getHeight() / 2
|
|
love.graphics.print(s, centreX - sw / 2, centreY - sh / 2)
|
|
end
|
|
|
|
function DisplayHealth()
|
|
local height = love.graphics.getHeight()
|
|
local width = love.graphics.getWidth()
|
|
love.graphics.print("" .. UserPlayer1.health, width - 120, height - 120)
|
|
love.graphics.print("" .. UserPlayer2.health, 0, 0)
|
|
end
|
|
|
|
function drawGame()
|
|
-- Debug Info
|
|
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)
|
|
--
|
|
|
|
love.graphics.setFont(GameFont)
|
|
DisplayHealth()
|
|
DrawGameOver()
|
|
|
|
-- 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
|