forked from TTalvenH/Myyra
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHUD.gd
51 lines (39 loc) · 1.02 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
extends CanvasLayer
var scorecount = 0
var fallsound = preload("res://Sounds/fall.ogg")
var fall_sounds = [fallsound]
# Called when the node enters the scene tree for the first time.
func _ready():
$GameOverLabel.hide()
$RestartButton.hide()
$QuitButton.hide()
$MessageTimer.start()
$ScoreTimer.start()
func show_message(text):
$Message.text = text
$Message.show()
$MessageTimer.start()
func start_score():
$ScoreTimer.start()
func stop_score():
$ScoreTimer.stop()
func _on_MessageTimer_timeout():
$Message.hide()
func _on_ScoreTimer_timeout():
scorecount += 1
$ScoreLabel.text = str(scorecount)
func game_over():
$ScoreTimer.stop()
get_node("../MobSpawn").stopspawn()
get_tree().call_group("mobs", "queue_free")
$GameOverLabel.show()
$RestartButton.show()
$QuitButton.show()
$AudioStreamPlayer.set_stream(fall_sounds[0])
$AudioStreamPlayer.play()
func _on_RestartButton_pressed():
$GameOverLabel.hide()
$RestartButton.hide()
get_tree().reload_current_scene()
func _on_QuitButton_pressed():
get_tree().quit()