Introduce safeMinimumOn

This commit is contained in:
jgk
2021-07-20 04:34:28 +02:00
parent 6905c6f154
commit 58b2c8a842
5 changed files with 59 additions and 28 deletions
+9 -4
View File
@@ -98,7 +98,10 @@ zoomOutLongGun w
--currentCursorDisplacement = fromJust $ _itAttachment wp
rotCam :: World -> World
rotCam = rotateCameraL . rotateCameraR . zoomCamIn . zoomCamOut . autoZoomCam
rotCam = rotateCameraL
. rotateCameraR
. zoomCamIn . zoomCamOut
. autoZoomCam
rotateCameraL :: World -> World
rotateCameraL w
@@ -150,13 +153,15 @@ autoZoomCam w = over cameraZoom changeZoom w
scZoom = fromMaybe 1 $ yourItem w ^? itAttachment . _Just . scopeZoom
farWallDist :: Point2 -> World -> Float
{-# INLINE farWallDist #-}
farWallDist cpos w = min (halfWidth w / (horizontalMax+50) ) (halfHeight w / (verticalMax+50) )
where
horizontalMax = maximum $ map (h' (1,0)) rRays ++ map (h' (-1,0)) lRays
verticalMax = maximum $ map (h' (0,1)) tRays ++ map (h' (0,-1)) bRays
-- TODO: fix wallsAlongLine and use instead of checking against all walls
-- h p = fromMaybe p $ collidePointIndirect cpos p $ wallsAlongLine cpos p w
h p = fromMaybe p . collidePointIndirect cpos p $ _walls w
--h p = fromMaybe p $ collidePointIndirect cpos p $ wallsAlongLine cpos p w
--h p = fromMaybe p . collidePointIndirect cpos p $ _walls w
wos = wallsOnScreen w
h p = fromMaybe p $ collidePointIndirect cpos p wos
h' x p = dotV (rotateV camRot x) (p -.- cpos)
camRot = _cameraRot w
rRays = rotF [( maxViewDistance,y) | y <- zs]