crystal-bit / godot-game-template

Generic template for Godot games
MIT License
598 stars 47 forks source link

Idea: allow loader stages after scene loads, before it starts #65

Open Iftahh opened 2 years ago

Iftahh commented 2 years ago

Idea: After pre_start, but before start the scene can add more "in-scene" stages to the progress-bar.

I think the pre_start function can be used for this, and maybe using yield to advance the progress bar (coroutines style) or by emitting signals.

I guess that in order to have proper progress-bar the number of "in-scene" stages need to be known before the scene is loaded, which is tricky, a simple solution is to pass it in the params, but I hope there is a more elegant solution.

Example use case: The gameplay.tscn scene generates procedural level in the pre_start func

func start_button_pressed():
     Game.change_scene("res://gameplay.tscn",  
                                          { "show_progress_bar": true, 
                                             "in_scene_stages": 5    # tell the progess bar to reserve 5 extra stages
                                           })

# in gameplay.gd
func pre_start(params):
    generate_maze()
    yield()   # advance stage...  or use signal and wait for idle frame?
    generate_tiles()
    yield()
    generate_treasure()
    yield()
    generate_monsters()
    yield()
    generate_doors()

func start():
    play_start_game_sound()
davcri commented 2 years ago

Hi @Iftahh, thanks for taking time explaining your suggestion!

I would split the problem in 2 separate issues: