From eefa785ec82076308b399cbb651cfb966954f6d4 Mon Sep 17 00:00:00 2001 From: Logan Date: Mon, 1 May 2023 10:18:40 -0600 Subject: Dynamically determine camera limits based on background size. --- scripts/camera.gd | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'scripts') diff --git a/scripts/camera.gd b/scripts/camera.gd index 9204a08..9c04d29 100644 --- a/scripts/camera.gd +++ b/scripts/camera.gd @@ -3,6 +3,13 @@ extends Camera2D @onready var basketball = $"../Basketball" @onready var hoop = $"../Hoop" +func _ready(): + var bg = $"../Background/Court" + limit_right = bg.get_rect().size.x + bg.get_rect().position.x + bg.position.x + limit_left = -bg.get_rect().size.x - bg.get_rect().position.x + bg.position.x + limit_bottom = bg.get_rect().size.y + bg.get_rect().position.y + bg.position.y + limit_top = -bg.get_rect().size.y - bg.get_rect().position.y + bg.position.y + func _process(_delta): if !basketball.waiting_for_shoot: position = (basketball.position + hoop.position) / 2 -- cgit v1.2.3