Tweak pause camera movement
This commit is contained in:
+21
-14
@@ -5,6 +5,7 @@ module Dodge.Update.Camera (
|
||||
updateCamera,
|
||||
) where
|
||||
|
||||
import Dodge.WASD
|
||||
import Dodge.SmoothScroll
|
||||
import SDL (MouseButton (..))
|
||||
import Dodge.Base.Coordinate
|
||||
@@ -32,13 +33,13 @@ updateCamera :: Configuration -> World -> World
|
||||
updateCamera cfig w = case w ^. wCam . camControl of
|
||||
CamInGame -> updateInGameCamera cfig w
|
||||
CamFloat -> updateFloatingCamera cfig w
|
||||
CamPan -> w
|
||||
|
||||
updateFloatingCamera :: Configuration -> World -> World
|
||||
updateFloatingCamera cfig w = w
|
||||
& updateBounds cfig
|
||||
& wCam %~ setViewDistance cfig
|
||||
& wCam %~ translateFloatingCamera theinput
|
||||
& wCam %~ translateFloatingCameraKeys theinput
|
||||
& wCam %~ zoomFloatingCamera theinput
|
||||
where
|
||||
theinput = w ^. input
|
||||
@@ -55,17 +56,23 @@ translateFloatingCamera theinput cam = fromMaybe cam $ do
|
||||
return $ cam & camCenter +~ thetran
|
||||
& camViewFrom +~ thetran
|
||||
|
||||
translateFloatingCameraKeys :: Input -> Camera -> Camera
|
||||
translateFloatingCameraKeys theinput = (camCenter -~ thetran)
|
||||
. (camViewFrom -~ thetran)
|
||||
where
|
||||
thetran = 10 *.* wasdDir theinput
|
||||
|
||||
zoomFloatingCamera :: Input -> Camera -> Camera
|
||||
zoomFloatingCamera theinput cam = cam
|
||||
& camZoom *~ (zoomSpeed ^^ negate (getSmoothScrollValue theinput))
|
||||
-- & camZoom *~ (zoomSpeed ^^ negate (theinput ^. smoothScrollAmount))
|
||||
|
||||
zoomFloatingCamera theinput cam
|
||||
| ButtonRight `M.member` (theinput ^. mouseButtons) = cam
|
||||
& camZoom *~ (zoomSpeed ^^ negate (getSmoothScrollValue theinput))
|
||||
| otherwise = cam
|
||||
|
||||
updateInGameCamera :: Configuration -> World -> World
|
||||
updateInGameCamera cfig w =
|
||||
w
|
||||
& updateBounds cfig
|
||||
& over (wCam) (setViewDistance cfig)
|
||||
& over wCam (setViewDistance cfig)
|
||||
& wCam %~ moveZoomCamera cfig (w ^. input) (you w)
|
||||
& updateScopeZoom
|
||||
& rotateCamera cfig
|
||||
@@ -140,12 +147,12 @@ updateScopeZoom' i w
|
||||
doScopeZoom :: Int -> Point2 -> Scope -> Scope
|
||||
doScopeZoom scrollamount mp sc = case scrollamount of
|
||||
x
|
||||
| x > 10 -> (zoomInLongGun mp . zoomInLongGun mp . zoomInLongGun mp) $ sc
|
||||
| x > 5 -> (zoomInLongGun mp . zoomInLongGun mp) $ sc
|
||||
| x > 0 -> zoomInLongGun mp $ sc
|
||||
| x < -10 -> (zoomOutLongGun . zoomOutLongGun . zoomOutLongGun) $ sc
|
||||
| x < -5 -> (zoomOutLongGun . zoomOutLongGun) $ sc
|
||||
| x < 0 -> zoomOutLongGun $ sc
|
||||
| x > 10 -> (zoomInLongGun mp . zoomInLongGun mp . zoomInLongGun mp) sc
|
||||
| x > 5 -> (zoomInLongGun mp . zoomInLongGun mp) sc
|
||||
| x > 0 -> zoomInLongGun mp sc
|
||||
| x < -10 -> (zoomOutLongGun . zoomOutLongGun . zoomOutLongGun) sc
|
||||
| x < -5 -> (zoomOutLongGun . zoomOutLongGun) sc
|
||||
| x < 0 -> zoomOutLongGun sc
|
||||
| otherwise -> sc
|
||||
|
||||
zoomSpeed :: Float
|
||||
@@ -220,8 +227,8 @@ rotateCameraBy x w =
|
||||
rotateCamera :: Configuration -> World -> World
|
||||
rotateCamera cfig w
|
||||
| keydown SDL.ScancodeQ && keydown SDL.ScancodeE = w
|
||||
| keydown SDL.ScancodeQ = (rotateCameraBy 0.025) w
|
||||
| keydown SDL.ScancodeE = (rotateCameraBy (-0.025)) w
|
||||
| keydown SDL.ScancodeQ = rotateCameraBy 0.025 w
|
||||
| keydown SDL.ScancodeE = rotateCameraBy (-0.025) w
|
||||
| otherwise = ifConfigWallRotate cfig w
|
||||
where
|
||||
keydown scode = scode `M.member` _pressedKeys (_input w) && not (inInputFocus w)
|
||||
|
||||
Reference in New Issue
Block a user