Improve bullet hit detection

This commit is contained in:
2026-04-13 20:26:34 +01:00
parent b8bec2c830
commit 431e64fbfb
8 changed files with 59 additions and 17 deletions
+11
View File
@@ -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