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/Robot.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/Robot.hs')
-rw-r--r-- | src/Game/Entities/Robot.hs | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/Game/Entities/Robot.hs b/src/Game/Entities/Robot.hs index 39b63aa..dd3404a 100644 --- a/src/Game/Entities/Robot.hs +++ b/src/Game/Entities/Robot.hs @@ -6,8 +6,8 @@ import Game.Entities.Const import Game.Entities.Types import qualified Game.Sprites as S -mkRobot :: S.SpriteSheet -> Int -> Int -> Collision -> IsBlocked -> IO () -> IO Entity -mkRobot sprites x y playerCollision isBlocked hitPlayer' = do +mkRobot :: S.SpriteSheet -> Int -> Int -> Collision -> IsBlocked -> IO Entity +mkRobot sprites x y playerCollision isBlocked = do s <- S.get sprites "robot" pure Entity @@ -20,16 +20,16 @@ mkRobot sprites x y playerCollision isBlocked hitPlayer' = do gravity = gravityOff, dir = DirRight, sprite = s, - update = updateRobot playerCollision isBlocked hitPlayer', + update = updateRobot playerCollision isBlocked, destroy = False, - spawns = [] + actions = [] } -updateRobot :: Collision -> IsBlocked -> IO () -> Entity -> IO Entity -updateRobot touchedPlayer isBlocked hitPlayer' e = do +updateRobot :: Collision -> IsBlocked -> Entity -> IO Entity +updateRobot touchedPlayer isBlocked e = do touched <- touchedPlayer e let updated = updateFrame True e - 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 |