From ec3b1f444db16ebfbbde48e20be3b92500762a57 Mon Sep 17 00:00:00 2001 From: Logan Date: Mon, 26 Sep 2022 11:15:14 -0600 Subject: Add countdown timer. --- scripts/interface.gd | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'scripts/interface.gd') diff --git a/scripts/interface.gd b/scripts/interface.gd index 453f468..138527d 100644 --- a/scripts/interface.gd +++ b/scripts/interface.gd @@ -1,7 +1,22 @@ -extends Label +extends Control + +onready var timer_label = $"Timer Label" +onready var timer = $"Timer Label/Timer" +onready var score_label = $"Score Label" func _ready(): - text = "Score: " + str(global_variables.score) + score_label.text = "Score: " + str(global_variables.score) + timer.start() + timer_label.text = "Time: " + str(timer.time_left) + $"Update Timer".start() func _on_Hoop_score(): - text = "Score: " + str(global_variables.score) + score_label.text = "Score: " + str(global_variables.score) + timer.start(timer.get_time_left() + 10) + update_timer() + +func update_timer(): + timer_label.text = "Time: " + str(round(timer.time_left)) + +func _on_Update_Timer_timeout(): + update_timer() -- cgit v1.2.3