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)
|
||||
|
||||
@@ -78,7 +78,7 @@ updatePressedButtonsCarte' pkeys w
|
||||
where
|
||||
isDown but = but `M.member` pkeys
|
||||
mbutpos but = theinput ^. heldPos . at but
|
||||
rot = fromMaybe 0 $ angleBetween (_mousePos (_input w)) <$> mbutpos SDL.ButtonLeft
|
||||
rot = maybe 0 (angleBetween (_mousePos (_input w))) $ mbutpos SDL.ButtonLeft
|
||||
czoom = fromMaybe 1 $ do
|
||||
p <- mbutpos SDL.ButtonLeft
|
||||
return $ magV (_mousePos theinput) / magV p
|
||||
@@ -110,7 +110,7 @@ updateInitialPressInGame :: Universe -> Scancode -> Universe
|
||||
updateInitialPressInGame uv sc = case sc of
|
||||
ScancodeF1 -> useNormalCamera uv
|
||||
ScancodeF2 -> pauseAndFloatCam uv
|
||||
ScancodeF3 -> pauseAndPanCam uv
|
||||
-- ScancodeF3 -> pauseAndPanCam uv
|
||||
ScancodeF5 -> doQuicksave uv
|
||||
ScancodeF9 -> doQuickload uv
|
||||
ScancodeEscape -> pauseGame uv
|
||||
@@ -152,7 +152,7 @@ doRegexInput u i sss
|
||||
any
|
||||
((== Just InitialPress) . (`M.lookup` pkeys))
|
||||
[ScancodeReturn, ScancodeSlash]
|
||||
endmouse = maybe False (==1) $ u ^? uvWorld . input . mouseButtons . ix ButtonLeft
|
||||
endmouse = (Just 1 == ) $ u ^? uvWorld . input . mouseButtons . ix ButtonLeft
|
||||
backspacetonothing =
|
||||
sss ^? sssExtra . sssFilters . ix i . _Just == Just ""
|
||||
&& ScancodeBackspace `M.lookup` pkeys == Just InitialPress
|
||||
|
||||
Reference in New Issue
Block a user