Simplify walk cycle (may decrease frame rate?)
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user