From 181f0aa422df02c14c9a4be9b59835661b3c5c07 Mon Sep 17 00:00:00 2001 From: Logan Date: Thu, 29 Sep 2022 12:37:32 -0600 Subject: Added improvements to camera logic and zooming. We'll probably want to refactor this at some point as it feels like it's a pretty rough implementation, but it works and works well enough. --- scenes/level.tscn | 2 ++ scripts/camera.gd | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/scenes/level.tscn b/scenes/level.tscn index f47ef03..1f89e81 100644 --- a/scenes/level.tscn +++ b/scenes/level.tscn @@ -25,6 +25,8 @@ limit_left = -202 limit_top = -150 limit_right = 214 limit_bottom = 120 +smoothing_enabled = true +smoothing_speed = 7.0 script = ExtResource( 6 ) [node name="Interface" parent="." instance=ExtResource( 4 )] diff --git a/scripts/camera.gd b/scripts/camera.gd index 264bc68..fb76159 100644 --- a/scripts/camera.gd +++ b/scripts/camera.gd @@ -2,3 +2,9 @@ extends Camera2D func _process(_delta): position = ($"../Basketball".position + $"../Hoop".position) / 2 + #if $"../Basketball".position.distance_to($"../Hoop".position) > limit_bottom: + #set_zoom(Vector2(1, 1) * ($"../Basketball".position.distance_to($"../Hoop".position) / limit_bottom)) + if ($"../Basketball".position.distance_to($"../Hoop".position) + $"../Basketball".drag_radius ) > limit_right: + set_zoom(Vector2(1, 1) * (($"../Basketball".position.distance_to($"../Hoop".position) + $"../Basketball".drag_radius) / limit_right)) + else: + set_zoom(Vector2(1, 1)) -- cgit v1.2.3