godot-game-template icon indicating copy to clipboard operation
godot-game-template copied to clipboard

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

Open Iftahh opened this issue 2 years ago • 1 comments

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()

Iftahh avatar Apr 10 '22 20:04 Iftahh

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

I would split the problem in 2 separate issues:

  • generic loader stages (this issue, harder to solve)
  • improving pre_start() behaviour on scene loading (https://github.com/crystal-bit/godot-game-template/issues/66 a simpler issue that could be fixed quickly in the main branch)

davcri avatar Apr 11 '22 13:04 davcri