diff options
author | dusoleil <howcansocksbereal@gmail.com> | 2022-07-23 10:48:05 -0400 |
---|---|---|
committer | dusoleil <howcansocksbereal@gmail.com> | 2022-07-23 10:48:05 -0400 |
commit | b1d3ff55329758f413864f68608c20ef33202a5c (patch) | |
tree | 61a8556c132ff818757366f4ce6f2791f008be13 | |
parent | 2a5aa7dc898b57d58e941d24b03a1d83ff9ddd81 (diff) | |
download | chicken-chaser-gd-b1d3ff55329758f413864f68608c20ef33202a5c.tar.gz chicken-chaser-gd-b1d3ff55329758f413864f68608c20ef33202a5c.zip |
Move all of the mouse consumption and aggregation
-rw-r--r-- | MouseInput.gd | 17 | ||||
-rw-r--r-- | Player.gd | 16 |
2 files changed, 17 insertions, 16 deletions
diff --git a/MouseInput.gd b/MouseInput.gd index e47e3c7..5805a02 100644 --- a/MouseInput.gd +++ b/MouseInput.gd @@ -9,3 +9,20 @@ func get_mouse_movement(): func add_mouse_movement(relative): mouse_movement += relative + +func _ready(): + Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED) + +func _notification(what): + if what == MainLoop.NOTIFICATION_WM_FOCUS_OUT: + Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE) + +func _input(event): + if event.is_action_pressed("ui_cancel"): + Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE) + if Input.get_mouse_mode() == Input.MOUSE_MODE_VISIBLE: + if event.is_action_pressed("click"): + Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED) + else: + if event is InputEventMouseMotion: + add_mouse_movement(event.relative) @@ -43,19 +43,3 @@ func _physics_process(delta): rotate(right, stick.y * stick.z * d_ang_speed) rotate(Vector3.UP, stick.x * stick.z * d_ang_speed) -func _ready(): - Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED) - -func _notification(what): - if what == MainLoop.NOTIFICATION_WM_FOCUS_OUT: - Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE) - -func _input(event): - if event.is_action_pressed("ui_cancel"): - Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE) - if Input.get_mouse_mode() == Input.MOUSE_MODE_VISIBLE: - if event.is_action_pressed("click"): - Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED) - else: - if event is InputEventMouseMotion: - MouseInput.add_mouse_movement(event.relative) |