From ccd83b474cf99b1bea16316404c87b99c2de3fde Mon Sep 17 00:00:00 2001 From: "Juan J. Martinez" Date: Sat, 18 Feb 2023 15:35:31 +0000 Subject: Slightly more readable --- src/Game/Entities.hs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Game/Entities.hs b/src/Game/Entities.hs index f45ae1a..8decf07 100644 --- a/src/Game/Entities.hs +++ b/src/Game/Entities.hs @@ -216,17 +216,17 @@ updateSlime touchedPlayer isBlocked e = do pure $ if touched then e {destroy = True} else updateMovement updated where updateMovement :: Entity -> Entity - updateMovement e' - | testBit e'.delay 1 = e' - | e'.dir == DirLeft - && (isBlocked (e'.x - 1) (e'.y + 15) || isBlocked (e'.x - 1) (e'.y + 10) || not (isBlocked (e'.x - 1) (e'.y + 16))) = - e' {dir = DirRight} - | e'.dir == DirLeft = e' {x = e'.x - 1} - | e'.dir == DirRight - && (isBlocked (e'.x + 16) (e'.y + 15) || isBlocked (e'.x + 16) (e'.y + 10) || not (isBlocked (e'.x + 16) (e'.y + 16))) = - e' {dir = DirLeft} - | e'.dir == DirRight = e' {x = e'.x + 1} - | otherwise = e' + updateMovement ent + | testBit ent.delay 1 = ent + | ent.dir == DirLeft + && (isBlocked (ent.x - 1) (ent.y + 15) || isBlocked (ent.x - 1) (ent.y + 10) || not (isBlocked (ent.x - 1) (ent.y + 16))) = + ent {dir = DirRight} + | ent.dir == DirLeft = ent {x = ent.x - 1} + | ent.dir == DirRight + && (isBlocked (ent.x + 16) (ent.y + 15) || isBlocked (ent.x + 16) (ent.y + 10) || not (isBlocked (ent.x + 16) (ent.y + 16))) = + ent {dir = DirLeft} + | ent.dir == DirRight = ent {x = ent.x + 1} + | otherwise = ent updateSlimeFrame :: Entity updateSlimeFrame | e.delay > 0 = e {delay = e.delay - 1} -- cgit v1.2.3