Work on flying creature inertia

This commit is contained in:
2026-04-02 22:04:58 +01:00
parent ff903bfb3b
commit 06c7e89dee
19 changed files with 205 additions and 171 deletions
+11 -3
View File
@@ -1,6 +1,6 @@
{-# LANGUAGE LambdaCase #-}
module Dodge.Creature.State.WalkCycle (updateWalkCycle) where
module Dodge.Creature.State.WalkCycle (updateCarriage) where
import Dodge.Creature.HandPos
import Linear
@@ -9,8 +9,8 @@ import Dodge.Data.World
import Dodge.SoundLogic
import Sound.Data
updateWalkCycle :: Int -> World -> World
updateWalkCycle cid w
updateCarriage :: Int -> World -> World
updateCarriage cid w
| Just cr <- w ^? cWorld . lWorld . creatures . ix cid
, Walking x ff <- cr ^. crStance . carriage
, x >= strideLength cr =
@@ -21,7 +21,15 @@ updateWalkCycle cid w
(chooseFootSound ff)
Nothing
& over (cWorld . lWorld . creatures . ix cid . crStance . carriage) resetStride
| Just cr <- w ^? cWorld . lWorld . creatures . ix cid
, Flying _ x oop <- cr ^. crStance . carriage =
w & cWorld . lWorld . creatures . ix cid . crPos . _xy +~ x *^ f (cr ^. crOldPos . _xy - oop)
| otherwise = w
where
-- limits max speed gained through inertia
-- f = id
f v | norm v > 10 = 10 *^ signorm v
| otherwise = v
resetStride :: Carriage -> Carriage
resetStride = \case