Rotate camera on chasm edges

This commit is contained in:
2026-02-08 14:32:30 +00:00
parent db24b0ffa6
commit 1d85ee6330
4 changed files with 56 additions and 27 deletions
+10 -8
View File
@@ -6,6 +6,7 @@ module Dodge.Update.Camera (
updateCamera,
) where
import Dodge.Update.Camera.Rotate
import Linear.V3
import Dodge.Creature.Radius
import Bound
@@ -226,14 +227,15 @@ rotateToOverlappingWall w =
p = you w ^. crPos . _xy
doWallRotate :: Wall -> World -> World
doWallRotate wl w
| b - b' > 0.01 = w & wCam . camRot +~ 0.01
| b - b' < negate 0.01 = w & wCam . camRot -~ 0.01
| otherwise = w
where
a = argV (uncurry (-.-) $ _wlLine wl) - w ^. wCam . camRot
b = a * (4 / pi) -- for 8 way cardinal orientation wrt wall
b' = fromIntegral (round b :: Int)
doWallRotate = rotateTo8 . argV . uncurry (-) . _wlLine
--doWallRotate wl w = rotateTo8
-- | b - b' > 0.01 = w & wCam . camRot +~ 0.01
-- | b - b' < negate 0.01 = w & wCam . camRot -~ 0.01
-- | otherwise = w
-- where
-- a = argV (uncurry (-.-) $ _wlLine wl) - w ^. wCam . camRot
-- b = a * (4 / pi) -- for 8 way cardinal orientation wrt wall
-- b' = fromIntegral (round b :: Int)
clipZoom ::
-- | Furthest viewable distance
+15
View File
@@ -0,0 +1,15 @@
module Dodge.Update.Camera.Rotate (rotateTo8) where
import Dodge.Data.World
import Control.Lens
rotateTo8 :: Float -> World -> World
rotateTo8 a' w
| b - b' > 0.01 = w & wCam . camRot +~ 0.01
| b - b' < negate 0.01 = w & wCam . camRot -~ 0.01
| otherwise = w
where
a = a' - w ^. wCam . camRot
b = a * (4 / pi) -- for 8 way cardinal orientation wrt wall
b' = fromIntegral (round b :: Int)