aboutsummaryrefslogtreecommitdiff
path: root/src/Game/Entities/Player.hs
diff options
context:
space:
mode:
authorJuan J. Martinez <jjm@usebox.net>2023-02-26 00:06:40 +0000
committerJuan J. Martinez <jjm@usebox.net>2023-02-26 00:06:40 +0000
commitb3e0ace3ca198cacd8d77c6ca0f2c457826dee63 (patch)
treed55b86d8347da910dd166f44b99e5b072f217c2d /src/Game/Entities/Player.hs
parentc5b11b2c3acfd701fe5689bf0666a9adcbde8e4e (diff)
downloadspace-plat-hs-b3e0ace3ca198cacd8d77c6ca0f2c457826dee63.tar.gz
space-plat-hs-b3e0ace3ca198cacd8d77c6ca0f2c457826dee63.zip
Revisited the game over sequence
Diffstat (limited to 'src/Game/Entities/Player.hs')
-rw-r--r--src/Game/Entities/Player.hs18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/Game/Entities/Player.hs b/src/Game/Entities/Player.hs
index 78da30e..f0a526c 100644
--- a/src/Game/Entities/Player.hs
+++ b/src/Game/Entities/Player.hs
@@ -58,11 +58,13 @@ updateVertical isBlocked jump down e
| otherwise = e
updatePlayer :: IORef C.Controls -> IsBlocked -> Entity -> IO Entity
-updatePlayer controls isBlocked e = do
- ctl <- readIORef controls
- pure $
- updateGravity isBlocked $
- updateVertical isBlocked ctl.a ctl.down $
- updateHorizontal isBlocked ctl.left ctl.right $
- -- left or right, but not both (keyboard)
- updateFrame ((ctl.left || ctl.right) && (ctl.left /= ctl.right)) e
+updatePlayer controls isBlocked e
+ | e.dir /= Dying = do
+ ctl <- readIORef controls
+ pure $
+ updateGravity isBlocked $
+ updateVertical isBlocked ctl.a ctl.down $
+ updateHorizontal isBlocked ctl.left ctl.right $
+ -- left or right, but not both (keyboard)
+ updateFrame ((ctl.left || ctl.right) && (ctl.left /= ctl.right)) e
+ | otherwise = pure $ updateGravity (\_ _ -> False) e