diff --git a/src/app/TetrisApp.cpp b/src/app/TetrisApp.cpp index e76fffb..62da545 100644 --- a/src/app/TetrisApp.cpp +++ b/src/app/TetrisApp.cpp @@ -1231,15 +1231,25 @@ void TetrisApp::Impl::runLoop() } }; - handleSide(CoopGame::PlayerSide::Left, p1LeftHeld, p1RightHeld, p1MoveTimerMs, SDL_SCANCODE_A, SDL_SCANCODE_D, SDL_SCANCODE_S); - handleSide(CoopGame::PlayerSide::Right, p2LeftHeld, p2RightHeld, p2MoveTimerMs, SDL_SCANCODE_LEFT, SDL_SCANCODE_RIGHT, SDL_SCANCODE_DOWN); + if (game->isPaused()) { + // While paused, suppress all continuous input changes so pieces don't drift. + coopGame->setSoftDropping(CoopGame::PlayerSide::Left, false); + coopGame->setSoftDropping(CoopGame::PlayerSide::Right, false); + p1MoveTimerMs = 0.0; + p2MoveTimerMs = 0.0; + p1LeftHeld = false; + p1RightHeld = false; + p2LeftHeld = false; + p2RightHeld = false; + } else { + handleSide(CoopGame::PlayerSide::Left, p1LeftHeld, p1RightHeld, p1MoveTimerMs, SDL_SCANCODE_A, SDL_SCANCODE_D, SDL_SCANCODE_S); + handleSide(CoopGame::PlayerSide::Right, p2LeftHeld, p2RightHeld, p2MoveTimerMs, SDL_SCANCODE_LEFT, SDL_SCANCODE_RIGHT, SDL_SCANCODE_DOWN); - p1LeftHeld = ks[SDL_SCANCODE_A]; - p1RightHeld = ks[SDL_SCANCODE_D]; - p2LeftHeld = ks[SDL_SCANCODE_LEFT]; - p2RightHeld = ks[SDL_SCANCODE_RIGHT]; + p1LeftHeld = ks[SDL_SCANCODE_A]; + p1RightHeld = ks[SDL_SCANCODE_D]; + p2LeftHeld = ks[SDL_SCANCODE_LEFT]; + p2RightHeld = ks[SDL_SCANCODE_RIGHT]; - if (!game->isPaused()) { coopGame->tickGravity(frameMs); coopGame->updateVisualEffects(frameMs); } diff --git a/src/core/application/ApplicationManager.cpp b/src/core/application/ApplicationManager.cpp index 5c0fde3..9f2c2e6 100644 --- a/src/core/application/ApplicationManager.cpp +++ b/src/core/application/ApplicationManager.cpp @@ -1259,6 +1259,19 @@ void ApplicationManager::setupStateHandlers() { const bool *ks = SDL_GetKeyboardState(nullptr); if (coopActive) { + // Paused: suppress all continuous input so pieces don't drift while paused. + if (m_stateContext.game->isPaused()) { + m_stateContext.coopGame->setSoftDropping(CoopGame::PlayerSide::Left, false); + m_stateContext.coopGame->setSoftDropping(CoopGame::PlayerSide::Right, false); + m_p1MoveTimerMs = 0.0; + m_p2MoveTimerMs = 0.0; + m_p1LeftHeld = false; + m_p1RightHeld = false; + m_p2LeftHeld = false; + m_p2RightHeld = false; + return; + } + auto handleSide = [&](CoopGame::PlayerSide side, bool leftHeld, bool rightHeld, diff --git a/src/states/PlayingState.cpp b/src/states/PlayingState.cpp index 4416b9f..e5268d0 100644 --- a/src/states/PlayingState.cpp +++ b/src/states/PlayingState.cpp @@ -133,6 +133,16 @@ void PlayingState::handleEvent(const SDL_Event& e) { return; } + // Pause toggle (P) - matches classic behavior; disabled during countdown + if (e.key.scancode == SDL_SCANCODE_P) { + const bool countdown = (ctx.gameplayCountdownActive && *ctx.gameplayCountdownActive) || + (ctx.menuPlayCountdownArmed && *ctx.menuPlayCountdownArmed); + if (!countdown) { + ctx.game->setPaused(!ctx.game->isPaused()); + } + return; + } + // Tetris controls (only when not paused) if (ctx.game->isPaused()) { return;