clockwork-city/prefabs/game_camera.gd
duncgibbs a9352d337d
Some checks failed
linting & formatting / build (push) Failing after 24s
way too many changes; multiplayer version, like, 0.6 or 0.7
2026-04-20 13:03:39 -05:00

30 lines
818 B
GDScript

extends Camera2D
var is_controlling_camera: bool = false
var is_dragging: bool = false
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)