From 7a1d4eb4481fa54753673e67532039da2b9c0b2f Mon Sep 17 00:00:00 2001 From: "Juan J. Martinez" Date: Wed, 19 Apr 2023 22:10:21 +0100 Subject: Simplified frame update When the entity hits the player we don't really need to update the frame. --- src/Game/Entities/Robot.hs | 3 +-- src/Game/Entities/Slime.hs | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) (limited to 'src/Game') 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 -- cgit v1.2.3