feat(title): FSM IDLE/STARTING amb START per jugador i propagació de StartingPlayers
This commit is contained in:
1 parent
1fc3ab8e31
commit
ca64115bfe
9 files changed
+143
-26
No files matched your search
@@ -251,19 +251,18 @@ Director::Director() {
|
||||
std::cout << "Director: start_scene=" << DebugConfig::toString(START)
|
||||
<< " starting_players=" << DebugConfig::toString(STARTING_PLAYERS) << '\n';
|
||||
|
||||
// El branch Release inicialitza STARTING_PLAYERS amb una constant
|
||||
// literal i clang considera la captura redundant; en Debug el valor és
|
||||
// runtime i la captura sí és imprescindible. La lambda viu dins de
|
||||
// IntroScene, més enllà del scope d'aquest ctor — capturar per
|
||||
// referència seria UB.
|
||||
// NOLINTNEXTLINE(clang-diagnostic-unused-lambda-capture)
|
||||
auto make_game = [STARTING_PLAYERS]() -> std::unique_ptr<Scene> {
|
||||
// `make_game` i `make_intro` reben `StartingPlayers` com a paràmetre
|
||||
// perquè la TitleScene tria al moment quins jugadors entren (P1, P2,
|
||||
// BOTH) segons la pulsació. La IntroScene ho reenvia a la GameScene.
|
||||
// El valor de `STARTING_PLAYERS` només s'usa com a punt d'entrada en
|
||||
// mode Debug quan saltem directament a INTRO o GAME (saltant TITLE).
|
||||
auto make_game = [](DebugConfig::StartingPlayers players) -> std::unique_ptr<Scene> {
|
||||
auto cfg = GameScene::defaultConfig();
|
||||
cfg.starting_players = STARTING_PLAYERS;
|
||||
cfg.starting_players = players;
|
||||
return std::make_unique<GameScene>(std::move(cfg));
|
||||
};
|
||||
auto make_intro = [placeholder_text, make_game]() -> std::unique_ptr<Scene> {
|
||||
return std::make_unique<IntroScene>(placeholder_text, make_game);
|
||||
auto make_intro = [placeholder_text, make_game](DebugConfig::StartingPlayers players) -> std::unique_ptr<Scene> {
|
||||
return std::make_unique<IntroScene>(placeholder_text, players, make_game);
|
||||
};
|
||||
auto make_title = [menu_title_text, placeholder_text, title_bg_surface, mini_logo_surface, make_intro]() -> std::unique_ptr<Scene> {
|
||||
return std::make_unique<TitleScene>(menu_title_text, placeholder_text, title_bg_surface, mini_logo_surface, make_intro);
|
||||
@@ -277,10 +276,10 @@ Director::Director() {
|
||||
current_scene_ = make_title();
|
||||
break;
|
||||
case DebugConfig::StartScene::INTRO:
|
||||
current_scene_ = make_intro();
|
||||
current_scene_ = make_intro(STARTING_PLAYERS);
|
||||
break;
|
||||
case DebugConfig::StartScene::GAME:
|
||||
current_scene_ = make_game();
|
||||
current_scene_ = make_game(STARTING_PLAYERS);
|
||||
break;
|
||||
}
|
||||
last_ticks_ms_ = SDL_GetTicks();
|
||||
|
||||
Reference in new issue
Block a user