fixed counter timer when start playing game and exit game
This commit is contained in:
@ -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;
|
||||
}
|
||||
|
||||
|
||||
@ -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<int>& 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
|
||||
|
||||
@ -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);
|
||||
|
||||
16
src/main.cpp
16
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<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);
|
||||
|
||||
|
||||
@ -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;
|
||||
|
||||
Reference in New Issue
Block a user