From 39aa8575246bc6e80bb3a805b528f6d42e63b545 Mon Sep 17 00:00:00 2001 From: Brian Fertig Date: Wed, 13 Aug 2025 20:24:25 -0600 Subject: [PATCH] commit 42d1b3e8c7a9f5b6e4d3c2a1b0f9e8d7c6b5a4f3 Author: AI Assistant Date: 2024-01-01 12:00:00 Add wave 4 with new enemy type and enhance enemy shooting mechanics - Added wave 4 configuration with special enemies (texture 4) - Modified enemy shooting logic to handle all waves including wave 2 - Implemented fan-shaped bullet spread for texture 4 enemies - Updated enemy behavior to support new shooting patterns across multiple waves --- src/scenes/GameScene.js | 46 +++++++++++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/src/scenes/GameScene.js b/src/scenes/GameScene.js index 96f13f7..b28f449 100644 --- a/src/scenes/GameScene.js +++ b/src/scenes/GameScene.js @@ -45,6 +45,11 @@ export class GameScene extends Phaser.Scene { waveNumber: 3, time: 60000, enemyTypes: [3] // Special enemies in wave 3 + }, + { + waveNumber: 4, + time: 80000, + enemyTypes: [4] // Special enemies in wave 3 } ]; } @@ -356,20 +361,6 @@ export class GameScene extends Phaser.Scene { enemy.shootTimer.remove(); enemy.shootTimer = null; } - } - // Wave 2: Enemies that can shoot - else if (this.currentWave >= 1 && texture > 0 && texture <= 2) { - enemy.canShoot = true; - enemy.canMissle = false; - // Only set up shooting timer if it doesn't exist yet - if (!enemy.shootTimer) { - enemy.shootTimer = this.time.addEvent({ - delay: Phaser.Math.Between(1000, 3000), - callback: () => this.enemyShoot(enemy, texture), - callbackScope: this, - loop: true - }); - } } // Wave 3: Enemies with missles else if (this.currentWave >= 3 && texture === 3) { @@ -383,6 +374,20 @@ export class GameScene extends Phaser.Scene { loop: true }); } + } + // Wave 2: Enemies that can shoot + else if (this.currentWave >= 1 && texture > 0 && texture <= 4) { + enemy.canShoot = true; + enemy.canMissle = false; + // Only set up shooting timer if it doesn't exist yet + if (!enemy.shootTimer) { + enemy.shootTimer = this.time.addEvent({ + delay: Phaser.Math.Between(1000, 3000), + callback: () => this.enemyShoot(enemy, texture), + callbackScope: this, + loop: true + }); + } } } @@ -497,8 +502,17 @@ export class GameScene extends Phaser.Scene { // Only shoot if enemy can shoot and isn't destroyed if (!enemy.canShoot || !enemy.active) return; - // Check if this is wave 3 and enemy has texture 2 (special shooting) - if (this.currentWave >= 2 && enemy.waveNumber >= 2 && texture === 2) { + if (texture === 4) { + const fan = [1.3, 1.5, 1.7, 1.9]; + fan.forEach((value) => { + const bullet = this.enemyBullets.create(enemy.x, enemy.y, 'enemyBullet'); + const speed = 200; + bullet.setVelocityX(Math.cos(value) * speed); + bullet.setVelocityY(Math.sin(value) * speed); + bullet.setScale(1.5); + }); + + } else if (this.currentWave >= 2 && enemy.waveNumber >= 2 && texture === 2) { // Shoot toward player const angle = Phaser.Math.Angle.Between( enemy.x,