Record whether a mouse click is continued or not

This commit is contained in:
2022-06-22 17:02:57 +01:00
parent ac0948cb64
commit 698ccb414d
18 changed files with 350 additions and 335 deletions
+5 -4
View File
@@ -12,7 +12,8 @@ import Geometry
import Control.Lens
import qualified SDL
import qualified Data.Set as S
--import qualified Data.Set as S
import qualified Data.Map.Strict as M
--import qualified Data.IntMap.Strict as IM
--import Data.Maybe
{- | The AI equivalent for your control. -}
@@ -34,7 +35,7 @@ wasdWithAiming
-> Creature
wasdWithAiming w speed cr
| isAiming = addAnyTwist $ set crDir mouseDir $ theMovement cr
| crIsReloading cr && SDL.ButtonRight `S.member` _mouseButtons w
| crIsReloading cr && SDL.ButtonRight `M.member` _mouseButtons w
= addAnyTwist $ set crDir (mouseDir + anytwist) $ theMovement cr
| otherwise = theMovement $ theTurn $ removeTwist cr
where
@@ -70,9 +71,9 @@ wasdDir :: World -> Point2
wasdDir = foldr ((+.+) . wasdM) (V2 0 0) . _keys
{- | Set posture according to mouse presses. -}
mouseActionsCr :: S.Set SDL.MouseButton -> Creature -> Creature
mouseActionsCr :: M.Map SDL.MouseButton Bool -> Creature -> Creature
mouseActionsCr pkeys cr
| rbPressed = cr & crStance . posture .~ Aiming
| otherwise = cr & crStance . posture .~ AtEase
where
rbPressed = SDL.ButtonRight `S.member` pkeys
rbPressed = SDL.ButtonRight `M.member` pkeys