2026-04-13 11:34:00 -05:00
|
|
|
extends Camera2D
|
|
|
|
|
|
2026-04-20 13:03:39 -05:00
|
|
|
var is_controlling_camera: bool = false
|
2026-04-13 11:34:00 -05:00
|
|
|
var is_dragging: bool = false
|
|
|
|
|
|
2026-04-20 13:03:39 -05:00
|
|
|
|
|
|
|
|
func _input(event: InputEvent) -> void:
|
|
|
|
|
if event.is_action_pressed("camera_engage"):
|
|
|
|
|
is_controlling_camera = true
|
|
|
|
|
elif event.is_action_released("camera_engage"):
|
|
|
|
|
is_controlling_camera = false
|
|
|
|
|
return
|
|
|
|
|
if !is_controlling_camera:
|
|
|
|
|
return
|
|
|
|
|
if event.is_action_pressed("camera_drag"):
|
|
|
|
|
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
|
|
|
|
|
is_dragging = true
|
|
|
|
|
elif event.is_action_released("camera_drag"):
|
|
|
|
|
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
|
|
|
|
|
is_dragging = false
|
|
|
|
|
|
|
|
|
|
if event.is_action_pressed("zoom_in"):
|
|
|
|
|
zoom *= Vector2(1.25, 1.25)
|
|
|
|
|
elif event.is_action_pressed("zoom_out"):
|
|
|
|
|
zoom *= Vector2(0.75, 0.75)
|
|
|
|
|
|
|
|
|
|
if is_dragging:
|
|
|
|
|
if event is InputEventMouseMotion:
|
|
|
|
|
position = lerp(position, event.screen_velocity, 0.01)
|