Simplify walk cycle (may decrease frame rate?)

This commit is contained in:
2025-06-19 13:48:53 +01:00
parent e6bb6fb1f3
commit add192741c
2 changed files with 11 additions and 12 deletions
+6 -8
View File
@@ -1,4 +1,5 @@
{-# LANGUAGE LambdaCase #-}
module Dodge.Creature.State.WalkCycle (
updateWalkCycle,
footstepSideEffect,
@@ -11,30 +12,27 @@ import Sound.Data
updateWalkCycle :: Stance -> Stance
updateWalkCycle s = case s ^. carriage of
Walking x ff | x > maxStride -> s & carriage .~ Walking 0 (normalGait ff)
Walking x ff | x > s ^. strideLength -> s & carriage .~ Walking 0 (normalGait ff)
_ -> s
where
maxStride = s ^. strideLength
normalGait :: FootForward -> FootForward
normalGait = \case
normalGait = \case
LeftForward -> RightForward
WasLeftForward -> RightForward
RightForward -> LeftForward
WasRightForward -> LeftForward
footstepSideEffect :: Creature -> World -> World
footstepSideEffect cr = case cr ^. crStance . carriage of
footstepSideEffect cr = over (cWorld . lWorld . creatures . ix (cr ^. crID) . crStance) updateWalkCycle .
case cr ^. crStance . carriage of
Walking x ff
| x > maxStride ->
| x > cr ^. crStance . strideLength ->
soundMultiFrom
[FootstepSound i | i <- [0 .. 10]]
(cr ^. crPos)
(chooseFootSound ff)
Nothing
_ -> id
where
maxStride = _strideLength (_crStance cr)
chooseFootSound :: FootForward -> SoundID
chooseFootSound LeftForward = foot1S