Fix direction stuttering bug
This commit is contained in:
@@ -76,18 +76,21 @@ creatureTurnTo p cr
|
||||
vToTarg = p -.- _crPos cr
|
||||
dirToTarget = argV vToTarg
|
||||
|
||||
-- the following is perhaps not ideal because it mixes normalizeAngle with
|
||||
-- angleVV, but it seems to work
|
||||
creatureTurnTowardDir
|
||||
:: Float -- ^ Angle
|
||||
-> Float -- ^ Turn speed
|
||||
-> Creature
|
||||
-> Creature
|
||||
creatureTurnTowardDir a turnSpeed cr
|
||||
| vToTarg == V2 0 0 = cr -- this should deal with the angleVV error
|
||||
| errorAngleVV 3 vToTarg (unitVectorAtAngle (_crDir cr)) <= turnSpeed
|
||||
= cr & crDir .~ dirToTarget
|
||||
| isLeftOfA (normalizeAngle dirToTarget) (normalizeAngle $ _crDir cr) = cr & crDir +~ turnSpeed
|
||||
| otherwise = cr & crDir -~ turnSpeed
|
||||
| normalizeAngle (abs (a - cdir)) <= turnSpeed
|
||||
= cr & crDir .~ dirToTarget
|
||||
| isLeftOfA (normalizeAngle dirToTarget) (normalizeAngle $ _crDir cr)
|
||||
= cr & crDir +~ turnSpeed
|
||||
| otherwise = cr & crDir -~ turnSpeed
|
||||
where
|
||||
cdir = _crDir cr
|
||||
vToTarg = rotateV a (V2 1 0)
|
||||
dirToTarget = argV vToTarg
|
||||
|
||||
|
||||
+12
-21
@@ -100,19 +100,17 @@ bpVector = V.fromList $ 0 : [0 .. 18]
|
||||
|
||||
movementSideEff :: Creature -> World -> World
|
||||
movementSideEff cr w
|
||||
| hasJetPack
|
||||
= case cr ^? crStance . carriage of
|
||||
Just (Boosting v)
|
||||
-> makeFlameletTimed
|
||||
(oldPos +.+ (_crRad cr + 3) *.* unitVectorAtAngle (_crDir cr + pi))
|
||||
20
|
||||
(momentum +.+ 1 *.* rotateV randDir (vInverse v))
|
||||
Nothing
|
||||
1
|
||||
20
|
||||
$ set randGen g
|
||||
w
|
||||
_ -> w
|
||||
| hasJetPack = case cr ^? crStance . carriage of
|
||||
Just (Boosting v)
|
||||
-> makeFlameletTimed
|
||||
(oldPos +.+ (_crRad cr + 3) *.* unitVectorAtAngle (_crDir cr + pi))
|
||||
20
|
||||
(momentum +.+ 1 *.* rotateV randDir (vInverse v))
|
||||
Nothing
|
||||
1
|
||||
20
|
||||
$ set randGen g w
|
||||
_ -> w
|
||||
| otherwise = footstepSideEffect cr w
|
||||
where
|
||||
hasJetPack = any (\it -> it ^? itIdentity == Just JetPack) $ _crInv cr
|
||||
@@ -124,9 +122,6 @@ movementSideEff cr w
|
||||
(randDir,g) = randomR (-0.5,0.5) $ _randGen w
|
||||
(randAng,_) = randomR (0,2*pi) $ _randGen w
|
||||
|
||||
--crHasMoved = dist (_crPos cr) (_crOldPos cr) > 0.5
|
||||
|
||||
|
||||
invSideEff :: Creature -> World -> World
|
||||
invSideEff cr w = weaponReloadSounds cr $ IM.foldrWithKey f w (_crInv cr)
|
||||
where
|
||||
@@ -165,15 +160,11 @@ isFrictionless cr = case cr ^? crStance . carriage of
|
||||
stepItemUseCooldown :: Creature -> Creature
|
||||
stepItemUseCooldown cr = cr & crInv . ix iSel %~
|
||||
(itUseTime %~ decreaseToZero) . (wpCurWarmUp %~ decreaseToZero)
|
||||
--( over (crInv . ix iSel . itUseTime) decreaseToZero cr
|
||||
where
|
||||
iSel = _crInvSel cr
|
||||
|
||||
stepReloading :: Creature -> Creature
|
||||
stepReloading cr
|
||||
-- | crIsAiming' cr = cr
|
||||
-- | otherwise
|
||||
= over (crInv . ix iSel . wpReloadState) decreaseToZero cr
|
||||
stepReloading cr = over (crInv . ix iSel . wpReloadState) decreaseToZero cr
|
||||
where
|
||||
iSel = _crInvSel cr
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ wasdWithAiming
|
||||
-> Creature
|
||||
wasdWithAiming w speed i cr
|
||||
| isAiming = set crDir mouseDir $ theMovement cr
|
||||
| otherwise = theTurn $ theMovement cr
|
||||
| otherwise = theMovement $ theTurn cr
|
||||
where
|
||||
theMovement
|
||||
| movDir == V2 0 0 = id
|
||||
|
||||
Reference in New Issue
Block a user