aboutsummaryrefslogtreecommitdiff
path: root/src/Game/Entities/Exit.hs
diff options
context:
space:
mode:
authorJuan J. Martinez <jjm@usebox.net>2023-03-21 21:28:25 +0000
committerJuan J. Martinez <jjm@usebox.net>2023-03-21 21:28:25 +0000
commit11d2ed7f15a86dd465bc3456e3478e9ff03bf5d2 (patch)
treef5e6df771eb4396df13fe3cdc2d98721917a2d68 /src/Game/Entities/Exit.hs
parent1c8a22d24b14d258a9103f7b83d627359eae0da8 (diff)
downloadspace-plat-hs-11d2ed7f15a86dd465bc3456e3478e9ff03bf5d2.tar.gz
space-plat-hs-11d2ed7f15a86dd465bc3456e3478e9ff03bf5d2.zip
Introduce a set property
Stopped abusing the direction property!
Diffstat (limited to 'src/Game/Entities/Exit.hs')
-rw-r--r--src/Game/Entities/Exit.hs8
1 files changed, 6 insertions, 2 deletions
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