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 ++++++++++++++++++--- scripts/score_label.gd | 7 +++++++ scripts/timer_label.gd | 9 +++++++++ 3 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 scripts/score_label.gd create mode 100644 scripts/timer_label.gd (limited to 'scripts') 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() diff --git a/scripts/score_label.gd b/scripts/score_label.gd new file mode 100644 index 0000000..453f468 --- /dev/null +++ b/scripts/score_label.gd @@ -0,0 +1,7 @@ +extends Label + +func _ready(): + text = "Score: " + str(global_variables.score) + +func _on_Hoop_score(): + text = "Score: " + str(global_variables.score) diff --git a/scripts/timer_label.gd b/scripts/timer_label.gd new file mode 100644 index 0000000..7a83ce9 --- /dev/null +++ b/scripts/timer_label.gd @@ -0,0 +1,9 @@ +extends Label + +func _ready(): + $Timer.start() + text = "Time: " + str($Timer.time_left) + +func _process(delta): + text = "Time: " + str($Timer.time_left) + -- cgit v1.2.3