updated asteroids

This commit is contained in:
2025-12-20 14:19:50 +01:00
parent 970259e3d6
commit 9a3c1a0688
6 changed files with 39 additions and 1 deletions

View File

@ -576,6 +576,7 @@ void GameRenderer::renderPlayingState(
SDL_Texture* scorePanelTex,
SDL_Texture* nextPanelTex,
SDL_Texture* holdPanelTex,
bool countdownActive,
float logicalW,
float logicalH,
float logicalScale,
@ -1017,7 +1018,29 @@ void GameRenderer::renderPlayingState(
bool isAsteroid = challengeMode && asteroidCells[cellIdx].has_value();
if (isAsteroid) {
const AsteroidCell& cell = *asteroidCells[cellIdx];
drawAsteroid(renderer, asteroidsTex, bx, by, finalBlockSize, cell);
float spawnScale = 1.0f;
float spawnAlpha = 1.0f;
if (countdownActive) {
// Staggered pop-in while counting: start oversized, fade to 1.0 with ease
const float t = static_cast<float>(SDL_GetTicks() & 2047) * 0.0015f; // ~0..3s loop
float phase = std::fmod(t + (float(cellIdx % 11) * 0.12f), 1.6f);
float pulse = std::clamp(phase / 1.2f, 0.0f, 1.0f);
float eased = smoothstep(pulse);
spawnScale = 1.35f - 0.35f * eased; // big -> normal
spawnAlpha = 0.25f + 0.75f * eased; // fade in
}
if (asteroidsTex && spawnAlpha < 1.0f) {
SDL_SetTextureAlphaMod(asteroidsTex, static_cast<Uint8>(std::clamp(spawnAlpha, 0.0f, 1.0f) * 255.0f));
}
float size = finalBlockSize * spawnScale;
float offset = (finalBlockSize - size) * 0.5f;
drawAsteroid(renderer, asteroidsTex, bx + offset, by + offset, size, cell);
if (asteroidsTex && spawnAlpha < 1.0f) {
SDL_SetTextureAlphaMod(asteroidsTex, 255);
}
} else {
drawBlockTexture(renderer, blocksTex, bx, by, finalBlockSize, v - 1);
}