From 15fac3db6ef8852f84d3a3166abd9041c87674a3 Mon Sep 17 00:00:00 2001 From: justin Date: Wed, 27 Oct 2021 00:15:26 +0100 Subject: [PATCH] Allow for destruction of blocks again --- src/Dodge/Initialisation.hs | 4 +++- src/Dodge/Update.hs | 11 ++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/Dodge/Initialisation.hs b/src/Dodge/Initialisation.hs index f4070f6f0..bc86ef753 100644 --- a/src/Dodge/Initialisation.hs +++ b/src/Dodge/Initialisation.hs @@ -64,8 +64,10 @@ zonedBlockWalls = concatMap f . IM.toList . _znObjects . _wallsZone g (y,zs) = show y testStringInit :: World -> [String] +testStringInit _ = [] --testStringInit w = map (show . _blWallIDs) . IM.elems $ _blocks w -testStringInit w = (map (f w) . filter g . IM.elems $ _walls w) +--testStringInit w = (map (f w) . filter g . IM.elems $ _walls w) +-- ++ map (show . fst) (IM.toList $ _znObjects $ _wallsZone w) -- ++ zonedBlockWalls w where g Block{} = True diff --git a/src/Dodge/Update.hs b/src/Dodge/Update.hs index 006a6ccc4..21a2e2b88 100644 --- a/src/Dodge/Update.hs +++ b/src/Dodge/Update.hs @@ -85,16 +85,17 @@ updateBlocks w = foldr f w $ _blocks w where f bl w' | head (_blHPs bl) < 1 = w' - & blocks %~ IM.delete (_blID bl) & walls %~ removeIDs (_blWallIDs bl) --- & flip (foldr removeFromZone) (_blWallIDs bl) + & flip (foldr removeFromZone) (_blWallIDs bl) + & blocks %~ IM.delete (_blID bl) | otherwise = w' removeIDs is wls = foldr IM.delete wls is - --removeFromZone wlid w' = over (wallsZone . znObjects . ix x . ix y) (IM.delete (_wlID wl)) w' - removeFromZone wlid w' = over (wallsZone . znObjects . ix x . ix y . ix (_wlID wl)) setCol w' + removeFromZone wlid w' = over (wallsZone . znObjects . ix x . ix y) (IM.delete (_wlID wl)) w' + --removeFromZone wlid w' = set (wallsZone . znObjects) IM.empty w' + --removeFromZone wlid w' = over (wallsZone . znObjects . ix x . ix y . ix (_wlID wl)) setCol w' where (x,y) = zoneOfPoint $ uncurry pHalf (_wlLine wl) - wl = _walls w' IM.! wlid + wl = _walls w IM.! wlid setCol = wlColor .~ V4 1 1 0 1 -- | Note the explict use of record syntax. Using lens creates a space leak.