From 2f40109ab69892c7b7812fdbba3a83dc3ca96193 Mon Sep 17 00:00:00 2001 From: "Juan J. Martinez" Date: Sat, 25 Feb 2023 13:50:04 +0000 Subject: Game over sequence WIP --- src/Game/Entities/Common.hs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/Game/Entities/Common.hs') diff --git a/src/Game/Entities/Common.hs b/src/Game/Entities/Common.hs index 2a0c6f1..251dbb4 100644 --- a/src/Game/Entities/Common.hs +++ b/src/Game/Entities/Common.hs @@ -43,7 +43,10 @@ hitPlayer stateRef = stateRef $~ updatePlayerHit where updatePlayerHit :: GS.State -> GS.State - updatePlayerHit s = s {GS.lives = s.lives - 1, GS.hitDelay = hitDelay} + updatePlayerHit s + -- if we run out of lives, trigger the game over + | s.lives == 1 = s {GS.lives = 0, GS.gameOverDelay = gameOverDelay} + | otherwise = s {GS.lives = s.lives - 1, GS.hitDelay = hitDelay} -- | Update game state to reflect that the player picked up a battery. collectedBattery :: IORef GS.State -> IO () -- cgit v1.2.3