Simplify walk cycle (may decrease frame rate?)
This commit is contained in:
@@ -62,9 +62,10 @@ crUpdate f =
|
|||||||
foldCr
|
foldCr
|
||||||
[ doDamage -- these two
|
[ doDamage -- these two
|
||||||
, checkDeath -- must be in this order 24/7/22
|
, checkDeath -- must be in this order 24/7/22
|
||||||
, internalCreatureUpdate
|
-- , internalCreatureUpdate
|
||||||
, f
|
|
||||||
, footstepSideEffect
|
, footstepSideEffect
|
||||||
|
, f
|
||||||
|
-- , footstepSideEffect
|
||||||
-- , updateInv -- upInv must be called before invSideEff 22.05.23
|
-- , updateInv -- upInv must be called before invSideEff 22.05.23
|
||||||
, invRootItemEffs
|
, invRootItemEffs
|
||||||
, invSideEff
|
, invSideEff
|
||||||
@@ -425,9 +426,9 @@ updateMovement cr
|
|||||||
| isFrictionless cr = over crPos (+.+ momentum) cr
|
| isFrictionless cr = over crPos (+.+ momentum) cr
|
||||||
| otherwise = cr & crStance %~ updateWalkCycle
|
| otherwise = cr & crStance %~ updateWalkCycle
|
||||||
where
|
where
|
||||||
momentum' = 0.98 *.* (_crPos cr -.- _crOldPos cr)
|
momentum' = 0.98 *.* (_crPos cr - _crOldPos cr)
|
||||||
momentum
|
momentum
|
||||||
| magV momentum' > 1 = 1 *.* normalizeV momentum'
|
| magV momentum' > 1 = normalizeV momentum'
|
||||||
| otherwise = momentum'
|
| otherwise = momentum'
|
||||||
|
|
||||||
isFrictionless :: Creature -> Bool
|
isFrictionless :: Creature -> Bool
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
{-# LANGUAGE LambdaCase #-}
|
{-# LANGUAGE LambdaCase #-}
|
||||||
|
|
||||||
module Dodge.Creature.State.WalkCycle (
|
module Dodge.Creature.State.WalkCycle (
|
||||||
updateWalkCycle,
|
updateWalkCycle,
|
||||||
footstepSideEffect,
|
footstepSideEffect,
|
||||||
@@ -11,10 +12,8 @@ import Sound.Data
|
|||||||
|
|
||||||
updateWalkCycle :: Stance -> Stance
|
updateWalkCycle :: Stance -> Stance
|
||||||
updateWalkCycle s = case s ^. carriage of
|
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
|
_ -> s
|
||||||
where
|
|
||||||
maxStride = s ^. strideLength
|
|
||||||
|
|
||||||
normalGait :: FootForward -> FootForward
|
normalGait :: FootForward -> FootForward
|
||||||
normalGait = \case
|
normalGait = \case
|
||||||
@@ -24,17 +23,16 @@ normalGait = \case
|
|||||||
WasRightForward -> LeftForward
|
WasRightForward -> LeftForward
|
||||||
|
|
||||||
footstepSideEffect :: Creature -> World -> World
|
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
|
Walking x ff
|
||||||
| x > maxStride ->
|
| x > cr ^. crStance . strideLength ->
|
||||||
soundMultiFrom
|
soundMultiFrom
|
||||||
[FootstepSound i | i <- [0 .. 10]]
|
[FootstepSound i | i <- [0 .. 10]]
|
||||||
(cr ^. crPos)
|
(cr ^. crPos)
|
||||||
(chooseFootSound ff)
|
(chooseFootSound ff)
|
||||||
Nothing
|
Nothing
|
||||||
_ -> id
|
_ -> id
|
||||||
where
|
|
||||||
maxStride = _strideLength (_crStance cr)
|
|
||||||
|
|
||||||
chooseFootSound :: FootForward -> SoundID
|
chooseFootSound :: FootForward -> SoundID
|
||||||
chooseFootSound LeftForward = foot1S
|
chooseFootSound LeftForward = foot1S
|
||||||
|
|||||||
Reference in New Issue
Block a user