From 5b297643dbd104a232cde6666bb9a5f956e1805c Mon Sep 17 00:00:00 2001 From: justin Date: Tue, 24 Mar 2026 11:46:36 +0000 Subject: [PATCH] Improve mouse click rotation --- src/Dodge/Data/Input.hs | 5 +++++ src/Dodge/Default/World.hs | 1 + src/Dodge/Update/Camera.hs | 2 ++ src/Dodge/Update/Input/InGame.hs | 2 +- 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Dodge/Data/Input.hs b/src/Dodge/Data/Input.hs index 48e52a79e..fc5ea6294 100644 --- a/src/Dodge/Data/Input.hs +++ b/src/Dodge/Data/Input.hs @@ -46,8 +46,13 @@ data Input = Input , _textInput :: [Either TermSignal Char] , _scrollTestFloat :: Float , _scrollTestInt :: Int + , _inputMemory :: InputMemory } +data InputMemory + = WasMouseGameRotating + | WasNotMouseGameRotating + data TermSignal = TSescape | TSreturn diff --git a/src/Dodge/Default/World.hs b/src/Dodge/Default/World.hs index 818e1a916..72e24ee1c 100644 --- a/src/Dodge/Default/World.hs +++ b/src/Dodge/Default/World.hs @@ -27,6 +27,7 @@ defaultInput = , _smoothScrollAmount = 0 , _scrollTestFloat = 1 , _scrollTestInt = 0 + , _inputMemory = WasNotMouseGameRotating } defaultWorld :: World diff --git a/src/Dodge/Update/Camera.hs b/src/Dodge/Update/Camera.hs index 0072d7b58..371fdc2a4 100644 --- a/src/Dodge/Update/Camera.hs +++ b/src/Dodge/Update/Camera.hs @@ -208,7 +208,9 @@ rotateCamera cfig w angleBetween (w ^. input . mousePos) <$> (w ^. input . heldPos . at SDL.ButtonRight) = w & wCam . camRot -~ rotation + & input . inputMemory .~ WasMouseGameRotating | _gameplay_rotate_to_wall cfig + , WasNotMouseGameRotating <- w ^. input . inputMemory , isNothing $ w ^? input . mouseButtons . ix SDL.ButtonRight = rotateToOverlappingWall w | otherwise = w diff --git a/src/Dodge/Update/Input/InGame.hs b/src/Dodge/Update/Input/InGame.hs index d3f9e3750..b88b8a924 100644 --- a/src/Dodge/Update/Input/InGame.hs +++ b/src/Dodge/Update/Input/InGame.hs @@ -427,7 +427,7 @@ updateKeysTextInputTerminal tmid u = updateKeyInGame :: Universe -> Scancode -> Int -> Universe updateKeyInGame uv sc = \case - 0 -> updateInitialPressInGame uv sc + 0 -> updateInitialPressInGame uv sc & uvWorld . input . inputMemory .~ WasNotMouseGameRotating x | x >= 30 -> updateLongPressInGame uv sc _ -> uv