From ac7e975cc7a194f0b7993a1a884dd98d47b73a6c Mon Sep 17 00:00:00 2001 From: elioat Date: Sun, 16 Feb 2025 16:25:07 -0500 Subject: * --- html/tower/js/game.js | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) (limited to 'html') 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 ) ); } -- cgit 1.4.1-2-gfad0 ds?id=fd6333ed6640fcc23a8f1a92a49cf45e13c96f17'>uswds/img/material-icons/library_add.svg
blob: baea3e9eadeb248f757b5d594fa6a72571949b10 (plain) (blame)
1