diff options
author | Juan J. Martinez <jjm@usebox.net> | 2023-03-01 07:27:50 +0000 |
---|---|---|
committer | Juan J. Martinez <jjm@usebox.net> | 2023-03-01 07:27:50 +0000 |
commit | 973961a0ced31c30f0e7e5abc618aaca6c8452b8 (patch) | |
tree | ba6d11b5a3e14e39568e3b49ec3c4550b5a825b9 /src/Game/Hud.hs | |
parent | 9efd5381a31d69a1122f101cbee03ad3a91ed4b3 (diff) | |
download | space-plat-hs-973961a0ced31c30f0e7e5abc618aaca6c8452b8.tar.gz space-plat-hs-973961a0ced31c30f0e7e5abc618aaca6c8452b8.zip |
Scroll using SDL's viewport
Horizontal needs testing.
Diffstat (limited to 'src/Game/Hud.hs')
-rw-r--r-- | src/Game/Hud.hs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/Game/Hud.hs b/src/Game/Hud.hs index 1e51993..880de50 100644 --- a/src/Game/Hud.hs +++ b/src/Game/Hud.hs @@ -1,10 +1,13 @@ -module Game.Hud (Hud, mkHud, render) where +module Game.Hud (Hud, mkHud, render, height) where import Data.IORef import qualified Game.Sprites as S import qualified Game.State as GS import qualified SDL +height :: Int +height = 16 + data Hud = Hud { sprite :: S.Sprite, stateRef :: IORef GS.State @@ -21,4 +24,5 @@ render renderer hud = do let xs = [0 .. state.totalBatteries - 1] in mapM_ (\x -> S.render renderer hud.sprite (4 + x * 8) 4 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) 4 0 (if state.lives <= x then 2 else 3)) xs + in -- magic numbers + mapM_ (\x -> S.render renderer hud.sprite (320 - 4 - state.totalLives * 8 + x * 8) 4 0 (if state.lives <= x then 2 else 3)) xs |