fixed main screen

This commit is contained in:
2025-11-23 13:41:00 +01:00
parent 1ac788b0a2
commit 6176e07ef1
2 changed files with 22 additions and 19 deletions

View File

@ -44,11 +44,11 @@ void GlobalState::shutdown() {
void GlobalState::updateFireworks(double frameMs) {
const Uint64 currentTime = SDL_GetTicks();
// Create new fireworks occasionally
if (currentTime - lastFireworkTime > 800 + (rand() % 1200)) {
// Spawn bias similar to legacy: lower-right area
float x = Config::Logical::WIDTH * (0.55f + (rand() % 35) / 100.0f); // ~55% - 90%
float y = Config::Logical::HEIGHT * (0.80f + (rand() % 15) / 100.0f); // ~80% - 95%
// Create new fireworks less frequently for subtle background effect
if (currentTime - lastFireworkTime > 1200 + (rand() % 1800)) { // Less frequent: 1200-3000ms
// Spawn across wider area for better coverage
float x = Config::Logical::WIDTH * (0.15f + (rand() % 70) / 100.0f); // 15% - 85%
float y = Config::Logical::HEIGHT * (0.20f + (rand() % 60) / 100.0f); // 20% - 80%
createFirework(x, y);
lastFireworkTime = currentTime;
}
@ -65,13 +65,13 @@ void GlobalState::updateFireworks(double frameMs) {
float dt = float(frameMs / 1000.0f);
particle.x += particle.vx * dt;
particle.y += particle.vy * dt;
particle.vx *= (1.0f - 0.6f * dt); // horizontal friction
particle.vy = particle.vy * (1.0f - 0.3f * dt) + 90.0f * dt; // gravity with damping
particle.vx *= (1.0f - 0.5f * dt); // Less friction for longer travel
particle.vy = particle.vy * (1.0f - 0.2f * dt) + 80.0f * dt; // Gentler gravity
particle.life -= frameMs;
// Smaller particles overall
// Smaller particles for subtle effect
float lifeRatio = particle.life / particle.maxLife;
particle.size = 6.0f + 5.0f * lifeRatio;
particle.size = 6.0f + 4.0f * lifeRatio; // Smaller particles
if (particle.life > 0) {
hasActiveParticles = true;
@ -102,8 +102,8 @@ void GlobalState::createFirework(float x, float y) {
firework->active = true;
firework->particles.clear();
// Create particles
const int particleCount = 10 + (rand() % 6);
// Create fewer particles for subtle background effect
const int particleCount = 12 + (rand() % 8); // 12-20 particles per explosion
for (int i = 0; i < particleCount; ++i) {
BlockParticle particle;
particle.x = x;
@ -111,14 +111,14 @@ void GlobalState::createFirework(float x, float y) {
// Random velocity in all directions
float angle = (float)(rand() % 360) * 3.14159f / 180.0f;
float speed = 70.0f + (rand() % 90);
float speed = 80.0f + (rand() % 100); // Moderate speed
particle.vx = cos(angle) * speed;
particle.vy = sin(angle) * speed - 50.0f; // Slight upward bias
particle.type = 1 + (rand() % 7); // Random tetris piece color
particle.maxLife = 1200.0f + (rand() % 800); // ~1.2-2.0 seconds
particle.maxLife = 1500.0f + (rand() % 1000); // Medium life: ~1.5-2.5 seconds
particle.life = particle.maxLife;
particle.size = 6.0f + (rand() % 5);
particle.size = 6.0f + (rand() % 5); // Smaller particles
firework->particles.push_back(particle);
}
@ -133,10 +133,10 @@ void GlobalState::drawFireworks(SDL_Renderer* renderer, SDL_Texture* blocksTex)
for (const auto& particle : firework.particles) {
if (particle.life <= 0) continue;
// Calculate alpha based on remaining life
// Calculate alpha based on remaining life - more transparent for subtle effect
float lifeRatio = particle.life / particle.maxLife;
// Faster fade like legacy
Uint8 alpha = (Uint8)(255 * std::min(1.0f, lifeRatio * 1.6f));
// Reduced opacity: 50% of original for subtle background effect
Uint8 alpha = (Uint8)(128 * std::min(1.0f, lifeRatio * 1.6f));
// Set texture alpha
SDL_SetTextureAlphaMod(blocksTex, alpha);