Added challenge mode
This commit is contained in:
@ -442,7 +442,7 @@ void MenuState::handleEvent(const SDL_Event& e) {
|
||||
case SDL_SCANCODE_LEFT:
|
||||
case SDL_SCANCODE_UP:
|
||||
{
|
||||
const int total = 6;
|
||||
const int total = 7;
|
||||
selectedButton = (selectedButton + total - 1) % total;
|
||||
// brief bright flash on navigation
|
||||
buttonFlash = 1.0;
|
||||
@ -451,7 +451,7 @@ void MenuState::handleEvent(const SDL_Event& e) {
|
||||
case SDL_SCANCODE_RIGHT:
|
||||
case SDL_SCANCODE_DOWN:
|
||||
{
|
||||
const int total = 6;
|
||||
const int total = 7;
|
||||
selectedButton = (selectedButton + 1) % total;
|
||||
// brief bright flash on navigation
|
||||
buttonFlash = 1.0;
|
||||
@ -465,9 +465,19 @@ void MenuState::handleEvent(const SDL_Event& e) {
|
||||
}
|
||||
switch (selectedButton) {
|
||||
case 0:
|
||||
// Endless play
|
||||
if (ctx.game) ctx.game->setMode(GameMode::Endless);
|
||||
triggerPlay();
|
||||
break;
|
||||
case 1:
|
||||
// Start challenge run at level 1
|
||||
if (ctx.game) {
|
||||
ctx.game->setMode(GameMode::Challenge);
|
||||
ctx.game->startChallengeRun(1);
|
||||
}
|
||||
triggerPlay();
|
||||
break;
|
||||
case 2:
|
||||
// Toggle inline level selector HUD (show/hide)
|
||||
if (!levelPanelVisible && !levelPanelAnimating) {
|
||||
levelPanelAnimating = true;
|
||||
@ -479,7 +489,7 @@ void MenuState::handleEvent(const SDL_Event& e) {
|
||||
levelDirection = -1; // hide
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
case 3:
|
||||
// Toggle the options panel with an animated slide-in/out.
|
||||
if (!optionsVisible && !optionsAnimating) {
|
||||
optionsAnimating = true;
|
||||
@ -489,7 +499,7 @@ void MenuState::handleEvent(const SDL_Event& e) {
|
||||
optionsDirection = -1; // hide
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
case 4:
|
||||
// Toggle the inline HELP HUD (show/hide)
|
||||
if (!helpPanelVisible && !helpPanelAnimating) {
|
||||
helpPanelAnimating = true;
|
||||
@ -500,7 +510,7 @@ void MenuState::handleEvent(const SDL_Event& e) {
|
||||
helpDirection = -1; // hide
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
case 5:
|
||||
// Toggle the inline ABOUT HUD (show/hide)
|
||||
if (!aboutPanelVisible && !aboutPanelAnimating) {
|
||||
aboutPanelAnimating = true;
|
||||
@ -510,7 +520,7 @@ void MenuState::handleEvent(const SDL_Event& e) {
|
||||
aboutDirection = -1;
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
case 6:
|
||||
// Show the inline exit HUD
|
||||
if (!exitPanelVisible && !exitPanelAnimating) {
|
||||
exitPanelAnimating = true;
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user