diff options
author | Juan J. Martinez <jjm@usebox.net> | 2023-04-19 22:10:21 +0100 |
---|---|---|
committer | Juan J. Martinez <jjm@usebox.net> | 2023-04-19 22:10:21 +0100 |
commit | 7a1d4eb4481fa54753673e67532039da2b9c0b2f (patch) | |
tree | 796b1206423dcf896b6cb98c3610210342b6848f | |
parent | 7a8af18d0e1003c26eb595b5faa71e51da6286a6 (diff) | |
download | space-plat-hs-7a1d4eb4481fa54753673e67532039da2b9c0b2f.tar.gz space-plat-hs-7a1d4eb4481fa54753673e67532039da2b9c0b2f.zip |
Simplified frame update
When the entity hits the player we don't really need to update the
frame.
-rw-r--r-- | src/Game/Entities/Robot.hs | 3 | ||||
-rw-r--r-- | src/Game/Entities/Slime.hs | 3 |
2 files changed, 2 insertions, 4 deletions
diff --git a/src/Game/Entities/Robot.hs b/src/Game/Entities/Robot.hs index 11a10c5..5cc9d70 100644 --- a/src/Game/Entities/Robot.hs +++ b/src/Game/Entities/Robot.hs @@ -30,8 +30,7 @@ mkRobot sprites x y d playerCollision isBlocked = do updateRobot :: Collision -> IsBlocked -> Entity -> IO Entity updateRobot touchedPlayer isBlocked e = do touched <- touchedPlayer e - let updated = updateFrame True e - pure $ if touched then updated {actions = [ActionHitPlayer]} else updateMovement updated + pure $ if touched then e {actions = [ActionHitPlayer]} else updateMovement $ updateFrame True e where updateMovement :: Entity -> Entity updateMovement ent diff --git a/src/Game/Entities/Slime.hs b/src/Game/Entities/Slime.hs index acbe638..0cc805b 100644 --- a/src/Game/Entities/Slime.hs +++ b/src/Game/Entities/Slime.hs @@ -30,8 +30,7 @@ mkSlime sprites x y d playerCollision isBlocked = do updateSlime :: Collision -> IsBlocked -> Entity -> IO Entity updateSlime touchedPlayer isBlocked e = do touched <- touchedPlayer e - let updated = updateSlimeFrame - pure $ if touched then updated {actions = [ActionHitPlayer]} else updateMovement updated + pure $ if touched then e {actions = [ActionHitPlayer]} else updateMovement updateSlimeFrame where updateMovement :: Entity -> Entity updateMovement ent |