Add new bullet trajectories

This commit is contained in:
2022-02-28 13:19:07 +00:00
parent 1e5f24c8a1
commit 419fcd0ff0
18 changed files with 285 additions and 101 deletions
+6 -7
View File
@@ -16,10 +16,10 @@ import Geometry
--import Picture
import qualified IntMapHelp as IM
import FoldableHelp
import qualified FoldlHelp as L
import Dodge.Base.You
import Control.Lens
import qualified Control.Foldl as L
import Data.Monoid
import Data.Maybe
--import Data.Bifunctor
@@ -97,23 +97,22 @@ wallsOnCirc p r = IM.filter f
allWalls :: World -> IM.IntMap Wall
allWalls = IM.unions . concatMap IM.elems . IM.elems . _znObjects . _wallsZone
creatureNearPoint :: Point2 -> World -> Maybe Creature
creatureNearPoint p = L.fold (L.minimumOn (dist p . _crPos)) . creaturesNearPoint p
creaturesNearPoint :: Point2 -> World -> IM.IntMap Creature
creaturesNearPoint p w = IM.unions
[f b $ f a $ _znObjects $ _creaturesZone w | a<-[x-1,x,x+1] , b<-[y-1,y,y+1]]
where
(x,y) = crZoneOfPoint p
f i m = case IM.lookup i m of
Just val -> val
_ -> IM.empty
f i m = fromMaybe IM.empty $ IM.lookup i m
creaturesNearPointI :: Int -> Point2 -> World -> IM.IntMap Creature
creaturesNearPointI n p w = IM.unions
[f b $ f a $ _znObjects $ _creaturesZone w | a<-[x-n..x+n] , b<-[y-n..y+n]]
where
(x,y) = crZoneOfPoint p
f i m = case IM.lookup i m of
Just val -> val
_ -> IM.empty
f i m = fromMaybe IM.empty $ IM.lookup i m
-- possible BUG, occurs when used in thingsHitLongLine
creaturesAlongLine :: Point2 -> Point2 -> World -> IM.IntMap Creature