diff options
Diffstat (limited to 'html/tower/js')
-rw-r--r-- | html/tower/js/game.js | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/html/tower/js/game.js b/html/tower/js/game.js index e36c291..263d25c 100644 --- a/html/tower/js/game.js +++ b/html/tower/js/game.js @@ -100,14 +100,30 @@ function gameLoop(timestamp) { const centerX = (target.position.x + 0.5) * cellSize; const centerY = (target.position.y + 0.5) * cellSize; - // Create explosion particles - for (let i = 0; i < 12; i++) { - const angle = (Math.PI * 2 * i) / 12; + // Create explosion particles with random angles and speeds + const particleCount = 8 + Math.floor(Math.random() * 8); // Random number of particles (8-15) + for (let i = 0; i < particleCount; i++) { + // Random angle with some clustering + const baseAngle = (Math.PI * 2 * i) / particleCount; + const randomAngle = baseAngle + (Math.random() - 0.5) * 1.5; // Add up to ±0.75 radians of randomness + + // Random speed multiplier + const speedMultiplier = 0.7 + Math.random() * 0.6; // Speed varies from 0.7x to 1.3x + + // Random offset from center + const startOffset = Math.random() * 5; + const startX = centerX + Math.cos(randomAngle) * startOffset; + const startY = centerY + Math.sin(randomAngle) * startOffset; + gameState.particles.push( createParticle( - ParticleTypes.DEATH_PARTICLE, - { x: centerX, y: centerY }, - angle + { + ...ParticleTypes.DEATH_PARTICLE, + speed: ParticleTypes.DEATH_PARTICLE.speed * speedMultiplier, + lifetime: ParticleTypes.DEATH_PARTICLE.lifetime * (0.8 + Math.random() * 0.4) // Random lifetime 80%-120% + }, + { x: startX, y: startY }, + randomAngle ) ); } |