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/Entities.hs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'src/Game/Entities.hs') diff --git a/src/Game/Entities.hs b/src/Game/Entities.hs index 2cfdd76..21b6ba5 100644 --- a/src/Game/Entities.hs +++ b/src/Game/Entities.hs @@ -53,12 +53,10 @@ playerPosition (Entities _ _ entities) = where player = head entities -addExit :: Entities -> IO Entities -addExit es = do +addExit :: Entities -> Int -> Int -> IO Entities +addExit es x y = do exit <- mkExit es.sprites x y (collision es.player 24) pure es {entities = es.entities ++ [exit]} - where - (x, y) = playerPosition es updateAll :: Entities -> GS.State -> IO (Entities, GS.State) updateAll es state = do @@ -86,8 +84,8 @@ updateAll es state = do ActionAddEffect x y name -> do effect <- mkEffect es.sprites x y name processActions s (ents ++ [effect]) t - ActionAddBattery -> - processActions s {GS.batteries = s.batteries + 1} ents t + ActionAddBattery x y -> + processActions s {GS.batteries = s.batteries + 1, GS.lastBattery = (x, y)} ents t ActionHitPlayer -> do let (s', ents') = if s.lives == 1 -- cgit v1.2.3