Added challenge mode

This commit is contained in:
2025-12-20 13:08:16 +01:00
parent fd29ae271e
commit 34447f0245
15 changed files with 535 additions and 1227 deletions

View File

@ -18,12 +18,18 @@ PlayingState::PlayingState(StateContext& ctx) : State(ctx) {}
void PlayingState::onEnter() {
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "[PLAYING] Entering Playing state");
// Initialize the game with the selected starting level
if (ctx.game && ctx.startLevelSelection) {
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "[PLAYING] Resetting game with level %d", *ctx.startLevelSelection);
ctx.game->reset(*ctx.startLevelSelection);
}
// Initialize the game based on mode: endless uses chosen start level, challenge keeps its run state
if (ctx.game) {
if (ctx.game->getMode() == GameMode::Endless) {
if (ctx.startLevelSelection) {
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "[PLAYING] Resetting game with level %d", *ctx.startLevelSelection);
ctx.game->reset(*ctx.startLevelSelection);
}
} else {
// Challenge run is prepared before entering; ensure gameplay is unpaused
ctx.game->setPaused(false);
}
s_lastPieceSequence = ctx.game->getCurrentPieceSequence();
s_pendingTransport = false;
}