Make creatures rotate when falling down chasms

This commit is contained in:
2026-04-10 10:25:09 +01:00
parent c861de8981
commit b197e22de7
4 changed files with 21 additions and 6 deletions
+8 -2
View File
@@ -2,6 +2,7 @@
module Dodge.Creature.State.WalkCycle (updateCarriage) where
import qualified Quaternion as Q
import Dodge.Creature.Radius
import Geometry
import Dodge.Update.Camera.Rotate
@@ -32,7 +33,7 @@ updateCarriage' cid cr w = \case
& tocr . crStance . carriage . zSpeed
%~ if cr ^. crPos . _z < 17 then min 0.05 . (+0.001) else max (-0.05) . subtract 0.001
Boosting {} -> w
Falling {} ->
Falling {_fallRot = q} ->
let v = 0.95 *^ (cr ^. crOldPos - oop & _z -~ 0.5)
ep = cr ^. crPos + v
in if ep ^. _z < 0 && cr ^. crOldPos . _z >= 0 &&
@@ -41,6 +42,8 @@ updateCarriage' cid cr w = \case
then w & tocr . crPos .~ (ep & _z .~ 0)
& cWorld . lWorld . creatures . ix cid . crStance . carriage .~ OnGround
else w & cWorld . lWorld . creatures . ix cid . crPos .~ ep
& cWorld . lWorld . creatures . ix cid . crStance . carriage . fallDir *~ q
OnGround {} -> w
& tocr . crPos . _xy +~ 0.8 *^ (cr ^. crOldPos . _xy - oop ^. _xy)
& chasmTestCliffPush groundCliffPush cr
@@ -106,7 +109,10 @@ chasmTestCliffPush f' cr w
& soundContinue (CrChasm (_crID cr)) (cr ^. crPos . _xy) debrisS (Just 100)
& tocr . crPos . _xy +~ f' cr (xy:xys) -- (f cr (xy:xys)) *^ h xy xys
& chasmRotate cr (uncurry (-) xy)
| any f (w ^. cWorld . chasms) = w & tocr . crStance . carriage .~ Falling -- %~ startFalling
| any f (w ^. cWorld . chasms) = w & tocr . crStance . carriage
.~ Falling
(Q.axisAngle (0 & _xy .~ vNormal (cr^.crOldOldPos._xy - cr^.crOldPos._xy)) 0.03)
Q.qid
| otherwise = w
where
cxy = cr ^. crPos . _xy
+3 -2
View File
@@ -1,6 +1,7 @@
{-# LANGUAGE LambdaCase #-}
module Dodge.Creature.Update (updateCreature) where
import qualified Quaternion as Q
import Dodge.Creature.Picture
import Dodge.Base.You
import Control.Monad
@@ -127,9 +128,9 @@ startDeathTimer cr = cr
toDeathCarriage :: Carriage -> Carriage
toDeathCarriage = \case
Flying {} -> Falling
Flying {} -> Falling Q.qid Q.qid
Walking -> OnGround
_ -> Falling
_ -> Falling Q.qid Q.qid
-- could look at the amount of damage here (given by maxDamage) too
corpseOrGib :: Creature -> World -> World