From 7a714cc457323bff6b4a73ec9e7b58c7a63381ec Mon Sep 17 00:00:00 2001 From: "Juan J. Martinez" Date: Sun, 5 Mar 2023 14:55:25 +0000 Subject: Exit placement on the last battery --- src/Game.hs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/Game.hs') diff --git a/src/Game.hs b/src/Game.hs index 850d6ed..31aa40b 100644 --- a/src/Game.hs +++ b/src/Game.hs @@ -63,7 +63,9 @@ initialState m = totalLives = maxLives, hitDelay = hitDelay, gameOverDelay = 0, - exit = False + exit = False, + -- doesn't matter where + lastBattery = (0, 0) } main :: IO () @@ -169,16 +171,17 @@ gameLoop e = do gameLoop updatedEnv where - -- update state counters + -- update state counters, etc updateState :: Env -> IO Env updateState env | state.gameOverDelay > 1 = pure env {state = state {GS.gameOverDelay = state.gameOverDelay - 1}} | state.batteries == state.totalBatteries && not state.exit = do - es <- E.addExit env.entities + es <- E.addExit env.entities x (y - 8) -- adjusted to player's height pure env {entities = es, state = state {GS.exit = True}} | otherwise = pure env where state = env.state + (x, y) = state.lastBattery playLoop :: Env -> IO Env playLoop e = do -- cgit v1.2.3