Improve bullet hit detection
This commit is contained in:
@@ -18,6 +18,7 @@ module Dodge.Base.Collide (
|
||||
collideCircWalls,
|
||||
overlapSegWalls,
|
||||
overlapSegCrs,
|
||||
overlapSegCrs',
|
||||
bouncePoint,
|
||||
circOnSomeWall,
|
||||
circOnAnyCr,
|
||||
@@ -35,6 +36,7 @@ module Dodge.Base.Collide (
|
||||
crHeight,
|
||||
) where
|
||||
|
||||
import Control.Applicative
|
||||
import Data.Foldable
|
||||
import qualified Data.IntMap.Strict as IM
|
||||
import Control.Lens
|
||||
@@ -66,6 +68,15 @@ overlapSegCrs sp ep = mapMaybe f
|
||||
(,cr)
|
||||
<$> fst (intersectCircSeg (cr ^. crPos . _xy) (crRad $ cr ^. crType) sp ep)
|
||||
|
||||
overlapSegCrs' :: Point2 -> Point2 -> [Creature] -> [(Point2, Creature)]
|
||||
{-# INLINE overlapSegCrs' #-}
|
||||
overlapSegCrs' sp ep = mapMaybe f
|
||||
where
|
||||
f cr =
|
||||
(,cr)
|
||||
<$> g (intersectCircSeg (cr ^. crPos . _xy) (crRad $ cr ^. crType) sp ep)
|
||||
g (a,b) = a <|> b
|
||||
|
||||
doBounce :: Float -> Point2 -> Point2 -> (Point2, Maybe Wall) -> Maybe (Point2, Point2)
|
||||
{-# INLINE doBounce #-}
|
||||
doBounce x sp ep (p, mwl) = fmap f mwl
|
||||
|
||||
Reference in New Issue
Block a user