initial project setup

This commit is contained in:
Haze Weathers 2025-12-09 14:43:30 -06:00
commit 40ebde624c
13 changed files with 296 additions and 0 deletions

36
globals/scene_stack.gd Normal file
View file

@ -0,0 +1,36 @@
extends Node
## The stack of scenes.
var scenes: Array[Node]
func _enter_tree() -> void:
scenes.push_back(get_tree().current_scene)
## Pushes a new scene onto the stack. It will replace the current scene until it is popped.
func push_scene(scene: Node) -> void:
scenes.push_back(scene)
get_tree().current_scene = scene
get_tree().scene_changed.emit()
## Pops the current scene off the stack, returning to the scene below it. If there are no
## scenes left, the game quits.
func pop_scene() -> void:
scenes.pop_back().queue_free()
if scenes.is_empty():
get_tree().quit()
return
get_tree().current_scene = scenes.back()
get_tree().scene_changed.emit()
## Swaps the current scene with a new scene.
func swap_scene(scene: Node) -> void:
scenes.pop_back().queue_free()
scenes.push_back(scene)
get_tree().current_scene = scene
get_tree().scene_changed.emit()