format and stuff
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
function GameKeyPressed(key)
|
||||
|
||||
if key == "escape" then
|
||||
musicBattle:setVolume(0)
|
||||
musicPause:setVolume(0.5)
|
||||
musicBattle:setVolume(0)
|
||||
musicPause:setVolume(0.6)
|
||||
|
||||
_G.GAMESTATE = "PAUSE"
|
||||
print("STATE CHANEGD: PAUSED!")
|
||||
@@ -13,13 +12,8 @@ function GameKeyPressed(key)
|
||||
DebugFlag = not DebugFlag
|
||||
end
|
||||
|
||||
--TODO: Move player movement code into here!
|
||||
|
||||
|
||||
--[[
|
||||
-- TODO: Better restart
|
||||
--TODO: Better restart
|
||||
if key == "r" and not _G.PAUSED then
|
||||
love.load()
|
||||
end
|
||||
]]--
|
||||
end
|
||||
|
||||
+29
-3
@@ -1,9 +1,31 @@
|
||||
local function checkWinState()
|
||||
-- Check P1's health
|
||||
if UserPlayer1.health <= 0 then --P1 win
|
||||
_G.P1_WIN = true
|
||||
_G.P2_WIN = false
|
||||
UserPlayer1.health = 0
|
||||
return true
|
||||
end
|
||||
if UserPlayer2.health <= 0 then --P2 win
|
||||
_G.P1_WIN = false
|
||||
_G.P2_WIN = true
|
||||
UserPlayer2.health = 0
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
local max = math.max -- optimisations
|
||||
|
||||
function UpdateGame(dt)
|
||||
--Check if anyone has won
|
||||
if checkWinState() == true then
|
||||
print("STATE CHNAGED: WIN!")
|
||||
_G.GAMESTATE = "WIN"
|
||||
end
|
||||
--WindField
|
||||
World:update(dt)
|
||||
|
||||
local max = math.max
|
||||
|
||||
KeyPressTime1 = max(0, KeyPressTime1 - dt)
|
||||
if KeyPressTime1 <= 0 then
|
||||
EnableKeyPress1 = true
|
||||
@@ -13,6 +35,7 @@ function UpdateGame(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
|
||||
@@ -69,7 +92,10 @@ function UpdateGame(dt)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
UserPlayer1:handleKeys("w", "s", "a", "d", dt)
|
||||
UserPlayer2:handleKeys("up", "down", "left", "right", dt)
|
||||
UserPlayer1:updateCol()
|
||||
UserPlayer2:updateCol()
|
||||
UserPlayer1:update(dt)
|
||||
UserPlayer2:update(dt)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user