some problems fixed
This commit is contained in:
@ -46,8 +46,9 @@ void GlobalState::updateFireworks(double frameMs) {
|
||||
|
||||
// Create new fireworks occasionally
|
||||
if (currentTime - lastFireworkTime > 800 + (rand() % 1200)) {
|
||||
float x = Config::Logical::WIDTH * 0.2f + (rand() % (int)(Config::Logical::WIDTH * 0.6f));
|
||||
float y = Config::Logical::HEIGHT * 0.3f + (rand() % (int)(Config::Logical::HEIGHT * 0.4f));
|
||||
// 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%
|
||||
createFirework(x, y);
|
||||
lastFireworkTime = currentTime;
|
||||
}
|
||||
@ -60,15 +61,17 @@ void GlobalState::updateFireworks(double frameMs) {
|
||||
for (auto& particle : firework.particles) {
|
||||
if (particle.life <= 0) continue;
|
||||
|
||||
// Update physics
|
||||
particle.x += particle.vx * (frameMs / 1000.0f);
|
||||
particle.y += particle.vy * (frameMs / 1000.0f);
|
||||
particle.vy += 150.0f * (frameMs / 1000.0f); // Gravity
|
||||
// Update physics (gentler gravity, slight friction)
|
||||
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.life -= frameMs;
|
||||
|
||||
// Fade size over time
|
||||
// Smaller particles overall
|
||||
float lifeRatio = particle.life / particle.maxLife;
|
||||
particle.size = 20.0f + 10.0f * lifeRatio;
|
||||
particle.size = 6.0f + 5.0f * lifeRatio;
|
||||
|
||||
if (particle.life > 0) {
|
||||
hasActiveParticles = true;
|
||||
@ -100,7 +103,7 @@ void GlobalState::createFirework(float x, float y) {
|
||||
firework->particles.clear();
|
||||
|
||||
// Create particles
|
||||
const int particleCount = 12 + (rand() % 8);
|
||||
const int particleCount = 10 + (rand() % 6);
|
||||
for (int i = 0; i < particleCount; ++i) {
|
||||
BlockParticle particle;
|
||||
particle.x = x;
|
||||
@ -108,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 = 80.0f + (rand() % 120);
|
||||
float speed = 70.0f + (rand() % 90);
|
||||
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 = 1500.0f + (rand() % 1000); // 1.5-2.5 seconds
|
||||
particle.maxLife = 1200.0f + (rand() % 800); // ~1.2-2.0 seconds
|
||||
particle.life = particle.maxLife;
|
||||
particle.size = 15.0f + (rand() % 15);
|
||||
particle.size = 6.0f + (rand() % 5);
|
||||
|
||||
firework->particles.push_back(particle);
|
||||
}
|
||||
@ -132,7 +135,8 @@ void GlobalState::drawFireworks(SDL_Renderer* renderer, SDL_Texture* blocksTex)
|
||||
|
||||
// Calculate alpha based on remaining life
|
||||
float lifeRatio = particle.life / particle.maxLife;
|
||||
Uint8 alpha = (Uint8)(255 * std::min(1.0f, lifeRatio * 2.0f));
|
||||
// Faster fade like legacy
|
||||
Uint8 alpha = (Uint8)(255 * std::min(1.0f, lifeRatio * 1.6f));
|
||||
|
||||
// Set texture alpha
|
||||
SDL_SetTextureAlphaMod(blocksTex, alpha);
|
||||
|
||||
Reference in New Issue
Block a user