35 lines
1.1 KiB
GDScript
35 lines
1.1 KiB
GDScript
extends Control
|
|
|
|
@export var final_score: int = 0
|
|
@export var final_highscore: int = 0
|
|
@export var total_lines: int = 0
|
|
|
|
@onready var score_label: Label = $CenterContainer/Panel/VBoxContainer/LabelScore
|
|
@onready var highscore_label: Label = $CenterContainer/Panel/VBoxContainer/LabelHighScore
|
|
@onready var lines_label: Label = $CenterContainer/Panel/VBoxContainer/LabelLines
|
|
@onready var retry_button: Button = $CenterContainer/Panel/VBoxContainer/HBoxContainer/ButtonAgain
|
|
@onready var quit_button: Button = $CenterContainer/Panel/VBoxContainer/HBoxContainer/ButtonQuit
|
|
|
|
func _ready() -> void:
|
|
_update_labels()
|
|
|
|
retry_button.pressed.connect(_on_retry_pressed)
|
|
quit_button.pressed.connect(_on_quit_pressed)
|
|
|
|
func _update_labels() -> void:
|
|
if score_label:
|
|
score_label.text = "Score: %d" % final_score
|
|
if highscore_label:
|
|
highscore_label.text = "Highscore: %d" % final_highscore
|
|
if lines_label:
|
|
lines_label.text = "Lines: %d" % total_lines
|
|
|
|
func _on_retry_pressed() -> void:
|
|
var main := get_tree().current_scene
|
|
if main and main.has_method("reset_game"):
|
|
main.reset_game()
|
|
queue_free() # remove overlay
|
|
|
|
func _on_quit_pressed() -> void:
|
|
get_tree().quit()
|