diff options
author | Logan <logan@cflip.net> | 2022-09-30 19:24:01 -0600 |
---|---|---|
committer | Logan <logan@cflip.net> | 2022-09-30 19:24:01 -0600 |
commit | 78057bf535cf382e2382d6faaadb640ea1313e4d (patch) | |
tree | 7417a94b44a25ed2596df95ec2792216f27b1598 | |
parent | 4ec359af497df0059e3049529bef6d9cede2c39a (diff) |
Tweaked camera logic.
-rw-r--r-- | scenes/level.tscn | 2 | ||||
-rw-r--r-- | scripts/camera.gd | 11 |
2 files changed, 7 insertions, 6 deletions
diff --git a/scenes/level.tscn b/scenes/level.tscn index dbf4ba1..6f6dde7 100644 --- a/scenes/level.tscn +++ b/scenes/level.tscn @@ -22,7 +22,7 @@ normal = Vector2( 1, 0 ) position = Vector2( 123, 73 ) current = true limit_left = -202 -limit_top = -150 +limit_top = -202 limit_right = 214 limit_bottom = 120 smoothing_enabled = true diff --git a/scripts/camera.gd b/scripts/camera.gd index fb76159..de8b20c 100644 --- a/scripts/camera.gd +++ b/scripts/camera.gd @@ -1,10 +1,11 @@ extends Camera2D +onready var basketball = $"../Basketball" +onready var hoop = $"../Hoop" + 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)) + position = (basketball.position + hoop.position) / 2 + if (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)) else: set_zoom(Vector2(1, 1)) |