(wip) Rehauled main menu / game loading logic

This commit is contained in:
2026-02-07 17:26:17 +01:00
parent bef1e9cb53
commit 49d9489ede
4 changed files with 22 additions and 3 deletions

View File

@@ -4,6 +4,12 @@ var screen_size = Vector2(1920.0, 1080.0) # Default screen size (this is a floa
var viewport_size
@onready var extent: Rect2 = get_viewport().get_visible_rect()
# Main menu & game spawning
@onready
var mainMenuScene = preload("res://main_menu.tscn").instantiate()
@onready
var gameScene = preload("res://molecular/molecular_stage.tscn").instantiate()
# utils.
var rng = RandomNumberGenerator.new()
var eps: float = 1e-4
@@ -23,8 +29,12 @@ var t: float = 0.0
func _ready() -> void:
# Create viewport
viewport_size = get_viewport().get_visible_rect().size
# Create game (main menu)
add_child(mainMenuScene)
# initial world current
get_new_flow()
@@ -35,6 +45,9 @@ func _physics_process(delta: float) -> void:
if abs(fmod(t, flowT)) < eps:
get_new_flow()
func start_game() -> void:
remove_child(mainMenuScene)
add_child(gameScene)
# TODO: This needs to be called from a script inheriting a CharacterBody2D (e.g. the player)
# Alternative would be to pass the player reference to this script (which might be better?)