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/Exit.hs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/Game/Entities/Exit.hs') diff --git a/src/Game/Entities/Exit.hs b/src/Game/Entities/Exit.hs index b87c115..206bfaa 100644 --- a/src/Game/Entities/Exit.hs +++ b/src/Game/Entities/Exit.hs @@ -5,6 +5,9 @@ import Game.Entities.Const import Game.Entities.Types import qualified Game.Sprites as S +closingDoorSet :: Int +closingDoorSet = 1 + mkExit :: S.SpriteSheet -> Int -> Int -> Collision -> IO Entity mkExit sprites x y playerCollision = do s <- S.get sprites "exit" @@ -15,6 +18,7 @@ mkExit sprites x y playerCollision = do y = y, delay = frameDelay, frame = 0, + set = 0, jumping = False, gravity = gravityOff, dir = DirRight, @@ -27,9 +31,9 @@ mkExit sprites x y playerCollision = do updateExit :: Collision -> Entity -> IO Entity updateExit touchedPlayer e -- right is the set 0, left set 1 - | e.dir == DirRight = do + | e.set /= closingDoorSet = do touched <- if e.frame < fullyOpen then pure False else touchedPlayer e - pure $ if touched then e {dir = DirLeft, frame = 0, actions = [ActionExitStarted]} else updateLoop + pure $ if touched then e {set = closingDoorSet, frame = 0, actions = [ActionExitStarted]} else updateLoop | otherwise = pure updateOnce where fullyOpen :: Int -- cgit v1.2.3