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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user