updated asteroids
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 183 KiB After Width: | Height: | Size: 181 KiB |
@ -1576,6 +1576,7 @@ void TetrisApp::Impl::runLoop()
|
|||||||
scorePanelTex,
|
scorePanelTex,
|
||||||
nextPanelTex,
|
nextPanelTex,
|
||||||
holdPanelTex,
|
holdPanelTex,
|
||||||
|
false,
|
||||||
(float)LOGICAL_W,
|
(float)LOGICAL_W,
|
||||||
(float)LOGICAL_H,
|
(float)LOGICAL_H,
|
||||||
logicalScale,
|
logicalScale,
|
||||||
|
|||||||
@ -1168,6 +1168,7 @@ void ApplicationManager::setupStateHandlers() {
|
|||||||
m_stateContext.scorePanelTex,
|
m_stateContext.scorePanelTex,
|
||||||
m_stateContext.nextPanelTex,
|
m_stateContext.nextPanelTex,
|
||||||
m_stateContext.holdPanelTex,
|
m_stateContext.holdPanelTex,
|
||||||
|
false,
|
||||||
LOGICAL_W,
|
LOGICAL_W,
|
||||||
LOGICAL_H,
|
LOGICAL_H,
|
||||||
logicalScale,
|
logicalScale,
|
||||||
|
|||||||
@ -576,6 +576,7 @@ void GameRenderer::renderPlayingState(
|
|||||||
SDL_Texture* scorePanelTex,
|
SDL_Texture* scorePanelTex,
|
||||||
SDL_Texture* nextPanelTex,
|
SDL_Texture* nextPanelTex,
|
||||||
SDL_Texture* holdPanelTex,
|
SDL_Texture* holdPanelTex,
|
||||||
|
bool countdownActive,
|
||||||
float logicalW,
|
float logicalW,
|
||||||
float logicalH,
|
float logicalH,
|
||||||
float logicalScale,
|
float logicalScale,
|
||||||
@ -1017,7 +1018,29 @@ void GameRenderer::renderPlayingState(
|
|||||||
bool isAsteroid = challengeMode && asteroidCells[cellIdx].has_value();
|
bool isAsteroid = challengeMode && asteroidCells[cellIdx].has_value();
|
||||||
if (isAsteroid) {
|
if (isAsteroid) {
|
||||||
const AsteroidCell& cell = *asteroidCells[cellIdx];
|
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 {
|
} else {
|
||||||
drawBlockTexture(renderer, blocksTex, bx, by, finalBlockSize, v - 1);
|
drawBlockTexture(renderer, blocksTex, bx, by, finalBlockSize, v - 1);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -26,6 +26,7 @@ public:
|
|||||||
SDL_Texture* scorePanelTex,
|
SDL_Texture* scorePanelTex,
|
||||||
SDL_Texture* nextPanelTex,
|
SDL_Texture* nextPanelTex,
|
||||||
SDL_Texture* holdPanelTex,
|
SDL_Texture* holdPanelTex,
|
||||||
|
bool countdownActive,
|
||||||
float logicalW,
|
float logicalW,
|
||||||
float logicalH,
|
float logicalH,
|
||||||
float logicalScale,
|
float logicalScale,
|
||||||
|
|||||||
@ -122,6 +122,16 @@ void PlayingState::handleEvent(const SDL_Event& e) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Debug: skip to next challenge level (B)
|
||||||
|
if (e.key.scancode == SDL_SCANCODE_B && ctx.game && ctx.game->getMode() == GameMode::Challenge) {
|
||||||
|
ctx.game->beginNextChallengeLevel();
|
||||||
|
// Cancel any countdown so play resumes immediately on the new level
|
||||||
|
if (ctx.gameplayCountdownActive) *ctx.gameplayCountdownActive = false;
|
||||||
|
if (ctx.menuPlayCountdownArmed) *ctx.menuPlayCountdownArmed = false;
|
||||||
|
ctx.game->setPaused(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Tetris controls (only when not paused)
|
// Tetris controls (only when not paused)
|
||||||
if (!ctx.game->isPaused()) {
|
if (!ctx.game->isPaused()) {
|
||||||
// Hold / swap current piece (H)
|
// Hold / swap current piece (H)
|
||||||
@ -246,6 +256,7 @@ void PlayingState::render(SDL_Renderer* renderer, float logicalScale, SDL_Rect l
|
|||||||
ctx.scorePanelTex,
|
ctx.scorePanelTex,
|
||||||
ctx.nextPanelTex,
|
ctx.nextPanelTex,
|
||||||
ctx.holdPanelTex,
|
ctx.holdPanelTex,
|
||||||
|
countdown,
|
||||||
1200.0f, // LOGICAL_W
|
1200.0f, // LOGICAL_W
|
||||||
1000.0f, // LOGICAL_H
|
1000.0f, // LOGICAL_H
|
||||||
logicalScale,
|
logicalScale,
|
||||||
@ -335,6 +346,7 @@ void PlayingState::render(SDL_Renderer* renderer, float logicalScale, SDL_Rect l
|
|||||||
ctx.scorePanelTex,
|
ctx.scorePanelTex,
|
||||||
ctx.nextPanelTex,
|
ctx.nextPanelTex,
|
||||||
ctx.holdPanelTex,
|
ctx.holdPanelTex,
|
||||||
|
countdown,
|
||||||
1200.0f,
|
1200.0f,
|
||||||
1000.0f,
|
1000.0f,
|
||||||
logicalScale,
|
logicalScale,
|
||||||
|
|||||||
Reference in New Issue
Block a user