```commit-message

Enemy bullet firing logic update with randomization and missile trajectory adjustments

- Added randomization to enemy bullet firing (50% chance of shooting straight down)
- Adjusted enemy missile trajectories by reversing vertical velocity and updating angles
- This change introduces more varied enemy behavior while maintaining game balance
```
This commit is contained in:
Brian Fertig 2025-08-07 07:56:49 -06:00
parent c93e599556
commit 68a49a69bc
1 changed files with 9 additions and 6 deletions

View File

@ -513,11 +513,14 @@ export class GameScene extends Phaser.Scene {
bullet.setVelocityY(Math.sin(angle) * speed); bullet.setVelocityY(Math.sin(angle) * speed);
bullet.setScale(1.5); bullet.setScale(1.5);
} else if (texture === 1) { } else if (texture === 1) {
const vari = Phaser.Math.Between(1,2);
if (vari === 2) {
// Regular straight-down shooting // Regular straight-down shooting
const bullet = this.enemyBullets.create(enemy.x, enemy.y, 'enemyBullet'); const bullet = this.enemyBullets.create(enemy.x, enemy.y, 'enemyBullet');
bullet.setVelocityY(300); // Move straight down at 200px/s bullet.setVelocityY(300); // Move straight down at 200px/s
bullet.setScale(1.5); bullet.setScale(1.5);
} }
}
// Sound effect for enemy shooting // Sound effect for enemy shooting
this.sound.play('enemy-shoot'); this.sound.play('enemy-shoot');
@ -533,8 +536,8 @@ export class GameScene extends Phaser.Scene {
const missle2 = this.enemyMissles.create(enemy.x, enemy.y, 'enemy-sprite', 30); const missle2 = this.enemyMissles.create(enemy.x, enemy.y, 'enemy-sprite', 30);
// Initial velocity // Initial velocity
missle1.setVelocityX(-100).setVelocityY(200).setAngle(45).setScale(.5); missle1.setVelocityX(-100).setVelocityY(-200).setAngle(135).setScale(.5);
missle2.setVelocityX(100).setVelocityY(200).setAngle(-45).setScale(.5); missle2.setVelocityX(100).setVelocityY(-200).setAngle(-135).setScale(.5);
// After 500ms, change direction towards player and increase speed // After 500ms, change direction towards player and increase speed
this.time.delayedCall(500, () => { this.time.delayedCall(500, () => {