-- import Linear.V3
import Data.List
import Data.Function
-import qualified Data.Map as M
-import Data.Map ((!))
+import qualified Data.Map.Strict as M
+import Data.Map.Strict ((!))
import qualified Data.Set as S
type Block = (V3 Int, V3 Int)
dropBlock :: [Block] -> Block -> [Block]
dropBlock resting block = resting ++ [over both (^-^ (V3 0 0 fallDistance)) block]
- where _2xy = alongside _xy _xy
- blockPlane = block ^. _2xy
- under = filter ((intersectsXY blockPlane) . (view _2xy)) resting
+ where -- _2xy = alongside _xy _xy
+ -- blockPlane = block ^. _2xy
+ blockPlane = over both (view _xy) block
+ -- under = filter ((intersectsXY blockPlane) . (view _2xy)) resting
+ under = filter ((intersectsXY blockPlane) . (over both (view _xy))) resting
highestUnder = maxZ under
fallDistance = block ^. _1 . _z - highestUnder - 1
vertexP :: Parser (V3 Int)
blocksP = blockP `sepBy` endOfLine
-blockP = cubify <$> (vertexP <* "~") <*> vertexP
+blockP = cubify <$> vertexP <* "~" <*> vertexP
where cubify (V3 x1 y1 z1) (V3 x2 y2 z2) =
( (V3 (min x1 x2) (min y1 y2) (min z1 z2))
, (V3 (max x1 x2) (max y1 y2) (max z1 z2))