diff options
author | Juan J. Martinez <jjm@usebox.net> | 2023-03-05 11:42:56 +0000 |
---|---|---|
committer | Juan J. Martinez <jjm@usebox.net> | 2023-03-09 12:21:05 +0000 |
commit | beecc1e2af08f81f5cb5d2ebb93aaef59b20fcd5 (patch) | |
tree | f0d1947e0369fdf59a1f626f953c778884873cc0 /src/Game/Entities | |
parent | ee50719de81145b5859d957da722cf183e0c8c60 (diff) | |
download | space-plat-hs-beecc1e2af08f81f5cb5d2ebb93aaef59b20fcd5.tar.gz space-plat-hs-beecc1e2af08f81f5cb5d2ebb93aaef59b20fcd5.zip |
Exit stage WIP
Diffstat (limited to 'src/Game/Entities')
-rw-r--r-- | src/Game/Entities/Exit.hs | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/Game/Entities/Exit.hs b/src/Game/Entities/Exit.hs new file mode 100644 index 0000000..075e1f4 --- /dev/null +++ b/src/Game/Entities/Exit.hs @@ -0,0 +1,31 @@ +module Game.Entities.Exit (mkExit) where + +import Game.Entities.Common +import Game.Entities.Const +import Game.Entities.Types +import qualified Game.Sprites as S + +mkExit :: S.SpriteSheet -> Int -> Int -> Collision -> IO Entity +mkExit sprites x y playerCollision = do + s <- S.get sprites "exit" + pure + Entity + { typ = TypePickup, + x = x, + y = y, + delay = frameDelay, + frame = 0, + jumping = False, + gravity = gravityOff, + dir = DirRight, + sprite = s, + update = pure . updateExit playerCollision, + destroy = False, + actions = [] + } + +updateExit :: Collision -> Entity -> Entity +updateExit _ e + | e.delay > 0 = e {delay = e.delay - 1} + | e.frame + 1 < frameLimit e = e {delay = frameDelay, frame = e.frame + 1} + | otherwise = e {delay = frameDelay, frame = 7} |