Refactor event/input
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
module Dodge.Update.UsingInput
|
||||
where
|
||||
import Dodge.Data
|
||||
|
||||
import Dodge.CreatureAction.UseItem
|
||||
|
||||
import Geometry
|
||||
|
||||
import SDL
|
||||
|
||||
import qualified Data.Set as S
|
||||
import Control.Lens
|
||||
|
||||
updateUsingInput :: World -> World
|
||||
updateUsingInput w = updatePressedButtons (_mouseButtons w) w
|
||||
|
||||
updatePressedButtons :: S.Set MouseButton -> World -> World
|
||||
updatePressedButtons keys w
|
||||
| lbPressed && rbPressed
|
||||
= useItem (_yourID w) w
|
||||
| mbPressed
|
||||
= set clickMousePos (_mousePos w) $ over cameraRot (\r-> r - rotation) w
|
||||
| otherwise
|
||||
= w
|
||||
where lbPressed = ButtonLeft `S.member` keys
|
||||
rbPressed = ButtonRight `S.member` keys
|
||||
mbPressed = ButtonMiddle `S.member` keys
|
||||
rotation = angleBetween (_mousePos w) (_clickMousePos w)
|
||||
|
||||
Reference in New Issue
Block a user