Tweak pause camera movement

This commit is contained in:
2023-04-25 10:23:43 +01:00
parent a2ad7c23ff
commit 734d74af52
31 changed files with 97 additions and 114 deletions
+5 -14
View File
@@ -2,9 +2,9 @@ module Dodge.Creature.YourControl (
yourControl,
) where
import Dodge.WASD
import Dodge.Base.You
import Dodge.Creature.Impulse.UseItem
import Data.Foldable
import qualified Data.Map.Strict as M
import Data.Maybe
import Dodge.Base.Coordinate
@@ -74,7 +74,7 @@ wasdWithAiming w speed cr
| movDir == V2 0 0 = id
| otherwise = crMvForward speed
theTurn cr' = creatureTurnTowardDir (_crMvAim cr') 0.2 cr'
movDir = wasdDir w
movDir = wasdDir (w ^. input)
dir = fmap ((w ^. wCam . camRot) +) (safeArgV movDir)
movAbs = rotateV (w ^. wCam . camRot) $ normalizeV movDir
isAiming = _posture (_crStance cr) == Aiming
@@ -92,16 +92,6 @@ aimTurn a cr = creatureTurnTowardDir a (x * 0.2) cr
itRef <- cr ^? crManipulation . manObject . inInventory . ispItem
cr ^? crInv . ix itRef . itUse . heldAim . aimTurnSpeed
wasdM :: SDL.Scancode -> Point2
wasdM scancode = case scancode of
SDL.ScancodeW -> V2 0 1
SDL.ScancodeS -> V2 0 (-1)
SDL.ScancodeD -> V2 1 0
SDL.ScancodeA -> V2 (-1) 0
_ -> V2 0 0
wasdDir :: World -> Point2
wasdDir = foldl' (flip $ (+.+) . wasdM) (V2 0 0) . M.keys . _pressedKeys . _input
-- | Set posture according to mouse presses.
mouseActionsCr :: M.Map SDL.MouseButton Int -> Creature -> Creature
@@ -128,5 +118,6 @@ pressedMBEffectsTopInventory pkeys w
_ -> False
isDown but = but `M.member` pkeys
theinput = w ^. input
rotation = fromMaybe 0
$ angleBetween (theinput ^. mousePos) <$> (theinput ^. heldPos . at SDL.ButtonMiddle)
rotation = maybe 0
(angleBetween (theinput ^. mousePos))
(theinput ^. heldPos . at SDL.ButtonMiddle)