Texpand/scenes/Main/main.gd
2024-08-20 16:59:16 +02:00

34 lines
1,010 B
GDScript

extends Node
@onready var scenes = $scenes
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
loadStartMenu()
func _physics_process(delta: float) -> void:
if scenes.get_children() != []:
if GLOBAL.lost and scenes.get_child(0).name == "Grid":
scoreOverview()
func loadGrid():
if $scenes/ScoreOverview != null:
$scenes/ScoreOverview.queue_free()
if $scenes/StartMenu != null:
$scenes/StartMenu.queue_free()
scenes.add_child(load("res://scenes/Grid/grid.tscn").instantiate())
$scenes/Grid.toggleButton()
func scoreOverview():
if $scenes/Grid != null:
$scenes/Grid.queue_free()
if $scenes/StartMenu != null:
$scenes/StartMenu.queue_free()
scenes.add_child(load("res://scenes/ScoreOverview/score_overview.tscn").instantiate())
func loadStartMenu():
if $scenes/ScoreOverview != null:
$scenes/ScoreOverview.queue_free()
if $scenes/Grid != null:
$scenes/Grid.queue_free()
scenes.add_child(load("res://scenes/Menu/start_menu.tscn").instantiate())