aboutsummaryrefslogtreecommitdiff
path: root/src/Game/Entities.hs
diff options
context:
space:
mode:
authorJuan J. Martinez <jjm@usebox.net>2023-03-21 21:02:45 +0000
committerJuan J. Martinez <jjm@usebox.net>2023-03-21 21:02:45 +0000
commit1c8a22d24b14d258a9103f7b83d627359eae0da8 (patch)
tree92b3d18cf689ddc0bf90028e7139354d82c2da48 /src/Game/Entities.hs
parent897bfe0f72ddc80a020a421cbe987b54716e571e (diff)
downloadspace-plat-hs-1c8a22d24b14d258a9103f7b83d627359eae0da8.tar.gz
space-plat-hs-1c8a22d24b14d258a9103f7b83d627359eae0da8.zip
Player transition into the stage
Diffstat (limited to 'src/Game/Entities.hs')
-rw-r--r--src/Game/Entities.hs6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/Game/Entities.hs b/src/Game/Entities.hs
index 8a939f4..b43ab0e 100644
--- a/src/Game/Entities.hs
+++ b/src/Game/Entities.hs
@@ -19,6 +19,7 @@ import qualified Game.Controller as C
import Game.Entities.Common
import Game.Entities.Const
import Game.Entities.Effect
+import Game.Entities.Entry
import Game.Entities.Exit
import Game.Entities.Pickup
import Game.Entities.Player
@@ -37,8 +38,10 @@ mkEntities sprites m controls = do
_ -> error "No player entity in map"
playerRef <- newIORef player
entities <- traverse (toEntity playerRef) $ sort $ filter (not . M.isPlayer) (M.objects m)
+ -- the effect of the player "warping" into the level
+ entryEffect <- mkEntry sprites player.x player.y
-- the entities list has always player first
- pure $ Entities sprites playerRef (player : entities)
+ pure $ Entities sprites playerRef (player : (entryEffect : entities))
where
toEntity :: IORef Entity -> M.Object -> IO Entity
toEntity playerRef (M.SlimeEntity x y) = mkSlime sprites x y (collision playerRef 16) (M.isBlocked m)
@@ -105,6 +108,7 @@ updateAll es state = do
-- the player is not in the action, changing the type disables collision detection
((head ents) {typ = TypeEffect} : tail ents)
t
+ ActionEntryDone -> processActions s {GS.levelCompleted = GS.ExitOff} ents t
ActionExitDone -> processActions s {GS.levelCompleted = GS.ExitDone} ents t
processActions s ents [] = pure (s, ents)