Move stride/footforward datatypes
This commit is contained in:
@@ -49,23 +49,14 @@ strideLength cr = case cr ^. crType of
|
||||
_ -> 30
|
||||
|
||||
handWalkingPos :: FootForward -> Float -> Creature -> Point3
|
||||
handWalkingPos b off cr = case cr ^. crStance . carriage of
|
||||
Walking sa ff ->
|
||||
handWalkingPos b off cr = case (cr ^? crType . strideAmount,cr ^? crType . footForward) of
|
||||
(Just sa,Just ff) ->
|
||||
let slen = strideLength cr
|
||||
f i
|
||||
| ff == b = 8 * zeroOneSmooth ((slen - i) / slen)
|
||||
| otherwise = 8 * zeroOneSmooth (i / slen)
|
||||
in V3 (f sa) off 12
|
||||
Falling sa ff ->
|
||||
let slen = strideLength cr
|
||||
f i
|
||||
| ff == b = 8 * zeroOneSmooth ((slen - i) / slen)
|
||||
| otherwise = 8 * zeroOneSmooth (i / slen)
|
||||
in V3 (f sa) off 20
|
||||
Floating -> V3 0 off 12
|
||||
Flying {} -> V3 0 off 12
|
||||
Boosting _ -> V3 0 off 12
|
||||
OnGround -> V3 0 off 12
|
||||
_ -> V3 0 off 12
|
||||
|
||||
zeroOneSmooth :: Float -> Float
|
||||
zeroOneSmooth x = (1 - cos (pi * x)) / 2
|
||||
@@ -137,14 +128,8 @@ leftHandPQ cr
|
||||
| otherwise = (handWalkingPos RightForward 8 cr, Q.qid)
|
||||
|
||||
twoHandOffY :: Creature -> Float
|
||||
twoHandOffY cr = zeroOneSmooth $ case cr ^. crStance . carriage of
|
||||
Walking sa ff ->
|
||||
let slen = strideLength cr
|
||||
f i
|
||||
| ff == RightForward = (slen - i) / slen
|
||||
| otherwise = i / slen
|
||||
in f sa
|
||||
Falling sa ff ->
|
||||
twoHandOffY cr = zeroOneSmooth $ case (cr ^? crType . strideAmount,cr ^? crType . footForward) of
|
||||
(Just sa,Just ff) ->
|
||||
let slen = strideLength cr
|
||||
f i
|
||||
| ff == RightForward = (slen - i) / slen
|
||||
@@ -175,11 +160,9 @@ legPQ' g cr =
|
||||
(0, Q.qz (_crMvDir cr - _crDir cr))
|
||||
(V3 x (g off) 0, Q.qid)
|
||||
where
|
||||
x = case cr ^? crStance . carriage of
|
||||
Just (Walking sa LeftForward) -> -f sa
|
||||
Just (Walking sa RightForward) -> f sa
|
||||
Just (Falling sa LeftForward) -> -f sa
|
||||
Just (Falling sa RightForward) -> f sa
|
||||
x = case (cr ^? crType . strideAmount,cr ^? crType . footForward) of
|
||||
(Just sa,Just LeftForward) -> -f sa
|
||||
(Just sa,Just RightForward) -> f sa
|
||||
_ -> 0
|
||||
off = -5
|
||||
sLen = strideLength cr
|
||||
|
||||
@@ -91,9 +91,9 @@ chaseUpperBody cr = colorSH (_skinUpper cskin)
|
||||
_ -> 0
|
||||
sLen = strideLength cr
|
||||
tbob = 5 * (1 - oneSmooth (abs llegpos))
|
||||
llegpos = case cr ^? crStance . carriage of
|
||||
Just (Walking sa LeftForward) -> f sa
|
||||
Just (Walking sa RightForward) -> -f sa
|
||||
llegpos = case (cr ^? crType . strideAmount,cr ^? crType . footForward) of
|
||||
(Just sa, Just LeftForward) -> f sa
|
||||
(Just sa, Just RightForward) -> -f sa
|
||||
_ -> 0
|
||||
--tbob = 2 * oneSmooth ((sLen - 2*i) / sLen)
|
||||
f i = (sLen - 2*i) / sLen
|
||||
@@ -104,9 +104,9 @@ oneSmooth x = sin (pi * x * 0.5)
|
||||
|
||||
feet :: Creature -> Shape
|
||||
{-# INLINE feet #-}
|
||||
feet cr = case cr ^? crStance . carriage of
|
||||
Just (Walking sa LeftForward) -> sh (f sa)
|
||||
Just (Walking sa RightForward) -> sh (-f sa)
|
||||
feet cr = case (cr ^? crType . strideAmount,cr ^? crType . footForward) of
|
||||
(Just sa,Just LeftForward) -> sh (f sa)
|
||||
(Just sa,Just RightForward) -> sh (-f sa)
|
||||
_ -> sh 0
|
||||
where
|
||||
sh x = translateSHxy x off aFoot <> translateSHxy (- x) (- off) aFoot
|
||||
|
||||
@@ -18,14 +18,15 @@ updateCarriage cid w = fromMaybe w $ do
|
||||
|
||||
updateCarriage' :: Int -> Creature -> World -> Carriage -> World
|
||||
updateCarriage' cid cr w = \case
|
||||
Walking x ff | x >= strideLength cr -> w
|
||||
Walking -> case (cr ^? crType . strideAmount,cr ^? crType . footForward) of
|
||||
(Just x,Just ff) | x >= strideLength cr -> w
|
||||
& soundMultiFrom
|
||||
[FootstepSound i | i <- [0 .. 10]]
|
||||
(cr ^. crPos . _xy)
|
||||
(chooseFootSound ff)
|
||||
Nothing
|
||||
& over (cWorld . lWorld . creatures . ix cid . crStance . carriage) resetStride
|
||||
Walking {} -> w
|
||||
& over (cWorld . lWorld . creatures . ix cid . crType) resetStride
|
||||
_ -> w
|
||||
Floating -> w
|
||||
Flying {_zSpeed = dz, _flyInertia = x} ->
|
||||
w & cWorld . lWorld . creatures . ix cid . crPos . _xy +~ x *^ f (cr ^. crOldPos . _xy - oop ^. _xy)
|
||||
@@ -33,7 +34,7 @@ updateCarriage' cid cr w = \case
|
||||
& cWorld . lWorld . creatures . ix cid . crStance . carriage . zSpeed
|
||||
%~ if cr ^. crPos . _z < 17 then min 0.05 . (+0.001) else max (-0.05) . subtract 0.001
|
||||
Boosting {} -> w
|
||||
Falling _ _ ->
|
||||
Falling {} ->
|
||||
let v = 0.9 *^ (cr ^. crOldPos - oop & _z -~ 0.5)
|
||||
ep = cr ^. crPos + v
|
||||
in if ep ^. _z < 0 && not (any (pointInPoly (ep ^. _xy)) (w ^. cWorld . chasms))
|
||||
@@ -47,10 +48,10 @@ updateCarriage' cid cr w = \case
|
||||
| otherwise = v
|
||||
|
||||
|
||||
resetStride :: Carriage -> Carriage
|
||||
resetStride = \case
|
||||
Walking _ ff -> Walking 0 (normalGait ff)
|
||||
x -> x
|
||||
resetStride :: CreatureType -> CreatureType
|
||||
resetStride ct = case ct ^? footForward of
|
||||
Just _ -> ct & strideAmount .~ 0 & footForward %~ normalGait
|
||||
_ -> ct
|
||||
|
||||
normalGait :: FootForward -> FootForward
|
||||
normalGait = \case
|
||||
|
||||
@@ -101,7 +101,7 @@ checkDeath' cr w = case cr ^. crHP of
|
||||
|
||||
toDeathCarriage :: Carriage -> Carriage
|
||||
toDeathCarriage = \case
|
||||
Flying {} -> Falling 0 RightForward
|
||||
Flying {} -> Falling
|
||||
x -> x
|
||||
|
||||
-- could look at the amount of damage here (given by maxDamage) too
|
||||
@@ -165,8 +165,8 @@ chasmTestLiving cr w
|
||||
|
||||
startFalling :: Creature -> Creature
|
||||
startFalling cr = case cr ^. crStance . carriage of
|
||||
Walking a b -> cr & crStance . carriage .~ Falling a b
|
||||
_ -> cr & crStance . carriage .~ Falling 0 RightForward
|
||||
Walking -> cr & crStance . carriage .~ Falling
|
||||
_ -> cr & crStance . carriage .~ Falling
|
||||
|
||||
chasmTestCorpse :: Creature -> World -> World
|
||||
chasmTestCorpse cr w
|
||||
|
||||
Reference in New Issue
Block a user