This commit is contained in:
2022-06-18 00:18:18 +01:00
parent a7c03671d3
commit 6a095d3de6
12 changed files with 49 additions and 36 deletions
+9 -8
View File
@@ -166,13 +166,13 @@ ssfold :: Foldable t => (a -> Bool) -> (a -> b -> a) -> a -> t b -> a
{-# INLINABLE ssfold #-}
ssfold p f a0 xs = foldr (\x g a -> if p a then a else g (f a x)) id xs a0
collidePointIndirect :: Point2 -> Point2 -> IM.IntMap Wall -> Maybe Point2
{-# INLINE collidePointIndirect #-}
collidePointIndirect p1 p2 = test . foldr f p2 . IM.filter wlIsOpaque
where
f wl p = fromMaybe p $ uncurry (intersectSegSeg p1 p) $ _wlLine wl
test p | p == p2 = Nothing
| otherwise = Just p
--collidePointIndirect :: Point2 -> Point2 -> IM.IntMap Wall -> Maybe Point2
--{-# INLINE collidePointIndirect #-}
--collidePointIndirect p1 p2 = test . foldr f p2 . IM.filter wlIsOpaque
-- where
-- f wl p = fromMaybe p $ uncurry (intersectSegSeg p1 p) $ _wlLine wl
-- test p | p == p2 = Nothing
-- | otherwise = Just p
collidePointIndirect' :: Point2 -> Point2 -> IM.IntMap Wall -> Maybe Point2
{-# INLINE collidePointIndirect' #-}
@@ -260,7 +260,8 @@ canSee i j w = hasLOS p1 p2 w
-- jpos = _crPos (_creatures w IM.! j)
canSeeIndirect :: Int -> Int -> World -> Bool
canSeeIndirect i j w = isNothing . collidePointIndirect ipos jpos $ wallsAlongLine ipos jpos w
canSeeIndirect i j w = any (isJust . uncurry (intersectSegSeg ipos jpos) . _wlLine)
$ IM.filter wlIsOpaque $ wallsAlongLine ipos jpos w
where
ipos = _crPos (_creatures w IM.! i)
jpos = _crPos (_creatures w IM.! j)
+1 -1
View File
@@ -48,7 +48,7 @@ halfWidth w = _windowX w / 2
halfHeight w = _windowY w / 2
-- | A box of the size of the screen in screen centered coordinates
screenBox :: Configuration -> [Point2]
screenBox w = reverse $ rectNSWE hh (-hh) (-hw) hw
screenBox w = rectNSWE hh (-hh) (-hw) hw
where
hw = halfWidth w
hh = halfHeight w