28 lines
781 B
GDScript
28 lines
781 B
GDScript
extends VBoxContainer
|
|
|
|
#var level : PackedScene = load("res://Scenes/main.tscn")
|
|
var main_menu : PackedScene = load("res://Scenes/main_menu.tscn")
|
|
@onready
|
|
var score_label : Label = $FinalScore
|
|
|
|
func update_score() -> void:
|
|
if score_label != null:
|
|
score_label.text = "Final Score\n\n{score}".format(GameManager)
|
|
|
|
func restart():
|
|
get_tree().change_scene_to_packed(load("res://Scenes/main.tscn"))
|
|
GridManager.current_allowed_spawns.clear()
|
|
GameManager.score = 0
|
|
|
|
func back():
|
|
get_tree().change_scene_to_packed(main_menu)
|
|
GridManager.current_allowed_spawns.clear()
|
|
GameManager.score = 0
|
|
|
|
func _unhandled_input(event: InputEvent) -> void:
|
|
if event is InputEventKey:
|
|
if event.is_action_pressed("ui_accept"):
|
|
restart()
|
|
if event.is_action_pressed("ui_cancel"):
|
|
back()
|