summaryrefslogtreecommitdiff
path: root/scripts/interface.gd
blob: 6aab7dd3d4ab7a64ad28cdd4b48a908e3d437de0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
extends CanvasLayer

var time_left = 30
var phase_index = 0

func _ready():
	update_labels()
	$Timer.start()

func _on_Hoop_score():
	time_left += 10
	update_labels()

func update_labels():
	update_timer()
	$ScoreLabel.text = "Score: " + str(global_variables.score)
	if phase_index < $"../Basketball".phase_increment.size() - 1:
		if $"../Basketball".phase_increment[phase_index] <= global_variables.score:
			phase_index += 1
	$PhaseLabel.text = "Next Phase: " + str($"../Basketball".phase_increment[phase_index] - global_variables.score)

func update_timer():
	$TimerLabel.text = "Time: " + str(time_left)

func _on_Timer_timeout():
	if time_left > 0:
		time_left -= 1
		update_timer()
	else:
		global_variables.timer_zero = true
		$Timer.stop()
		$Control.visible = true