(wip) Rehauled main menu / game loading logic
This commit is contained in:
@@ -4,6 +4,12 @@ var screen_size = Vector2(1920.0, 1080.0) # Default screen size (this is a floa
|
|||||||
var viewport_size
|
var viewport_size
|
||||||
@onready var extent: Rect2 = get_viewport().get_visible_rect()
|
@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.
|
# utils.
|
||||||
var rng = RandomNumberGenerator.new()
|
var rng = RandomNumberGenerator.new()
|
||||||
var eps: float = 1e-4
|
var eps: float = 1e-4
|
||||||
@@ -23,8 +29,12 @@ var t: float = 0.0
|
|||||||
|
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
|
# Create viewport
|
||||||
viewport_size = get_viewport().get_visible_rect().size
|
viewport_size = get_viewport().get_visible_rect().size
|
||||||
|
|
||||||
|
# Create game (main menu)
|
||||||
|
add_child(mainMenuScene)
|
||||||
|
|
||||||
# initial world current
|
# initial world current
|
||||||
get_new_flow()
|
get_new_flow()
|
||||||
|
|
||||||
@@ -35,6 +45,9 @@ func _physics_process(delta: float) -> void:
|
|||||||
if abs(fmod(t, flowT)) < eps:
|
if abs(fmod(t, flowT)) < eps:
|
||||||
get_new_flow()
|
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)
|
# 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?)
|
# Alternative would be to pass the player reference to this script (which might be better?)
|
||||||
|
|||||||
@@ -2,4 +2,4 @@ extends Control
|
|||||||
|
|
||||||
|
|
||||||
func _on_play_button_pressed() -> void:
|
func _on_play_button_pressed() -> void:
|
||||||
get_tree().change_scene_to_file("res://molecular/molecular_stage.tscn")
|
GameManager.start_game()
|
||||||
|
|||||||
6
evolve-die-repeat/main_scene.tscn
Normal file
6
evolve-die-repeat/main_scene.tscn
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
[gd_scene format=3 uid="uid://b8gt8os2m28lv"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" uid="uid://vsbibc5fanou" path="res://game_manager.gd" id="1_0f027"]
|
||||||
|
|
||||||
|
[node name="MainScene" type="Node" unique_id=1897047571]
|
||||||
|
script = ExtResource("1_0f027")
|
||||||
@@ -15,7 +15,7 @@ compatibility/default_parent_skeleton_in_mesh_instance_3d=true
|
|||||||
[application]
|
[application]
|
||||||
|
|
||||||
config/name="EvolveDieRepeat"
|
config/name="EvolveDieRepeat"
|
||||||
run/main_scene="uid://drgv154ei1vrl"
|
run/main_scene="uid://b8gt8os2m28lv"
|
||||||
config/features=PackedStringArray("4.6", "Forward Plus")
|
config/features=PackedStringArray("4.6", "Forward Plus")
|
||||||
config/icon="res://icon.svg"
|
config/icon="res://icon.svg"
|
||||||
|
|
||||||
@@ -25,7 +25,7 @@ GameManager="*res://game_manager.gd"
|
|||||||
|
|
||||||
[editor_plugins]
|
[editor_plugins]
|
||||||
|
|
||||||
enabled=PackedStringArray("res://addons/godot-neovim/plugin.cfg")
|
enabled=PackedStringArray()
|
||||||
|
|
||||||
[global_group]
|
[global_group]
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user