fixed highscore

This commit is contained in:
2025-12-06 15:10:41 +01:00
parent 26b4454eea
commit f24d484496
12 changed files with 45 additions and 16 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 930 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 195 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 110 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.9 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 MiB

After

Width:  |  Height:  |  Size: 2.0 MiB

View File

@ -624,7 +624,7 @@ int main(int, char **)
// Load the new main screen overlay that sits above the background but below buttons
int mainScreenW = 0;
int mainScreenH = 0;
SDL_Texture* mainScreenTex = loadTextureFromImage(renderer, "assets/images/main_screen_004.png", &mainScreenW, &mainScreenH);
SDL_Texture* mainScreenTex = loadTextureFromImage(renderer, "assets/images/main_screen.png", &mainScreenW, &mainScreenH);
if (mainScreenTex) {
SDL_SetTextureBlendMode(mainScreenTex, SDL_BLENDMODE_BLEND);
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Loaded main_screen overlay %dx%d (tex=%p)", mainScreenW, mainScreenH, (void*)mainScreenTex);

View File

@ -602,7 +602,9 @@ void MenuState::render(SDL_Renderer* renderer, float logicalScale, SDL_Rect logi
if (useFont) {
const float panelW = std::min(780.0f, LOGICAL_W * 0.85f);
const float panelH = 36.0f + maxDisplay * 36.0f; // header + rows
float panelBaseX = (LOGICAL_W - panelW) * 0.5f + contentOffsetX;
// Shift the entire highscores panel slightly left (~1.5% of logical width)
float panelShift = LOGICAL_W * 0.015f;
float panelBaseX = (LOGICAL_W - panelW) * 0.5f + contentOffsetX - panelShift;
float panelBaseY = scoresStartY - 20.0f - panelDelta; // nudge up and apply HUD slide
// Column positions inside panel
@ -614,7 +616,8 @@ void MenuState::render(SDL_Renderer* renderer, float logicalScale, SDL_Rect logi
float rankX = centerX - colWidth * 0.34f;
// Move PLAYER column a bit further left while leaving others unchanged
float nameX = centerX - colWidth * 0.25f;
float scoreX = centerX + colWidth * 0.00f;
// Move SCORE column slightly left for tighter layout
float scoreX = centerX - colWidth * 0.06f;
float linesX = centerX + colWidth * 0.14f;
float levelX = centerX + colWidth * 0.26f;
float timeX = centerX + colWidth * 0.38f;
@ -623,8 +626,8 @@ void MenuState::render(SDL_Renderer* renderer, float logicalScale, SDL_Rect logi
float headerY = panelBaseY + 26.0f;
// Slightly smaller header for compactness
float headerScale = 0.75f;
// Use same color as Options heading
SDL_Color headerColor = SDL_Color{120,220,255,220};
// Use same color as Options heading (use full alpha for maximum brightness)
SDL_Color headerColor = SDL_Color{120,220,255,255};
useFont->draw(renderer, rankX, headerY, "#", headerScale, headerColor);
useFont->draw(renderer, nameX, headerY, "PLAYER", headerScale, headerColor);
useFont->draw(renderer, scoreX, headerY, "SCORE", headerScale, headerColor);
@ -633,7 +636,7 @@ void MenuState::render(SDL_Renderer* renderer, float logicalScale, SDL_Rect logi
useFont->draw(renderer, timeX, headerY, "TIME", headerScale, headerColor);
const float rowHeight = 28.0f;
float rowY = panelBaseY + 48.0f;
float rowY = panelBaseY + 28.0f;
float rowScale = 0.80f;
for (size_t i = 0; i < maxDisplay; ++i) {
@ -644,29 +647,55 @@ void MenuState::render(SDL_Renderer* renderer, float logicalScale, SDL_Rect logi
// Subtle highlight wave for the list similar to before
float wave = std::sin((float)GlobalState::instance().logoAnimCounter * 0.006f + i * 0.25f) * 4.0f;
// Slightly reduced font for rows to fit more cleanly
if (i < 5) {
rowScale -= 0.05f;
// Per-row entrance staggering and easing to make movement fancier
const float baseEntrance = 40.0f; // pixels rows slide from
const float perRowDelay = 0.06f; // stagger delay per row (in eased 0..1 space)
float rowDelay = perRowDelay * (float)i;
float rowT = 0.0f;
if (eased > rowDelay) rowT = (eased - rowDelay) / (1.0f - rowDelay);
if (rowT < 0.0f) rowT = 0.0f; if (rowT > 1.0f) rowT = 1.0f;
// cubic smoothstep per row
float rowEase = rowT * rowT * (3.0f - 2.0f * rowT);
float entryOffset = (1.0f - rowEase) * baseEntrance;
// Slight alpha fade during entrance
float alphaMul = 1;
// Slight scale slip per row (keeps earlier visual taper)
float curRowScale = rowScale - std::min(0.20f, 0.05f * (float)i);
// Base row color matches header brightness; top 3 get vivid medal colors
SDL_Color baseRowColor = SDL_Color{ headerColor.r, headerColor.g, headerColor.b, 255 };
if (i == 0) {
baseRowColor = SDL_Color{255,215,0,255}; // bright gold
} else if (i == 1) {
baseRowColor = SDL_Color{230,230,235,255}; // bright silver
} else if (i == 2) {
baseRowColor = SDL_Color{255,165,80,255}; // brighter bronze/orange
}
SDL_Color rowColor = SDL_Color{120,220,255,220};
SDL_Color rowColor = baseRowColor;
// Use entrance alpha to fade in but keep RGB full-brightness; map alphaMul to 0..1
rowColor.a = static_cast<Uint8>(std::round(255.0f * alphaMul));
// horizontal subtle slide for name column to add a little polish
float nameXAdj = nameX - (1.0f - rowEase) * 8.0f;
char rankStr[8]; std::snprintf(rankStr, sizeof(rankStr), "%zu.", i + 1);
useFont->draw(renderer, rankX, y + wave, rankStr, rowScale, rowColor);
useFont->draw(renderer, rankX, y + wave + entryOffset, rankStr, curRowScale, rowColor);
useFont->draw(renderer, nameX, y + wave, hs[i].name, rowScale, rowColor);
useFont->draw(renderer, nameXAdj, y + wave + entryOffset, hs[i].name, curRowScale, rowColor);
char scoreStr[16]; std::snprintf(scoreStr, sizeof(scoreStr), "%d", hs[i].score);
useFont->draw(renderer, scoreX, y + wave, scoreStr, rowScale, rowColor);
useFont->draw(renderer, scoreX, y + wave + entryOffset, scoreStr, curRowScale, rowColor);
char linesStr[8]; std::snprintf(linesStr, sizeof(linesStr), "%d", hs[i].lines);
useFont->draw(renderer, linesX, y + wave, linesStr, rowScale, rowColor);
useFont->draw(renderer, linesX, y + wave + entryOffset, linesStr, curRowScale, rowColor);
char levelStr[8]; std::snprintf(levelStr, sizeof(levelStr), "%d", hs[i].level);
useFont->draw(renderer, levelX, y + wave, levelStr, rowScale, rowColor);
useFont->draw(renderer, levelX, y + wave + entryOffset, levelStr, curRowScale, rowColor);
char timeStr[16]; int mins = int(hs[i].timeSec) / 60; int secs = int(hs[i].timeSec) % 60;
std::snprintf(timeStr, sizeof(timeStr), "%d:%02d", mins, secs);
useFont->draw(renderer, timeX, y + wave, timeStr, rowScale, rowColor);
useFont->draw(renderer, timeX, y + wave + entryOffset, timeStr, curRowScale, rowColor);
}
}