|
@@ -1,7 +1,16 @@
|
|
extends Camera2D
|
|
extends Camera2D
|
|
|
|
|
|
-export var dist_max = 900
|
|
|
|
-export var zoom_rate = 0.001
|
|
|
|
|
|
+export var zoom_border = 100
|
|
|
|
+
|
|
|
|
+var zoom_rate:float
|
|
|
|
+
|
|
|
|
+var view:Viewport
|
|
|
|
+var dist_max:float
|
|
|
|
+
|
|
|
|
+func _ready():
|
|
|
|
+ view = get_tree().root
|
|
|
|
+ view.connect("size_changed", self, "_on_size_changed")
|
|
|
|
+ update_zoom_reference()
|
|
|
|
|
|
func _process(_d):
|
|
func _process(_d):
|
|
move()
|
|
move()
|
|
@@ -40,3 +49,11 @@ func center_on(players):
|
|
new_zoom += (dist - dist_max) * zoom_rate
|
|
new_zoom += (dist - dist_max) * zoom_rate
|
|
|
|
|
|
zoom = Vector2(new_zoom, new_zoom)
|
|
zoom = Vector2(new_zoom, new_zoom)
|
|
|
|
+
|
|
|
|
+func update_zoom_reference():
|
|
|
|
+ var ref_length = min(view.size.x, view.size.y)
|
|
|
|
+ dist_max = ref_length - 2 * zoom_border
|
|
|
|
+ zoom_rate = 1.0 / dist_max
|
|
|
|
+
|
|
|
|
+func _on_size_changed():
|
|
|
|
+ update_zoom_reference()
|