fixed counter timer when start playing game and exit game

This commit is contained in:
2025-11-23 10:02:02 +01:00
parent 5bf87f2c21
commit b33a90d5c5
5 changed files with 24 additions and 18 deletions

View File

@ -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<int>(GAMEPLAY_COUNTDOWN_LABELS.size()) - 1);
const char* label = GAMEPLAY_COUNTDOWN_LABELS[cappedIndex];
bool isFinalCue = (cappedIndex == static_cast<int>(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<float>(textW)) * 0.5f;
float textY = (LOGICAL_H - static_cast<float>(textH)) * 0.5f;
// Center in actual window coordinates (works for any resolution/fullscreen)
float textX = (winW - static_cast<float>(textW)) * 0.5f;
float textY = (winH - static_cast<float>(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);