Work on flying creature inertia
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user