Texpand/scenes/Main/main.gd

46 lines
1.4 KiB
GDScript

extends Node
@onready var scenes = $scenes
var fullscreen = false
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_FULLSCREEN)
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_WINDOWED)
loadStartMenu()
func _physics_process(delta: float) -> void:
if Input.is_action_just_pressed("fullscreen"):
if not fullscreen:
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_FULLSCREEN)
fullscreen = true
elif fullscreen:
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_WINDOWED)
fullscreen = false
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()
$scenes/Grid.startGame()
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())