diff options
Diffstat (limited to 'scripts/camera.gd')
-rw-r--r-- | scripts/camera.gd | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/scripts/camera.gd b/scripts/camera.gd index de8b20c..f44e430 100644 --- a/scripts/camera.gd +++ b/scripts/camera.gd @@ -4,8 +4,20 @@ onready var basketball = $"../Basketball" onready var hoop = $"../Hoop" func _process(_delta): - position = (basketball.position + hoop.position) / 2 - if (basketball.position.distance_to(hoop.position) + (basketball.drag_radius * 3)) > limit_right: + if !basketball.waiting_for_shoot: + position = (basketball.position + hoop.position) / 2 + adjust_zoom() + +func adjust_zoom(): + if !basketball.waiting_for_shoot and (basketball.position.distance_to(hoop.position) + (basketball.drag_radius * 3)) > limit_right: set_zoom(Vector2(1, 1) * ((basketball.position.distance_to(hoop.position) + (basketball.drag_radius * 3)) / limit_right)) + elif basketball.waiting_for_shoot and (basketball.start_position.distance_to(hoop.position) + (basketball.drag_radius * 3)) > limit_right: + set_zoom(Vector2(1, 1) * ((basketball.start_position.distance_to(hoop.position) + (basketball.drag_radius * 3)) / limit_right)) else: set_zoom(Vector2(1, 1)) + var zoom_level = get_zoom() + set_zoom(Vector2(clamp(zoom_level.x, 1, 1.94), clamp(zoom_level.y, 1, 1.94))) + +func _on_Basketball_reset(): + position = (basketball.start_position + hoop.position) / 2 + adjust_zoom() |