-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHUD.gd
60 lines (41 loc) · 1.12 KB
/
HUD.gd
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
extends CanvasLayer
signal start_game
signal name_change
func show_message(text):
$MessageLabel.text = text
$MessageLabel.show()
$MessageTimer.start()
func show_hint(text):
$HintLabel.text = text
$HintLabel.show()
$HintTimer.start()
func show_game_over():
show_message("Game Over")
yield($MessageTimer, "timeout")
$MessageLabel.text = "Survive"
$MessageLabel.show()
yield(get_tree().create_timer(1), "timeout")
$ScoreList.hide()
$StartButton.show()
func update_score(score):
$ScoreLabel.text = str(score)
func update_time(time):
$TimeLabel.text = str(time)
func sort_score(a, b):
return a[1] > b[1]
func show_high_scores(highScores):
var top = []
for player in highScores:
top.append([player, highScores[player]])
top.sort_custom(self, "sort_score")
$ScoreList.text = "Top Ghosts\n----------------------\n"
for score in top.slice(0, 2):
$ScoreList.text += score[0] + "\t" + str(score[1]) + "\n"
$ScoreList.show()
func _on_StartButton_pressed():
$StartButton.hide()
emit_signal("start_game")
func _on_MessageTimer_timeout():
$MessageLabel.hide()
func _on_HintTimer_timeout():
$HintLabel.hide()