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
+2
View File
@@ -44,6 +44,8 @@ crabCrit = defaultCreature
, _footForward = LeftForward
, _strideAmount = 0
, _dodgeCooldown = 0
, _lFootPos = 0
, _rFootPos = 0
}
& crFaction .~ ColorFaction red
& crPerception . cpVision . viFOV .~ FloatFOV pi
+4 -9
View File
@@ -46,14 +46,14 @@ followImpulse cid w = \case
( crMvAbsolute (w ^. cWorld . lWorld) (10 *.* normalizeV (posFromID cid' -.- cpos)) . (crType . meleeCooldown .~ 20)
)
MeleeL cid' ->
hitCrl cid' $
hitCrd (-pi/2) cid' $
crup
-- ( crMvAbsolute (w ^. cWorld . lWorld) (vNormal $ 10 *.* normalizeV (posFromID cid' -.- cpos))
-- .
(crType . meleeCooldownL .~ 20)
-- )
MeleeR cid' ->
hitCrr cid' $
hitCrd (pi/2) cid' $
crup
--( crMvAbsolute (w ^. cWorld . lWorld) (vNormal $ (-10) *.* normalizeV (posFromID cid' -.- cpos)) .
(crType . meleeCooldownR .~ 20)
@@ -87,13 +87,8 @@ followImpulse cid w = \case
hitCr i =
cWorld . lWorld . creatures . ix i . crDamage
.:~ Blunt 100 (posFromID i) (posFromID i - cpos)
hitCrl i =
hitCrd a i =
cWorld . lWorld . creatures . ix i . crDamage
<>~ [Blunt 100 (posFromID i) (posFromID i - cpos)
, Inertial 0 (posFromID i) (50 * unitVectorAtAngle (cr ^. crDir - pi/2))
]
hitCrr i =
cWorld . lWorld . creatures . ix i . crDamage
<>~ [Blunt 100 (posFromID i) (posFromID i - cpos)
, Inertial 0 (posFromID i) (50 * unitVectorAtAngle (cr ^. crDir + pi/2))
, Inertial 0 (posFromID i) (50 * unitVectorAtAngle (cr ^. crDir + a))
]
+20 -7
View File
@@ -160,17 +160,30 @@ feet cr = case (cr ^? crType . strideAmount,cr ^? crType . footForward) of
crabFeet :: Creature -> Shape
{-# INLINE crabFeet #-}
crabFeet 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
crabFeet cr =
uncurryV translateSHxy rpos afoot
<> uncurryV translateSHxy (f (V2 0 10) rpos) afoot
<> uncurryV translateSHxy lpos afoot
<> uncurryV translateSHxy (f (V2 0 (-10)) lpos) afoot
-- <> uncurryV translateSHxy (rotateV cdir $ cr ^?! crType . lFootPos - cxy) afoot
-- <> uncurryV translateSHxy (rotateV cdir $ cxy - cr ^?! crType . lFootPos) afoot
-- 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
aFoot = upperPrismPolyST 10 $ polyCirc 3 2
rpos = rot ( cr ^?! crType . rFootPos - cxy)
rot = rotateV cdir
lpos = rot ( cr ^?! crType . lFootPos - cxy)
f p q = q + 2 *^ (p - q)
cdir = -cr ^. crDir
cxy = cr ^. crPos . _xy
-- sh x = translateSHxy x off aFoot <> translateSHxy (- x) (- off) aFoot
afoot = upperPrismPolyST 10 $ polyCirc 3 2
off = 10
sLen = strideLength cr
-- f i = 8 * (sLen - 2*i) / sLen
f i = 8 * oneSmooth ((sLen - 2*i) / sLen)
-- f i = 8 * oneSmooth ((sLen - 2*i) / sLen)
deadFeet :: Creature -> Shape
{-# INLINE deadFeet #-}