From b3e0ace3ca198cacd8d77c6ca0f2c457826dee63 Mon Sep 17 00:00:00 2001 From: "Juan J. Martinez" Date: Sun, 26 Feb 2023 00:06:40 +0000 Subject: Revisited the game over sequence --- src/Game/Entities.hs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/Game/Entities.hs') diff --git a/src/Game/Entities.hs b/src/Game/Entities.hs index 71f9791..a168e83 100644 --- a/src/Game/Entities.hs +++ b/src/Game/Entities.hs @@ -51,8 +51,12 @@ updateAll es = do updated <- (updatedPlayer :) <$> traverse (updateFilter playerWasHit) others -- collect new entities new <- traverse (processSpawn es.sprites) (concatMap (\e -> e.spawns) updated) + -- is the player dead? + updated' <- do + s <- readIORef es.state + pure $ if s.lives == 0 && updatedPlayer.dir /= Dying then (head updated) {dir = Dying, gravity = gravityUp} : tail updated else updated -- clear spawns (new entities), filter out destroyed entities, and add the new ones - pure es {entities = map (\e -> e {spawns = []}) (filter (\e -> not e.destroy) updated) ++ new} + pure es {entities = map (\e -> e {spawns = []}) (filter (\e -> not e.destroy) updated') ++ new} where player = head es.entities others = tail es.entities -- cgit v1.2.3