From 5b13a8c276199f3ccdfdcb0d96dd7631b7e1b1fb Mon Sep 17 00:00:00 2001 From: "Juan J. Martinez" Date: Tue, 16 May 2023 22:13:37 +0100 Subject: Use play state instead of level complete, that includes game over --- src/Game/Entities.hs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/Game/Entities.hs') diff --git a/src/Game/Entities.hs b/src/Game/Entities.hs index 3cb2510..6ddf589 100644 --- a/src/Game/Entities.hs +++ b/src/Game/Entities.hs @@ -71,7 +71,7 @@ addExit es x y = do updateAll :: Entities -> GS.State -> IO (Entities, GS.State) updateAll es state = do -- update the player first (including the reference), unless the level is completed - updatedPlayer <- if state.levelCompleted /= GS.ExitOff then pure player else player.update player + updatedPlayer <- if state.playState /= GS.InPlay then pure player else player.update player void $ writeIORef es.player updatedPlayer -- then the other entities updated <- (updatedPlayer :) <$> traverse (updateFilter $ state.hitDelay > 0) others @@ -111,12 +111,12 @@ updateAll es state = do processActions s' ents' t ActionExitStarted -> processActions - s {GS.levelCompleted = GS.ExitStarted} + s {GS.playState = GS.ExitStarted} -- 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 + ActionEntryDone -> processActions s {GS.playState = GS.InPlay} ents t + ActionExitDone -> processActions s {GS.playState = GS.ExitDone} ents t ActionAddBlast x y d playerCollision isBlocked -> do blast <- mkBlast es.sprites x y d playerCollision isBlocked processActions s (ents ++ [blast]) t @@ -156,7 +156,7 @@ render renderer es state = do -- always render player last -- won't draw all the frames if the player was hit -- or we are exiting the level - if testBit state.hitDelay 2 || state.levelCompleted /= GS.ExitOff then pure () else renderOne player + if testBit state.hitDelay 2 || state.playState /= GS.InPlay then pure () else renderOne player where player = head es.entities others = tail es.entities -- cgit v1.2.3