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/Pickup.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/Pickup.hs')
-rw-r--r-- | src/Game/Entities/Pickup.hs | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/Game/Entities/Pickup.hs b/src/Game/Entities/Pickup.hs index 4aa7326..7c1937c 100644 --- a/src/Game/Entities/Pickup.hs +++ b/src/Game/Entities/Pickup.hs @@ -5,8 +5,8 @@ import Game.Entities.Const import Game.Entities.Types import qualified Game.Sprites as S -mkBattery :: S.SpriteSheet -> Int -> Int -> Collision -> IO () -> IO Entity -mkBattery sprites x y playerCollision collectedBattery' = do +mkBattery :: S.SpriteSheet -> Int -> Int -> Collision -> IO Entity +mkBattery sprites x y playerCollision = do s <- S.get sprites "battery" pure Entity @@ -19,15 +19,15 @@ mkBattery sprites x y playerCollision collectedBattery' = do gravity = gravityOff, dir = DirRight, sprite = s, - update = updateBattery playerCollision collectedBattery', + update = updateBattery playerCollision, destroy = False, - spawns = [] + actions = [] } -updateBattery :: Collision -> IO () -> Entity -> IO Entity -updateBattery touchedPlayer collectedBattery' e = do +updateBattery :: Collision -> Entity -> IO Entity +updateBattery touchedPlayer e = do touched <- touchedPlayer e - if touched then e {destroy = True} <$ collectedBattery' else pure updateBatteryFrame + pure $ if touched then e {destroy = True, actions = [ActionAddBattery]} else updateBatteryFrame where updateBatteryFrame :: Entity updateBatteryFrame |