cutechicken commited on
Commit
a81868f
1 Parent(s): 56a245d

Update game.js

Browse files
Files changed (1) hide show
  1. game.js +31 -26
game.js CHANGED
@@ -766,35 +766,40 @@ class Enemy {
766
 
767
 
768
  shoot(playerPosition) {
769
- const currentTime = Date.now();
770
- const attackInterval = this.type === 'tank' ?
771
- ENEMY_CONFIG.ATTACK_INTERVAL :
772
- ENEMY_CONFIG.ATTACK_INTERVAL * 1.5;
773
 
774
- if (currentTime - this.lastAttackTime < attackInterval) return;
775
 
776
- const bulletGeometry = new THREE.SphereGeometry(this.type === 'tank' ? 0.2 : 0.3);
777
- const bulletMaterial = new THREE.MeshBasicMaterial({
778
- color: this.type === 'tank' ? 0xff0000 : 0xff6600
779
- });
780
- const bullet = new THREE.Mesh(bulletGeometry, bulletMaterial);
781
 
782
- bullet.position.copy(this.mesh.position);
783
-
784
- const direction = new THREE.Vector3()
785
- .subVectors(playerPosition, this.mesh.position)
786
- .normalize();
787
-
788
- const bulletSpeed = this.type === 'tank' ?
789
- ENEMY_CONFIG.BULLET_SPEED :
790
- ENEMY_CONFIG.BULLET_SPEED * 0.8;
791
-
792
- bullet.velocity = direction.multiplyScalar(bulletSpeed);
793
-
794
- this.scene.add(bullet);
795
- this.bullets.push(bullet);
796
- this.lastAttackTime = currentTime;
797
- }
 
 
 
 
 
 
798
 
799
  takeDamage(damage) {
800
  this.health -= damage;
 
766
 
767
 
768
  shoot(playerPosition) {
769
+ const currentTime = Date.now();
770
+ const attackInterval = this.type === 'tank' ?
771
+ ENEMY_CONFIG.ATTACK_INTERVAL :
772
+ ENEMY_CONFIG.ATTACK_INTERVAL * 1.5;
773
 
774
+ if (currentTime - this.lastAttackTime < attackInterval) return;
775
 
776
+ // 발사 사운드 재생
777
+ const enemyFireSound = new Audio('sounds/fireenemy3.ogg');
778
+ enemyFireSound.volume = 0.3; // 볼륨 설정
779
+ enemyFireSound.play();
 
780
 
781
+ const bulletGeometry = new THREE.SphereGeometry(this.type === 'tank' ? 0.2 : 0.3);
782
+ const bulletMaterial = new THREE.MeshBasicMaterial({
783
+ color: this.type === 'tank' ? 0xff0000 : 0xff6600
784
+ });
785
+ const bullet = new THREE.Mesh(bulletGeometry, bulletMaterial);
786
+
787
+ bullet.position.copy(this.mesh.position);
788
+
789
+ const direction = new THREE.Vector3()
790
+ .subVectors(playerPosition, this.mesh.position)
791
+ .normalize();
792
+
793
+ const bulletSpeed = this.type === 'tank' ?
794
+ ENEMY_CONFIG.BULLET_SPEED :
795
+ ENEMY_CONFIG.BULLET_SPEED * 0.8;
796
+
797
+ bullet.velocity = direction.multiplyScalar(bulletSpeed);
798
+
799
+ this.scene.add(bullet);
800
+ this.bullets.push(bullet);
801
+ this.lastAttackTime = currentTime;
802
+ }
803
 
804
  takeDamage(damage) {
805
  this.health -= damage;