Work on crab feet

This commit is contained in:
2026-04-09 10:01:11 +01:00
parent 52d389f342
commit 0a8a2210c0
7 changed files with 42 additions and 21 deletions
+9 -1
View File
@@ -375,9 +375,17 @@ updateCreatureStrides = cWorld . lWorld . creatures . each %~ updateCreatureStri
updateCreatureStride :: Creature -> Creature
updateCreatureStride cr
| Walking <- cr ^. crStance . carriage = cr & crType . strideAmount +~ d
| Walking <- cr ^. crStance . carriage
, CrabCrit {} <- cr ^. crType
= cr & crType . lFootPos %~ f (g 10)
& crType . rFootPos %~ f (g (-10))
| Walking <- cr ^. crStance . carriage
, isJust $ cr ^? crType . strideAmount = cr & crType . strideAmount +~ d
| otherwise = cr
where
f p q | distance p q > 10 = p - 9 *^ signorm (q - p)
| otherwise = q
g x = cr ^. crPos . _xy + x *^ vNormal (unitVectorAtAngle (cr ^. crDir))
s = 2 * fromMaybe 1 (crMvType cr ^? mvSpeed)
-- d = min s . norm $ cr ^. crPos - cr ^. crOldPos
d = max 0 . min s $ dotV (cr ^. crPos . _xy - cr ^. crOldPos . _xy) (unitVectorAtAngle (cr ^. crMvDir))