Implement slowed down aim turning

This commit is contained in:
2023-01-08 11:10:42 +00:00
parent 44bb6e7e02
commit 05d081497d
11 changed files with 46 additions and 26 deletions
+9 -9
View File
@@ -1,5 +1,6 @@
module Dodge.Creature.Impulse.Movement where
import Dodge.Base
import Control.Lens
import Dodge.Creature.Statistics
import Dodge.Data.World
@@ -30,9 +31,9 @@ crMvAbsolute p' cr =
strengthFactor :: Int -> Float
strengthFactor i
| i > 9 = 1
| i > 50 = 1
| i < 1 = 0
| otherwise = 0.1 * fromIntegral i
| otherwise = 0.02 * fromIntegral i
crMvForward ::
-- | Speed
@@ -74,15 +75,14 @@ creatureTurnTowardDir ::
Creature ->
Creature
creatureTurnTowardDir a turnSpeed cr
| normalizeAngle (abs (a - cdir)) <= turnSpeed =
cr & crDir .~ dirToTarget
| isLeftOfA (normalizeAngle dirToTarget) (normalizeAngle $ _crDir cr) =
cr & crDir +~ turnSpeed
| otherwise = cr & crDir -~ turnSpeed
| abs (normalizeAnglePi (a - cdir)) <= turnSpeed = cr & crDir .~ dirToTarget
| otherwise = cr & crDir %~ addOrSub turnSpeed
where
addOrSub | isLeftOfA dirToTarget cdir = (+)
| otherwise = subtract
cdir = _crDir cr
vToTarg = rotateV a (V2 1 0)
dirToTarget = argV vToTarg
dirToTarget = argV $ rotateV a (V2 1 0)
creatureTurnToward :: Point2 -> Float -> Creature -> Creature
creatureTurnToward p turnSpeed cr