------------------------------------------------------------
commit b1f85e919787f7a33936fcb520e4ae584966d83e
Author: Breck Yunits <breck7@gmail.com> Date: Sun Nov 24 15:32:32 2024 -0800 diff --git a/WaveWar.js b/WaveWar.js index 7fcfea8..e005cf8 100644 --- a/WaveWar.js +++ b/WaveWar.js @@ -209,7 +209,7 @@ this.earthHealth = 1.0; // 1.0 = full health, 0 = dead this.drones = [] this.lastDroneSpawn = 0 this.droneSpawnInterval = 1000 // Spawn a new drone every 2 seconds - this.maxDrones = 500 // Maximum number of drones allowed + this.maxDrones = 200 // Maximum number of drones allowed } ------------------------------------------------------------
commit 237586d9e6db57e61b1509e9d5d8953059347686
Author: Breck Yunits <breck7@gmail.com> Date: Sun Nov 24 15:31:17 2024 -0800 diff --git a/WaveWar.js b/WaveWar.js index ac8a82e..7fcfea8 100644 --- a/WaveWar.js +++ b/WaveWar.js @@ -209,7 +209,7 @@ this.earthHealth = 1.0; // 1.0 = full health, 0 = dead this.drones = [] this.lastDroneSpawn = 0 this.droneSpawnInterval = 1000 // Spawn a new drone every 2 seconds - this.maxDrones = 1000 // Maximum number of drones allowed + this.maxDrones = 500 // Maximum number of drones allowed } @@ -816,7 +816,7 @@ const texture = new THREE.TextureLoader().load("earth_atmos_2048.jpg") ) { this.drones.push(new Drone(this)) this.lastDroneSpawn = currentTime - this.droneSpawnInterval = Math.max(10, this.droneSpawnInterval * .98) + this.droneSpawnInterval = Math.max(10, this.droneSpawnInterval * .95) } ------------------------------------------------------------
commit 2d2763e5abe34808bc18e04c807353f66d9a6995
Author: Breck Yunits <breck7@gmail.com> Date: Sun Nov 24 15:29:29 2024 -0800 diff --git a/WaveWar.js b/WaveWar.js index 76e816d..ac8a82e 100644 --- a/WaveWar.js +++ b/WaveWar.js @@ -816,7 +816,7 @@ const texture = new THREE.TextureLoader().load("earth_atmos_2048.jpg") ) { this.drones.push(new Drone(this)) this.lastDroneSpawn = currentTime - this.droneSpawnInterval = Math.max(10, this.droneSpawnInterval * .99) + this.droneSpawnInterval = Math.max(10, this.droneSpawnInterval * .98) } ------------------------------------------------------------
commit b1ab71f7d0992f861c10338464fc12cead1484a2
Author: Breck Yunits <breck7@gmail.com> Date: Sun Nov 24 15:27:38 2024 -0800 diff --git a/WaveWar.js b/WaveWar.js index acd763a..76e816d 100644 --- a/WaveWar.js +++ b/WaveWar.js @@ -812,7 +812,7 @@ const texture = new THREE.TextureLoader().load("earth_atmos_2048.jpg") // Spawn new drones if ( currentTime - this.lastDroneSpawn > this.droneSpawnInterval && - this.drones.length < this.maxDrones + this.drones.length < this.maxDrones && !this.gameOver ) { this.drones.push(new Drone(this)) this.lastDroneSpawn = currentTime ------------------------------------------------------------
commit 4d0d9575443368de665d7e88821cb692634a3c8e
Author: Breck Yunits <breck7@gmail.com> Date: Sun Nov 24 15:26:29 2024 -0800 diff --git a/WaveWar.js b/WaveWar.js index b8dc4f3..acd763a 100644 --- a/WaveWar.js +++ b/WaveWar.js @@ -1,7 +1,7 @@ class Drone { constructor(globe) { this.globe = globe - this.speed = 0.01 + Math.random() * 0.02 + this.speed = 0.01 + Math.random() * 0.2 this.mesh = this.createDroneMesh() this.position = this.getRandomPosition() this.target = this.getRandomPosition() @@ -56,7 +56,8 @@ class Drone { ) } - update(delta) { + update(delta) { + if (this.globe.gameOver) return; if (this.isExploding) { this.updateExplosion(delta) return @@ -171,7 +172,8 @@ class Globe { this.spikes = [] this.animationId = null this.stars = null - +this.earthHealth = 1.0; // 1.0 = full health, 0 = dead + this.gameOver = false; this.score = 0; this.createScoreDisplay(); @@ -574,17 +576,20 @@ class Globe { // Create starry background this.createStarField() + + // Create Earth with better lighting const geometry = new THREE.SphereGeometry(0.5, 32, 32) - const texture = new THREE.TextureLoader().load("earth_atmos_2048.jpg") - - // Use PhongMaterial for better lighting +const texture = new THREE.TextureLoader().load("earth_atmos_2048.jpg") const material = new THREE.MeshPhongMaterial({ map: texture, specular: 0x333333, shininess: 5, + emissive: 0xff0000, // Red glow for damage + emissiveIntensity: 0 // Start with no damage glow }) + this.earth = new THREE.Mesh(geometry, material) this.scene.add(this.earth) @@ -607,6 +612,88 @@ class Globe { return this } + damageEarth() { + if (this.gameOver) return; + + this.earthHealth = Math.max(0, this.earthHealth - 0.1); // Reduce health by 10% + this.earth.material.emissiveIntensity = 1 - this.earthHealth; // Increase red glow + + if (this.earthHealth <= 0) { + this.triggerGameOver(); + } + } + + + triggerGameOver() { + this.gameOver = true; + + // Create explosion particles + const particleCount = 1000; + const particles = new THREE.Group(); + + for (let i = 0; i < particleCount; i++) { + const geometry = new THREE.BoxGeometry(0.02, 0.02, 0.02); + const material = new THREE.MeshPhongMaterial({ + color: Math.random() > 0.5 ? 0xff4444 : 0xff7700, + emissive: 0x441111, + }); + const particle = new THREE.Mesh(geometry, material); + + // Position particles on earth's surface + const theta = Math.random() * Math.PI * 2; + const phi = Math.random() * Math.PI; + const radius = 0.5; + + particle.position.x = radius * Math.sin(phi) * Math.cos(theta); + particle.position.y = radius * Math.sin(phi) * Math.sin(theta); + particle.position.z = radius * Math.cos(phi); + + // Add velocity for explosion + const velocity = new THREE.Vector3() + .copy(particle.position) + .normalize() + .multiplyScalar(0.03); + particle.velocity = velocity; + + particles.add(particle); + } + + this.scene.add(particles); + this.explosionParticles = particles; + + // Hide Earth + this.earth.visible = false; + + // Create game over text + const gameOverDiv = document.createElement('div'); + gameOverDiv.style.position = 'fixed'; + gameOverDiv.style.top = '50%'; + gameOverDiv.style.left = '50%'; + gameOverDiv.style.transform = 'translate(-50%, -50%)'; + gameOverDiv.style.color = '#ff0000'; + gameOverDiv.style.fontSize = '64px'; + gameOverDiv.style.fontFamily = 'Arial, sans-serif'; + gameOverDiv.style.fontWeight = 'bold'; + gameOverDiv.style.textShadow = '0 0 10px #ff0000'; + gameOverDiv.style.zIndex = '1000'; + gameOverDiv.innerHTML = `GAME OVER<br>Score: ${this.score}`; + document.body.appendChild(gameOverDiv); + + // Start explosion animation + this.animateExplosion(); + } + + animateExplosion() { + if (!this.explosionParticles) return; + + this.explosionParticles.children.forEach(particle => { + particle.position.add(particle.velocity); + particle.scale.multiplyScalar(0.98); + }); + + requestAnimationFrame(() => this.animateExplosion()); + } + setupMouseControls() { const canvas = this.renderer.domElement @@ -732,6 +819,18 @@ class Globe { this.droneSpawnInterval = Math.max(10, this.droneSpawnInterval * .99) } + + // Check for drone collisions with Earth + this.drones.forEach((drone) => { + if (!drone.isExploding) { + const distanceFromCenter = drone.position.length(); + if (distanceFromCenter <= 0.52) { // Slightly larger than Earth's radius (0.5) + this.damageEarth(); + drone.startExplosion(); + } + } + }); + // Update drones this.drones.forEach((drone) => drone.update(delta)) ------------------------------------------------------------
commit 54f9d46e8e336b2a3c27a56f2bfae2333f0e8884
Author: Breck Yunits <breck7@gmail.com> Date: Sun Nov 24 15:13:52 2024 -0800 diff --git a/WaveWar.js b/WaveWar.js index 66a0ce0..b8dc4f3 100644 --- a/WaveWar.js +++ b/WaveWar.js @@ -313,6 +313,8 @@ class Globe { document.addEventListener("keydown", (e) => { if (e.key.toLowerCase() === "e") { this.handleAction("EMP") + }else if (e.key.toLowerCase() === " ") { + this.handleAction("EMP") } else if (e.key.toLowerCase() === "s") { this.handleAction("SOUND") } ------------------------------------------------------------
commit 2d848b43c2186681fb0b7330821b7991ebd9db9a
Author: Breck Yunits <breck7@gmail.com> Date: Sun Nov 24 15:09:16 2024 -0800 diff --git a/WaveWar.js b/WaveWar.js index bd31d35..66a0ce0 100644 --- a/WaveWar.js +++ b/WaveWar.js @@ -108,6 +108,9 @@ class Drone { startExplosion() { this.isExploding = true this.explosionStartTime = Date.now() + // Increment score when drone is destroyed + this.globe.score++; + document.getElementById('score-display').textContent = `Drones Destroyed: ${this.globe.score}`; // Create explosion particles const particleCount = 20 @@ -145,10 +148,6 @@ class Drone { this.globe.scene.remove(this.explosionParticles); this.globe.drones = this.globe.drones.filter((d) => d !== this); - // Increment score when drone is destroyed - this.globe.score++; - document.getElementById('score-display').textContent = `Drones: ${this.globe.score}`; - return; } ------------------------------------------------------------
commit 3b4d855b2e057ac42f8f9817e553134109eb5f07
Author: Breck Yunits <breck7@gmail.com> Date: Sun Nov 24 15:07:43 2024 -0800 diff --git a/WaveWar.js b/WaveWar.js index c285d79..bd31d35 100644 --- a/WaveWar.js +++ b/WaveWar.js @@ -134,27 +134,32 @@ class Drone { this.globe.scene.add(particles) this.explosionParticles = particles } - +// Modify the Drone class's updateExplosion method updateExplosion(delta) { - const elapsed = Date.now() - this.explosionStartTime - const progress = elapsed / this.explosionDuration + const elapsed = Date.now() - this.explosionStartTime; + const progress = elapsed / this.explosionDuration; if (progress >= 1) { // Remove drone and particles - this.globe.scene.remove(this.mesh) - this.globe.scene.remove(this.explosionParticles) - this.globe.drones = this.globe.drones.filter((d) => d !== this) - return + this.globe.scene.remove(this.mesh); + this.globe.scene.remove(this.explosionParticles); + this.globe.drones = this.globe.drones.filter((d) => d !== this); + + // Increment score when drone is destroyed + this.globe.score++; + document.getElementById('score-display').textContent = `Drones: ${this.globe.score}`; + + return; } // Update particle positions and scale this.explosionParticles.children.forEach((particle) => { - particle.position.add(particle.velocity) - particle.scale.multiplyScalar(0.95) - }) + particle.position.add(particle.velocity); + particle.scale.multiplyScalar(0.95); + }); // Fade out original drone - this.mesh.scale.multiplyScalar(0.9) + this.mesh.scale.multiplyScalar(0.9); } } @@ -168,6 +173,9 @@ class Globe { this.animationId = null this.stars = null + this.score = 0; + this.createScoreDisplay(); + // Camera control properties this.isDragging = false this.previousMousePosition = { @@ -203,6 +211,26 @@ class Globe { this.maxDrones = 1000 // Maximum number of drones allowed } + + createScoreDisplay() { + const scoreDisplay = document.createElement("div"); + scoreDisplay.style.position = "fixed"; + scoreDisplay.style.top = "20px"; + scoreDisplay.style.right = "20px"; + scoreDisplay.style.padding = "10px 20px"; + scoreDisplay.style.backgroundColor = "rgba(0, 0, 0, 0.8)"; + scoreDisplay.style.color = "#4CAF50"; + scoreDisplay.style.borderRadius = "10px"; + scoreDisplay.style.fontSize = "24px"; + scoreDisplay.style.fontFamily = "monospace"; + scoreDisplay.style.zIndex = "1000"; + scoreDisplay.style.border = "1px solid rgba(76, 175, 80, 0.3)"; + scoreDisplay.id = "score-display"; + scoreDisplay.textContent = "Drones Destroyed: 0"; + document.body.appendChild(scoreDisplay); + } + + createControlPanel() { const controlPanel = document.createElement("div") controlPanel.style.position = "fixed" @@ -312,7 +340,7 @@ class Globe { } } - triggerSound() { + triggerSound() { const soundGeometry = new THREE.SphereGeometry(0.5, 32, 32) const soundMaterial = new THREE.ShaderMaterial({ transparent: true, @@ -336,7 +364,7 @@ class Globe { void main() { float intensity = 1.0 - (time * time); - float edge = 0.1; + float edge = 0.5; float rim = smoothstep(0.5 - edge, 0.5 + edge, dot(vNormal, vec3(0.0, 0.0, 1.0))); float wave = sin(time * 20.0) * 0.5 + 0.5; gl_FragColor = vec4(color, intensity * (1.0 - rim) * wave * 0.7); @@ -352,7 +380,7 @@ class Globe { geometry: soundGeometry, material: soundMaterial, startTime: Date.now(), - duration: 2000, + duration: 4000, // Increased from 2000 to 4000 for slower wave maxScale: 8, } @@ -375,7 +403,8 @@ class Globe { wave.material.dispose() this.activeSoundWaves.splice(i, 1) } else { - const scale = 1 + (wave.maxScale - 1) * progress + // Slower expansion rate + const scale = 1 + (wave.maxScale - 1) * (progress * 0.5) // Added 0.5 multiplier to slow expansion wave.mesh.scale.set(scale, scale, scale) wave.material.uniforms.time.value = progress } @@ -411,7 +440,7 @@ class Globe { void main() { float intensity = 1.0 - (time * time); // Inverse square law decay - float edge = 0.05; + float edge = 0.2; float rim = smoothstep(0.5 - edge, 0.5 + edge, dot(vNormal, vec3(0.0, 0.0, 1.0))); gl_FragColor = vec4(color, intensity * (1.0 - rim) * 0.5); } diff --git a/test.js b/test.js deleted file mode 100644 index e69de29..0000000 ------------------------------------------------------------
commit df1f43aac6ef7a61ed9683ad5ec51a04d315b412
Author: Breck Yunits <breck7@gmail.com> Date: Sun Nov 24 15:01:27 2024 -0800 diff --git a/WaveWar.js b/WaveWar.js index 8a80874..c285d79 100644 --- a/WaveWar.js +++ b/WaveWar.js @@ -699,7 +699,7 @@ class Globe { ) { this.drones.push(new Drone(this)) this.lastDroneSpawn = currentTime - this.droneSpawnInterval = Math.max(10, this.droneSpawnInterval * .8) + this.droneSpawnInterval = Math.max(10, this.droneSpawnInterval * .99) } // Update drones ------------------------------------------------------------
commit d103df8b435205fa7379802892091c387b667ea4
Author: Breck Yunits <breck7@gmail.com> Date: Sun Nov 24 14:57:25 2024 -0800 diff --git a/index.html b/index.html index aab6248..dcf70b1 100644 --- a/index.html +++ b/index.html @@ -33,7 +33,7 @@ <meta name="twitter:card" content="summary_large_image" /> </head> <body> - <a id="summaryLink"></a> + <a id="summaryLink">WaveWar</a> <div id="log-container"></div> <link rel="stylesheet" type="text/css" href="wavewar.css" /> <script src="three.min.js"></script>