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/Slime.hs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/Game/Entities/Slime.hs') diff --git a/src/Game/Entities/Slime.hs b/src/Game/Entities/Slime.hs index 5ca6fe7..1f50927 100644 --- a/src/Game/Entities/Slime.hs +++ b/src/Game/Entities/Slime.hs @@ -6,8 +6,8 @@ import Game.Entities.Const import Game.Entities.Types import qualified Game.Sprites as S -mkSlime :: S.SpriteSheet -> Int -> Int -> Collision -> IsBlocked -> IO () -> IO Entity -mkSlime sprites x y playerCollision isBlocked hitPlayer' = do +mkSlime :: S.SpriteSheet -> Int -> Int -> Collision -> IsBlocked -> IO Entity +mkSlime sprites x y playerCollision isBlocked = do s <- S.get sprites "slime" pure Entity @@ -20,16 +20,16 @@ mkSlime sprites x y playerCollision isBlocked hitPlayer' = do gravity = gravityOff, dir = DirRight, sprite = s, - update = updateSlime playerCollision isBlocked hitPlayer', + update = updateSlime playerCollision isBlocked, destroy = False, - spawns = [] + actions = [] } -updateSlime :: Collision -> IsBlocked -> IO () -> Entity -> IO Entity -updateSlime touchedPlayer isBlocked hitPlayer' e = do +updateSlime :: Collision -> IsBlocked -> Entity -> IO Entity +updateSlime touchedPlayer isBlocked e = do touched <- touchedPlayer e let updated = updateSlimeFrame - if touched then fmap (const e) hitPlayer' else pure $ updateMovement updated + pure $ if touched then updated {actions = [ActionHitPlayer]} else updateMovement updated where updateMovement :: Entity -> Entity updateMovement ent -- cgit v1.2.3