|
|
@ -1,12 +1,14 @@ |
|
|
|
local function checkWinState() |
|
|
|
local function checkLossState() |
|
|
|
-- Check P1's health |
|
|
|
-- Check P1's health |
|
|
|
if UserPlayer1.health <= 0 then --P1 win |
|
|
|
if UserPlayer1.health <= 0 then --P1 Lost, P2 Win |
|
|
|
|
|
|
|
_G.P2_COUNT = _G.P2_COUNT + 1 |
|
|
|
_G.P1_WIN = false |
|
|
|
_G.P1_WIN = false |
|
|
|
_G.P2_WIN = true |
|
|
|
_G.P2_WIN = true |
|
|
|
return true |
|
|
|
return true |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
if UserPlayer2.health <= 0 then --P2 win |
|
|
|
if UserPlayer2.health <= 0 then --P2 Lost, P1 Win |
|
|
|
|
|
|
|
_G.P1_COUNT = _G.P1_COUNT + 1 |
|
|
|
_G.P1_WIN = true |
|
|
|
_G.P1_WIN = true |
|
|
|
_G.P2_WIN = false |
|
|
|
_G.P2_WIN = false |
|
|
|
return true |
|
|
|
return true |
|
|
@ -18,7 +20,7 @@ local max = math.max -- optimisations |
|
|
|
|
|
|
|
|
|
|
|
function UpdateGame(dt) |
|
|
|
function UpdateGame(dt) |
|
|
|
--Check if anyone has won |
|
|
|
--Check if anyone has won |
|
|
|
if checkWinState() == true then |
|
|
|
if checkLossState() == true then |
|
|
|
print("STATE CHNAGED: WIN!") |
|
|
|
print("STATE CHNAGED: WIN!") |
|
|
|
_G.GAMESTATE = "WIN" |
|
|
|
_G.GAMESTATE = "WIN" |
|
|
|
end |
|
|
|
end |
|
|
|