-
Notifications
You must be signed in to change notification settings - Fork 0
/
GameOverHUD.gd
63 lines (45 loc) · 1.92 KB
/
GameOverHUD.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
61
62
63
extends Control
var ui_up_down_path: String = "res://assets/ui-up-down2.mp3"
var ui_accept_path: String = "res://assets/swhit.ogg"
# Called when the node enters the scene tree for the first time.
func _ready():
$VBoxContainer/RetryButton.grab_focus()
var sfx_ui_up_down: Resource = load(ui_up_down_path)
$UIAudio.stream = sfx_ui_up_down
activate(GlobalVariables.high_score, GlobalVariables.second_score,
GlobalVariables.third_score, GlobalVariables.points)
$GameOverSound.play()
$GameOverTheme.play()
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass
func _input(event):
if event is InputEventMouseMotion:
$VBoxContainer/RetryButton.release_focus()
$VBoxContainer/BackButton.release_focus()
elif (
(Input.is_action_pressed("ui_down") or Input.is_action_pressed("ui_up"))
and no_button_has_focus()
):
$VBoxContainer/BackButton.grab_focus()
if( (Input.is_action_pressed("ui_down") or Input.is_action_pressed("ui_up")) and visible):
$UIAudio.play()
elif Input.is_action_just_pressed("ui_accept") and visible:
var sfx_accept: Resource = load(ui_accept_path)
$UIAudio.stream = sfx_accept
$UIAudio.play()
func _update_score_label(high_score: int, second_score: int, third_score: int, score: int) -> void:
$ScoreLabel.text = "High Score: " + str(high_score) + "\n2nd: " + str(second_score) + "\n3rd: " + str(third_score) + "\nYour Score: " + str(score)
func no_button_has_focus() -> bool:
return (
not $VBoxContainer/RetryButton.has_focus()
and not $VBoxContainer/BackButton.has_focus()
)
func activate(high_score: int, second_score: int, third_score: int, score: int):
_update_score_label(high_score, second_score, third_score, score)
show()
$VBoxContainer/RetryButton.grab_focus()
func _on_RetryButton_pressed():
get_tree().change_scene("res://Gnop/GnopMain.tscn")
func _on_BackButton_pressed():
get_tree().change_scene("res://Menu.tscn")