aboutsummaryrefslogtreecommitdiff
path: root/src/Game/Entities/Slime.hs
diff options
context:
space:
mode:
authorJuan J. Martinez <jjm@usebox.net>2023-03-01 23:11:31 +0000
committerJuan J. Martinez <jjm@usebox.net>2023-03-01 23:11:31 +0000
commit1b05eefc7a5a4fb688d7b631529324ca08ed1a16 (patch)
tree52f5e126b2af0aa519a30040191a1cbdbc12f8e8 /src/Game/Entities/Slime.hs
parent6f9e98cc5cefa9b35f139d3715339d676eff18ed (diff)
downloadspace-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/Slime.hs')
-rw-r--r--src/Game/Entities/Slime.hs14
1 files changed, 7 insertions, 7 deletions
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