aboutsummaryrefslogtreecommitdiff
path: root/src/Game
diff options
context:
space:
mode:
authorJuan J. Martinez <jjm@usebox.net>2023-02-16 21:11:18 +0000
committerJuan J. Martinez <jjm@usebox.net>2023-02-16 21:11:18 +0000
commit1d68ac340c28792b2b498e204ef123730d901443 (patch)
tree840514d136efbfe57b1f1321cc0b3d82286fb188 /src/Game
parent11120a24b6927073d55d2e56b4b911817dedaae2 (diff)
downloadspace-plat-hs-1d68ac340c28792b2b498e204ef123730d901443.tar.gz
space-plat-hs-1d68ac340c28792b2b498e204ef123730d901443.zip
Added lives to the HUD
Diffstat (limited to 'src/Game')
-rw-r--r--src/Game/Hud.hs4
-rw-r--r--src/Game/State.hs4
2 files changed, 6 insertions, 2 deletions
diff --git a/src/Game/Hud.hs b/src/Game/Hud.hs
index 3b59558..dd72bb3 100644
--- a/src/Game/Hud.hs
+++ b/src/Game/Hud.hs
@@ -19,4 +19,6 @@ render :: SDL.Renderer -> Hud -> IO ()
render renderer hud = do
state <- readIORef hud.stateRef
let xs = [0 .. state.totalBatteries - 1]
- mapM_ (\x -> S.render renderer hud.sprite (4 + x * 8) 178 0 (if state.batteries <= x then 0 else 1)) xs
+ in mapM_ (\x -> S.render renderer hud.sprite (4 + x * 8) 178 0 (if state.batteries <= x then 0 else 1)) xs
+ let xs = [0 .. state.totalLives - 1]
+ in mapM_ (\x -> S.render renderer hud.sprite (320 - 4 - state.totalLives * 8 + x * 8) 178 0 (if state.lives <= x then 2 else 3)) xs
diff --git a/src/Game/State.hs b/src/Game/State.hs
index 9988936..2223434 100644
--- a/src/Game/State.hs
+++ b/src/Game/State.hs
@@ -2,5 +2,7 @@ module Game.State (State (..)) where
data State = State
{ batteries :: Int,
- totalBatteries :: Int
+ totalBatteries :: Int,
+ lives :: Int,
+ totalLives :: Int
}