From 11d2ed7f15a86dd465bc3456e3478e9ff03bf5d2 Mon Sep 17 00:00:00 2001 From: "Juan J. Martinez" Date: Tue, 21 Mar 2023 21:28:25 +0000 Subject: Introduce a set property Stopped abusing the direction property! --- src/Game/Entities/Robot.hs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/Game/Entities/Robot.hs') diff --git a/src/Game/Entities/Robot.hs b/src/Game/Entities/Robot.hs index dd3404a..44fc310 100644 --- a/src/Game/Entities/Robot.hs +++ b/src/Game/Entities/Robot.hs @@ -16,6 +16,7 @@ mkRobot sprites x y playerCollision isBlocked = do y = y, delay = frameDelay, frame = 0, + set = toSpriteSet DirRight, jumping = False, gravity = gravityOff, dir = DirRight, @@ -36,10 +37,10 @@ updateRobot touchedPlayer isBlocked e = do | testBit ent.delay 1 = ent | ent.dir == DirLeft && (isBlocked (ent.x - 1) (ent.y + 17) || isBlocked (ent.x - 1) (ent.y + 17) || not (isBlocked (ent.x - 1) (ent.y + 24))) = - ent {dir = DirRight} + ent {dir = DirRight, set = toSpriteSet DirRight} | ent.dir == DirLeft = ent {x = ent.x - 1} | ent.dir == DirRight && (isBlocked (ent.x + 16) (ent.y + 17) || isBlocked (ent.x + 16) (ent.y + 17) || not (isBlocked (ent.x + 16) (ent.y + 24))) = - ent {dir = DirLeft} + ent {dir = DirLeft, set = toSpriteSet DirLeft} | ent.dir == DirRight = ent {x = ent.x + 1} | otherwise = ent -- cgit v1.2.3