aboutsummaryrefslogtreecommitdiff
path: root/src/Game/Entities.hs
diff options
context:
space:
mode:
authorJuan J. Martinez <jjm@usebox.net>2023-03-05 14:55:25 +0000
committerJuan J. Martinez <jjm@usebox.net>2023-03-09 12:21:05 +0000
commit7a714cc457323bff6b4a73ec9e7b58c7a63381ec (patch)
tree23305ab55b3c79fb6bb62c3df56baa01b28890fe /src/Game/Entities.hs
parentbeecc1e2af08f81f5cb5d2ebb93aaef59b20fcd5 (diff)
downloadspace-plat-hs-7a714cc457323bff6b4a73ec9e7b58c7a63381ec.tar.gz
space-plat-hs-7a714cc457323bff6b4a73ec9e7b58c7a63381ec.zip
Exit placement on the last battery
Diffstat (limited to 'src/Game/Entities.hs')
-rw-r--r--src/Game/Entities.hs10
1 files changed, 4 insertions, 6 deletions
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