added stars to gameplay grid
This commit is contained in:
@ -10,6 +10,7 @@
|
||||
#include <random>
|
||||
#include <vector>
|
||||
#include "../../core/Settings.h"
|
||||
#include "../../graphics/effects/Starfield3D.h"
|
||||
|
||||
namespace {
|
||||
struct ImpactSpark {
|
||||
@ -30,6 +31,9 @@ struct ActivePieceSmoothState {
|
||||
};
|
||||
|
||||
ActivePieceSmoothState s_activePieceSmooth;
|
||||
|
||||
Starfield3D s_inGridStarfield;
|
||||
bool s_starfieldInitialized = false;
|
||||
}
|
||||
|
||||
// Color constants (copied from main.cpp)
|
||||
@ -250,6 +254,22 @@ void GameRenderer::renderPlayingState(
|
||||
float lineY = gridY + y * finalBlockSize;
|
||||
SDL_RenderLine(renderer, gridX, lineY, gridX + GRID_W, lineY);
|
||||
}
|
||||
|
||||
if (!s_starfieldInitialized) {
|
||||
s_inGridStarfield.init(static_cast<int>(GRID_W), static_cast<int>(GRID_H), 180);
|
||||
s_starfieldInitialized = true;
|
||||
} else {
|
||||
s_inGridStarfield.resize(static_cast<int>(GRID_W), static_cast<int>(GRID_H));
|
||||
}
|
||||
|
||||
const float deltaSeconds = std::clamp(static_cast<float>(sparkDeltaMs) / 1000.0f, 0.0f, 0.033f);
|
||||
s_inGridStarfield.update(deltaSeconds);
|
||||
|
||||
SDL_BlendMode oldBlend = SDL_BLENDMODE_NONE;
|
||||
SDL_GetRenderDrawBlendMode(renderer, &oldBlend);
|
||||
SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND);
|
||||
s_inGridStarfield.draw(renderer, gridX, gridY, 0.22f, true);
|
||||
SDL_SetRenderDrawBlendMode(renderer, oldBlend);
|
||||
|
||||
// Draw block statistics panel border
|
||||
drawRectWithOffset(statsX - 3 - contentOffsetX, statsY - 3 - contentOffsetY, statsW + 6, statsH + 6, {100, 120, 200, 255});
|
||||
|
||||
Reference in New Issue
Block a user