making menu and subfolders

This commit is contained in:
Simon Kellet
2024-07-14 20:56:04 +01:00
parent a3f90645fd
commit 99f0323635
13 changed files with 1152 additions and 32 deletions
+37
View File
@@ -0,0 +1,37 @@
local 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(), 1520, 10)
end
local function drawHealth()
love.graphics.setFont(GameFont)
local height = love.graphics.getHeight()
local width = love.graphics.getWidth()
love.graphics.print("" .. UserPlayer1.health, 5, 5)
love.graphics.print("" .. UserPlayer2.health, width - 70, height - 95)
end
function DrawGame()
--STI
GameMap:draw()
-- WindField
if DebugFlag then
World:draw()
drawFPS()
end
for _, v in ipairs(Bullets1) do
v:draw()
end
for _, v in ipairs(Bullets2) do
v:draw()
end
UserPlayer1:draw()
UserPlayer2:draw()
--Draw Health
drawHealth()
end
+13
View File
@@ -0,0 +1,13 @@
function GameKeyPressed(key)
if key == "escape" then
love.event.quit()
end
if key == "b" then
DebugFlag = not DebugFlag
end
if key == "r" then
love.load()
end
end
+75
View File
@@ -0,0 +1,75 @@
function UpdateGame(dt)
--WindField
World:update(dt)
local max = math.max
KeyPressTime1 = max(0, KeyPressTime1 - dt)
if KeyPressTime1 <= 0 then
EnableKeyPress1 = true
end
KeyPressTime2 = max(0, KeyPressTime2 - dt)
if KeyPressTime2 <= 0 then
EnableKeyPress2 = true
end
for i, v in ipairs(Bullets1) do
v:update(dt)
if v.y < 0 then --top of screen
table.remove(Bullets1, i)
v.collider:destroy()
elseif v.y > love.graphics.getHeight() then --bottom of screen
table.remove(Bullets1, i)
v.collider:destroy()
end
if v.collider:enter("Player2") then
print("Player1 hit Player2!")
table.remove(Bullets1, i)
v.collider:destroy()
if UserPlayer1.health > 0 then
UserPlayer1.health = UserPlayer1.health - 1
end
end
if v.collider:enter("Player1") then
print("Player 1 hit themselves!")
table.remove(Bullets1, i)
v.collider:destroy()
if UserPlayer1.health > 0 then
UserPlayer1.health = UserPlayer1.health - 1
end
end
end
for i, v in ipairs(Bullets2) do
v:update(dt)
if v.y < 0 then --top of screen
table.remove(Bullets2, i)
v.collider:destroy()
elseif v.y > love.graphics.getHeight() then --bottom of screen
table.remove(Bullets2, i)
v.collider:destroy()
end
if v.collider:enter("Player1") then
print("Player2 hit Player1!")
table.remove(Bullets2, i)
v.collider:destroy()
if UserPlayer2.health > 0 then
UserPlayer2.health = UserPlayer2.health - 1
end
end
if v.collider:enter("Player2") then
print("Player 2 hit themselves!")
table.remove(Bullets2, i)
v.collider:destroy()
if UserPlayer2.health > 0 then
UserPlayer2.health = UserPlayer2.health - 1
end
end
end
UserPlayer1:update(dt)
UserPlayer2:update(dt)
end