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
+8 -1
View File
@@ -2,6 +2,7 @@ module Dodge.Creature.YourControl (
yourControl,
) where
import Data.Maybe
import Data.Foldable
import qualified Data.Map.Strict as M
import Dodge.Base.Coordinate
@@ -38,7 +39,8 @@ wasdWithAiming ::
Creature ->
Creature
wasdWithAiming w speed cr
| isAiming = addAnyTwist $ set crDir mouseDir $ theMovement cr
-- | isAiming = addAnyTwist $ set crDir mouseDir $ theMovement cr
| isAiming = addAnyTwist $ aimTurn mouseDir $ theMovement cr
| crIsReloading cr && SDL.ButtonRight `M.member` _mouseButtons (_input w) =
addAnyTwist $ set crDir (mouseDir + anytwist) $ theMovement cr
| otherwise = theMovement $ theTurn $ removeTwist cr
@@ -64,6 +66,11 @@ wasdWithAiming w speed cr
Just _ -> argV $ mouseWorldPos (w ^. input) (w ^. cWorld . camPos) -.- _crPos cr
_ -> argV (_mousePos (_input w)) + (w ^. cWorld . camPos . camRot)
aimTurn :: Float -> Creature -> Creature
aimTurn a cr = creatureTurnTowardDir a (x * 0.2) cr
where
x = fromMaybe 1 $ cr ^? crInv . ix (crSel cr) . itUse . heldAim . aimTurnSpeed
wasdM :: SDL.Scancode -> Point2
wasdM scancode = case scancode of
SDL.ScancodeW -> V2 0 1