summaryrefslogtreecommitdiff
path: root/scripts/interface.gd
blob: d61b8d5cc7426cdcbc8342d8591b9ae5b8e451cc (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
33
34
35
36
37
38
extends CanvasLayer

var time_left = 30
var phase_index = 0
var phase_type = ["RANDOM", "INCREASED RANGE"]
var paused = false

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
			$Difficulty/ChangeLabel.text = phase_type[$"../Basketball".phase - 1]
			$Difficulty/AnimationPlayer.play("blinking")
	var phase_difference = $"../Basketball".phase_increment[phase_index] - global_variables.score
	if phase_difference >= 0:
		$PhaseLabel.text = "Next Phase: " + str($"../Basketball".phase_increment[phase_index] - global_variables.score)

func update_timer():
	$TimerLabel.set_text("%03d" % time_left)

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