space warp fixes

This commit is contained in:
2025-12-10 17:57:32 +01:00
parent 57eac01bcb
commit e8a7b19213
3 changed files with 41 additions and 7 deletions

View File

@ -716,7 +716,16 @@ void GameRenderer::renderPlayingState(
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);
// Add a small, smooth sub-pixel jitter to the starfield origin so the
// brightest star doesn't permanently sit exactly at the visual center.
{
const float jitterAmp = 1.6f; // max pixels of jitter
const uint32_t now = SDL_GetTicks();
const float tms = static_cast<float>(now) * 0.001f;
const float jitterX = std::sin(tms * 1.7f) * jitterAmp + std::cos(tms * 0.9f) * 0.4f;
const float jitterY = std::sin(tms * 1.1f + 3.7f) * (jitterAmp * 0.6f);
s_inGridStarfield.draw(renderer, gridX + jitterX, gridY + jitterY, 0.22f, true);
}
// Update and spawn ambient sparkles inside/around the grid
// Use the same RNG and timing values used for impact sparks