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
View File
@@ -1,5 +1,7 @@
module Dodge.Creature.Update (updateCreature) where
import Dodge.Update.Camera.Rotate
import SDL (MouseButton (..))
import Dodge.Creature.Vocalization
import RandomHelp
import Data.Maybe
@@ -128,6 +130,7 @@ chasmTest cr w
| Just (x, y) <- List.find g (w ^. cWorld . cliffs) = w
& soundContinue (CrChasm (_crID cr)) (cr ^. crPos . _xy) debrisS (Just 100)
& tocr . crPos . _xy -~ normalizeV (vNormal (x - y))
& chasmRotate cr (x - y)
| any f (w ^. cWorld . chasms) = w & tocr . crZVel -~ 0.5
| otherwise = w
where
@@ -135,6 +138,13 @@ chasmTest cr w
g = uncurry $ circOnSeg (cr ^. crPos . _xy) (crRad $ cr ^. crType)
f = circInPolygon (cr ^. crPos . _xy) (crRad $ cr ^. crType)
chasmRotate :: Creature -> Point2 -> World -> World
chasmRotate cr v w
| t = rotateTo8 (argV v) w
| otherwise = w
where
t = cr ^. crID == 0 && isNothing (w ^? input . mouseButtons . ix SDL.ButtonRight)
updatePulse :: Pulse -> Pulse
updatePulse p
| p ^. pulseProgress >= p ^. pulseRate = p & pulseProgress .~ 0