Continue tweaking movement, remove _crMvAim

This commit is contained in:
2026-04-03 20:50:41 +01:00
parent 47ecfb7fd3
commit dc30f7ca15
9 changed files with 18 additions and 15 deletions
+1 -1
View File
@@ -39,7 +39,7 @@ crMvAbsolute :: LWorld -> Point2 -> Creature -> Creature
crMvAbsolute lw p' cr =
cr
& crPos . _xy +~ p
& crMvDir .~ argV p
& crMvDir .~ argV (p + cr ^. crOldPos . _xy - cr ^. crOldOldPos . _xy)
where
p = strengthFactor (getCrMoveSpeed lw cr) *.* p'
+1 -1
View File
@@ -8,7 +8,7 @@ crMvType :: Creature -> CrMvType
crMvType cr = case _crType cr of
Avatar {} -> MvWalking 1.5
ChaseCrit {} -> defaultChaseMvType
HoverCrit {} -> defaultChaseMvType & mvSpeed .~ 0.1
HoverCrit {} -> defaultChaseMvType & mvSpeed .~ 0.15
SwarmCrit -> defaultChaseMvType
AutoCrit -> defaultAimMvType
BarrelCrit {} -> defaultAimMvType
+1 -1
View File
@@ -26,7 +26,7 @@ updateCarriage' cid cr w = \case
(chooseFootSound ff)
Nothing
& over (cWorld . lWorld . creatures . ix cid . crType) resetStride
& tocr . crPos +~ 0.1 *^ (cr ^. crOldPos - oop)
& tocr . crPos +~ 0.5 *^ (cr ^. crOldPos - oop)
_ -> w & tocr . crPos +~ 0.5 *^ (cr ^. crOldPos - oop)
Floating -> w
Flying {_zSpeed = dz, _flyInertia = x} ->
+6 -5
View File
@@ -117,7 +117,8 @@ wasdAim inp w cr
setposture Aiming (-twoHandTwistAmount)
| SDL.ButtonRight `M.member` _mouseButtons inp = aimTurn (w ^. cWorld . lWorld) mousedir cr
| Aiming{} <- cr ^. crStance . posture = setposture AtEase twoHandTwistAmount
| otherwise = creatureTurnTowardDir (_crMvAim cr) 0.2 cr
-- | otherwise = creatureTurnTowardDir (_crMvAim cr) 0.2 cr
| otherwise = creatureTurnTowardDir (_crMvDir cr) 0.2 cr
where
setposture x r =
cr
@@ -134,11 +135,11 @@ twoHandTwistAmount :: Float
twoHandTwistAmount = 1.6 * pi
wasdMovement :: LWorld -> Input -> Camera -> Float -> Creature -> Creature
wasdMovement lw inp cam speed = theMovement . setMvAim
wasdMovement lw inp cam speed = theMovement -- . setMvAim
where
setMvAim = fromMaybe id $ do
dir <- safeArgV movDir
return $ crMvAim .~ (cam ^. camRot + dir)
-- setMvAim = fromMaybe id $ do
-- dir <- safeArgV movDir
-- return $ crMvAim .~ (cam ^. camRot + dir)
movDir = wasdDir inp
movAbs = rotateV (cam ^. camRot) $ normalizeV movDir
theMovement
+1 -1
View File
@@ -39,7 +39,7 @@ data Creature = Creature
, _crZVel :: Float
, _crDir :: Float
, _crMvDir :: Float
, _crMvAim :: Float
-- , _crMvAim :: Float
, _crType :: CreatureType
, _crID :: Int
, _crHP :: CrHP
+1 -1
View File
@@ -19,7 +19,7 @@ defaultCreature =
, _crZVel = 0
, _crDir = 0
, _crMvDir = 0
, _crMvAim = 0
-- , _crMvAim = 0
-- , _crTwist = 0
, _crID = 1
, _crType = ChaseCrit 0 LeftForward 0
+2 -1
View File
@@ -26,4 +26,5 @@ spawnAt p d w = w
---- SoundStart BackgroundSound p foamSprayFadeOutS Nothing :
-- [MakeStartCloudAt (V3 x y 20 & _xy +~ p) | x <- [-5, -4 .. 5], y <- [-5, -4 .. 5]]
where
f = set (crPos . _xy) p . set crDir d . set crMvDir d . set crMvAim d . set (crPos . _z) 0 . set crZVel 0
--f = set (crPos . _xy) p . set crDir d . set crMvDir d . set crMvAim d . set (crPos . _z) 0 . set crZVel 0
f = set (crPos . _xy) p . set crDir d . set crMvDir d . set (crPos . _z) 0 . set crZVel 0
+3 -2
View File
@@ -35,13 +35,14 @@ import Data.Monoid
import RandomHelp
testStringInit :: Universe -> [String]
testStringInit u = [show p, show op, show oop, show (op - oop), show . norm $ op - oop, show d]
testStringInit u = [show p, show op', show oop, show (op' - oop), show . norm $ op' - oop, show d]
<> u ^.. tocr . crStance . carriage . to show
<> u ^.. tocr . crMvDir . to show
where
tocr = uvWorld . cWorld . lWorld . creatures . ix 0
f = fromMaybe 0
p = f $ u ^? uvWorld . cWorld . lWorld . creatures . ix 0 . crPos
op = f $ u ^? uvWorld . cWorld . lWorld . creatures . ix 0 . crOldPos
op' = f $ u ^? uvWorld . cWorld . lWorld . creatures . ix 0 . crOldPos
oop = fromMaybe 0 $ u ^? uvWorld . cWorld . lWorld . creatures . ix 0 . crOldOldPos
d = fromMaybe 0 $ u ^? uvWorld . cWorld . lWorld . creatures . ix 0 . crDir
-- u ^.. uvWorld . cWorld . lWorld . creatures . ix 1 . crActionPlan . apStrategy . to show
+2 -2
View File
@@ -280,8 +280,8 @@ functionalUpdate =
. over uvWorld (cWorld . lWorld . lClock +~ 1)
. over uvWorld updateDistortions
. over uvWorld updateCreatureSoundPositions
. over uvWorld pushYouOutFromWalls
. over uvWorld updateCreatureStrides
. over uvWorld pushYouOutFromWalls
. colCrsWalls
. over uvWorld simpleCrSprings
. over uvWorld updateDoors
@@ -374,7 +374,7 @@ updateCreatureStrides = cWorld . lWorld . creatures . each %~ updateCreatureStri
updateCreatureStride :: Creature -> Creature
updateCreatureStride cr = cr & crType . strideAmount +~ d
where
s = fromMaybe 0 $ crMvType cr ^? mvSpeed
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))