From 1b05eefc7a5a4fb688d7b631529324ca08ed1a16 Mon Sep 17 00:00:00 2001 From: "Juan J. Martinez" Date: Wed, 1 Mar 2023 23:11:31 +0000 Subject: Untangle state changes into actions WIP: still unclear if we really need the IORefs! --- src/Game/Entities/Common.hs | 20 -------------------- 1 file changed, 20 deletions(-) (limited to 'src/Game/Entities/Common.hs') 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 -- cgit v1.2.3