diff options
author | Juan J. Martinez <jjm@usebox.net> | 2023-03-01 23:11:31 +0000 |
---|---|---|
committer | Juan J. Martinez <jjm@usebox.net> | 2023-03-01 23:11:31 +0000 |
commit | 1b05eefc7a5a4fb688d7b631529324ca08ed1a16 (patch) | |
tree | 52f5e126b2af0aa519a30040191a1cbdbc12f8e8 /src/Game/Entities/Common.hs | |
parent | 6f9e98cc5cefa9b35f139d3715339d676eff18ed (diff) | |
download | space-plat-hs-1b05eefc7a5a4fb688d7b631529324ca08ed1a16.tar.gz space-plat-hs-1b05eefc7a5a4fb688d7b631529324ca08ed1a16.zip |
Untangle state changes into actions
WIP: still unclear if we really need the IORefs!
Diffstat (limited to 'src/Game/Entities/Common.hs')
-rw-r--r-- | src/Game/Entities/Common.hs | 20 |
1 files changed, 0 insertions, 20 deletions
diff --git a/src/Game/Entities/Common.hs b/src/Game/Entities/Common.hs index ca5eb78..2e447f5 100644 --- a/src/Game/Entities/Common.hs +++ b/src/Game/Entities/Common.hs @@ -2,8 +2,6 @@ module Game.Entities.Common ( toSpriteSet, frameLimit, collision, - hitPlayer, - collectedBattery, updateFrame, updateGravity, ) @@ -13,8 +11,6 @@ import Data.IORef import Game.Entities.Const import Game.Entities.Types import qualified Game.Sprites as S -import qualified Game.State as GS -import SDL (($~)) -- | Convert direction into a sprite set. toSpriteSet :: Dir -> Int @@ -40,22 +36,6 @@ collision playerRef otherHeight other = do && player.y + otherHeight - 4 < other.y + otherHeight && other.y + 4 < player.y + 24 --- | Update game state to reflect that the player was hit by an enemy. -hitPlayer :: IORef GS.State -> IO () -hitPlayer stateRef = - stateRef $~ updatePlayerHit - where - updatePlayerHit :: GS.State -> GS.State - 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 () -collectedBattery stateRef = - stateRef $~ (\s -> s {GS.batteries = s.batteries + 1}) - -- | Update frame animation for entities that have direction. updateFrame :: Bool -> Entity -> Entity updateFrame updated e |