Start using streaming as the way to consume foldable objects

This commit is contained in:
2022-06-24 09:27:29 +01:00
parent 89dd8502ad
commit 86b1c2581b
6 changed files with 58 additions and 17 deletions
+2 -2
View File
@@ -31,7 +31,7 @@ makePoisonExplosionAt
-> World
makePoisonExplosionAt p w
= soundMultiFrom [Explosion 0,Explosion 1] p bangS Nothing
$ foldr (makeGasCloud p) w
$ foldl' (flip $ makeGasCloud p) w
$ replicateM 25 (randInCirc 2) & evalState $ _randGen w
-- just change the number after replicateM to get more or less clouds
-- suggested change: use random positions, offset from p, rather than velocities
@@ -89,7 +89,7 @@ makeExplosionAt p w = w
times = randomRs (15,20) $ _randGen w
mF q z v size time = makeFlamelet q z v Nothing size time
newFs = zipWith5 mF fPs zs (fmap (3 *.*) fVs') sizes times
addFlames w' = foldr ($) w' newFs
addFlames w' = foldl' (flip ($)) w' newFs
--pushAgainstWalls q = maybe q (uncurry (+.+)) $ reflectPointWalls p q wls
pushAgainstWalls q = maybe q fst $ reflectPointWalls p q wls
wls = wallsNearPoint p w