Hold block added

This commit is contained in:
2025-12-17 21:05:32 +01:00
parent 492abc09bc
commit 0ab7121c5b
6 changed files with 48 additions and 10 deletions

View File

@ -1357,6 +1357,11 @@ void GameRenderer::renderPlayingState(
statLines.push_back({dropStr, 370.0f, 0.7f, dropColor});
}
bool scorePanelMetricsValid = false;
float scorePanelTop = 0.0f;
float scorePanelLeftX = 0.0f;
float scorePanelWidth = 0.0f;
if (!statLines.empty()) {
float statsContentTop = std::numeric_limits<float>::max();
float statsContentBottom = std::numeric_limits<float>::lowest();
@ -1383,6 +1388,11 @@ void GameRenderer::renderPlayingState(
SDL_SetRenderDrawColor(renderer, 12, 18, 32, 205);
SDL_RenderFillRect(renderer, &statsBg);
}
scorePanelMetricsValid = true;
scorePanelTop = statsPanelTop;
scorePanelLeftX = statsPanelLeft;
scorePanelWidth = statsPanelWidth;
}
for (const auto& line : statLines) {
@ -1393,10 +1403,30 @@ void GameRenderer::renderPlayingState(
pixelFont->draw(renderer, logicalW - 260, 10, gravityHud, 0.9f, {200, 200, 220, 255});
}
// Hold piece (if implemented)
// Hold piece (right side, above score dashboard)
if (game->held().type < PIECE_COUNT) {
pixelFont->draw(renderer, statsX + 10, statsY + statsH - 80, "HOLD", 1.0f, {255, 220, 0, 255});
drawSmallPiece(renderer, blocksTex, static_cast<PieceType>(game->held().type), statsX + 60, statsY + statsH - 80, finalBlockSize * 0.6f);
float holdLabelX = statsTextX;
float holdY = statsY + statsH - 80.0f;
if (scorePanelMetricsValid) {
const float holdGap = 18.0f;
const float holdBlockH = (finalBlockSize * 0.6f) * 4.0f;
holdY = scorePanelTop - holdBlockH - holdGap;
holdLabelX = statsTextX;
// Ensure HOLD block doesn't drift too far left if the score panel gets narrow.
holdLabelX = std::max(holdLabelX, scorePanelLeftX + 14.0f);
// If the score panel is extremely narrow, keep within its bounds.
holdLabelX = std::min(holdLabelX, scorePanelLeftX + std::max(0.0f, scorePanelWidth - 90.0f));
}
pixelFont->draw(renderer, holdLabelX, holdY, "HOLD", 1.0f, {255, 220, 0, 255});
drawSmallPiece(
renderer,
blocksTex,
static_cast<PieceType>(game->held().type),
holdLabelX + 50.0f,
holdY + 2.0f,
finalBlockSize * 0.6f
);
}
// Pause overlay logic moved to renderPauseOverlay