From b33a90d5c5012767da77ea6c7b85f35d7a926b06 Mon Sep 17 00:00:00 2001 From: Gregor Klevze Date: Sun, 23 Nov 2025 10:02:02 +0100 Subject: [PATCH] fixed counter timer when start playing game and exit game --- src/core/application/ApplicationManager.cpp | 6 ++---- src/gameplay/effects/LineEffect.cpp | 4 ++-- src/gameplay/effects/LineEffect.h | 2 +- src/main.cpp | 16 ++++++---------- src/states/MenuState.cpp | 14 +++++++++++++- 5 files changed, 24 insertions(+), 18 deletions(-) diff --git a/src/core/application/ApplicationManager.cpp b/src/core/application/ApplicationManager.cpp index 23e7e64..b8f8d32 100644 --- a/src/core/application/ApplicationManager.cpp +++ b/src/core/application/ApplicationManager.cpp @@ -327,8 +327,8 @@ bool ApplicationManager::initializeManagers() { // Global hotkeys (handled across all states) if (pressed) { - // Toggle fullscreen on F11 or Alt+Enter (or Alt+KP_Enter) - if (sc == SDL_SCANCODE_F11 || + // Toggle fullscreen on F, F11 or Alt+Enter (or Alt+KP_Enter) + if (sc == SDL_SCANCODE_F || sc == SDL_SCANCODE_F11 || ((sc == SDL_SCANCODE_RETURN || sc == SDL_SCANCODE_RETURN2 || sc == SDL_SCANCODE_KP_ENTER) && (SDL_GetModState() & SDL_KMOD_ALT))) { if (m_renderManager) { @@ -336,8 +336,6 @@ bool ApplicationManager::initializeManagers() { m_renderManager->setFullscreen(!fs); m_isFullscreen = m_renderManager->isFullscreen(); } - // Don’t also forward Alt+Enter as an Enter keypress to states (prevents accidental "Start") - // Don't also forward Alt+Enter as an Enter keypress to states (prevents accidental "Start") consume = true; } diff --git a/src/gameplay/effects/LineEffect.cpp b/src/gameplay/effects/LineEffect.cpp index d3052a8..e4a8460 100644 --- a/src/gameplay/effects/LineEffect.cpp +++ b/src/gameplay/effects/LineEffect.cpp @@ -34,7 +34,7 @@ void LineEffect::Particle::update() { y += vy * 0.016f; vy += 250.0f * 0.016f; vx *= 0.98f; - alpha -= 0.08f; // Slower fade for blocks + alpha -= 0.025f; // Slower fade for blocks (longer visibility) if (alpha < 0.0f) alpha = 0.0f; if (size > 2.0f) size -= 0.05f; @@ -145,7 +145,7 @@ void LineEffect::startLineClear(const std::vector& rows, int gridX, int gri void LineEffect::createParticles(int row, int gridX, int gridY, int blockSize) { // Create particles spread across the row with explosive pattern - int particlesPerRow = 35; // More particles for dramatic explosion effect + int particlesPerRow = 60; // More particles for dramatic explosion effect for (int i = 0; i < particlesPerRow; ++i) { // Create particles along the entire row width diff --git a/src/gameplay/effects/LineEffect.h b/src/gameplay/effects/LineEffect.h index 526137d..0c9aa93 100644 --- a/src/gameplay/effects/LineEffect.h +++ b/src/gameplay/effects/LineEffect.h @@ -60,7 +60,7 @@ private: // Animation timing - Flash then immediate explosion effect static constexpr float FLASH_DURATION = 0.12f; // Very brief white flash - static constexpr float EXPLODE_DURATION = 0.15f; // Quick explosive effect + static constexpr float EXPLODE_DURATION = 0.6f; // Longer explosive effect static constexpr float DROP_DURATION = 0.05f; // Almost instant block drop void createParticles(int row, int gridX, int gridY, int blockSize); diff --git a/src/main.cpp b/src/main.cpp index b35d7b9..25475ac 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1646,25 +1646,21 @@ int main(int, char **) } if (gameplayCountdownActive && state == AppState::Playing) { + // Switch to window coordinates for perfect centering in any resolution SDL_SetRenderViewport(renderer, nullptr); SDL_SetRenderScale(renderer, 1.f, 1.f); SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND); - // Removed background overlay for cleaner countdown - // SDL_SetRenderDrawColor(renderer, 0, 0, 0, 160); - // SDL_FRect dimRect{0.f, 0.f, (float)winW, (float)winH}; - // SDL_RenderFillRect(renderer, &dimRect); - - SDL_SetRenderViewport(renderer, &logicalVP); - SDL_SetRenderScale(renderer, logicalScale, logicalScale); int cappedIndex = std::min(gameplayCountdownIndex, static_cast(GAMEPLAY_COUNTDOWN_LABELS.size()) - 1); const char* label = GAMEPLAY_COUNTDOWN_LABELS[cappedIndex]; bool isFinalCue = (cappedIndex == static_cast(GAMEPLAY_COUNTDOWN_LABELS.size()) - 1); - float textScale = isFinalCue ? 2.6f : 3.6f; + float textScale = isFinalCue ? 4.5f : 5.0f; // Much bigger fonts for countdown int textW = 0, textH = 0; pixelFont.measure(label, textScale, textW, textH); - float textX = (LOGICAL_W - static_cast(textW)) * 0.5f; - float textY = (LOGICAL_H - static_cast(textH)) * 0.5f; + + // Center in actual window coordinates (works for any resolution/fullscreen) + float textX = (winW - static_cast(textW)) * 0.5f; + float textY = (winH - static_cast(textH)) * 0.5f; SDL_Color textColor = isFinalCue ? SDL_Color{255, 230, 90, 255} : SDL_Color{255, 255, 255, 255}; pixelFont.draw(renderer, textX, textY, label, textScale, textColor); diff --git a/src/states/MenuState.cpp b/src/states/MenuState.cpp index 39657bd..fc9279e 100644 --- a/src/states/MenuState.cpp +++ b/src/states/MenuState.cpp @@ -335,10 +335,22 @@ void MenuState::render(SDL_Renderer* renderer, float logicalScale, SDL_Rect logi if (ctx.showExitConfirmPopup && *ctx.showExitConfirmPopup) { int selection = ctx.exitPopupSelectedButton ? *ctx.exitPopupSelectedButton : 1; + + // Switch to window coordinates for full-screen overlay + SDL_SetRenderViewport(renderer, nullptr); + SDL_SetRenderScale(renderer, 1.0f, 1.0f); SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND); SDL_SetRenderDrawColor(renderer, 0, 0, 0, 150); - SDL_FRect overlay{contentOffsetX, contentOffsetY, LOGICAL_W, LOGICAL_H}; + + // Get actual window size + int actualWinW = 0, actualWinH = 0; + SDL_GetRenderOutputSize(renderer, &actualWinW, &actualWinH); + SDL_FRect overlay{0, 0, (float)actualWinW, (float)actualWinH}; SDL_RenderFillRect(renderer, &overlay); + + // Restore viewport and scale for popup content + SDL_SetRenderViewport(renderer, &logicalVP); + SDL_SetRenderScale(renderer, logicalScale, logicalScale); const float panelW = 640.0f; const float panelH = 320.0f;