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