Add basic booster

This commit is contained in:
jgk
2021-05-24 13:59:51 +02:00
parent cda035b1d1
commit 968273bf25
20 changed files with 276 additions and 324 deletions
+2 -6
View File
@@ -19,7 +19,7 @@ hasLOS p1 p2 w = not $ pointHitsWalls p1 p2 $ wallsAlongLine p1 p2 w
reflectPointWalls :: Point2 -> Point2 -> IM.IntMap Wall -> Maybe (Point2,Point2)
reflectPointWalls p1 p2 ws
= listToMaybe
. sortOn f
. sortOn (dist p1 . fst)
. IM.elems
$ IM.mapMaybe
(( \(x,y) ->
@@ -29,8 +29,6 @@ reflectPointWalls p1 p2 ws
(intersectSegSeg' p1 p2 x y)
)
. _wlLine) ws
where
f (a,_) = magV (p1 -.- a)
-- | Looks for first collision of a point with walls.
-- If found, gives point and reflection velocity, reflection damped in normal.
reflectPointWallsDamped
@@ -41,7 +39,7 @@ reflectPointWallsDamped
-> Maybe (Point2,Point2)
reflectPointWallsDamped dfact p1 p2 ws
= listToMaybe
. sortOn f
. sortOn (dist p1 . fst)
. IM.elems
$ IM.mapMaybe
(( \(x,y) -> fmap ((, reflectInParam dfact (x -.- y) (p2 -.- p1))
@@ -49,8 +47,6 @@ reflectPointWallsDamped dfact p1 p2 ws
(intersectSegSeg' p1 p2 x y))
. _wlLine
) ws
where
f (a,_) = magV (p1 -.- a)
-- | Test if a point collides with walls
pointHitsWalls :: Point2 -> Point2 -> IM.IntMap Wall -> Bool
pointHitsWalls p1 p2