cutechicken commited on
Commit
657a924
ยท
verified ยท
1 Parent(s): a71b9b6

Update game.js

Browse files
Files changed (1) hide show
  1. game.js +15 -33
game.js CHANGED
@@ -609,7 +609,7 @@ class Fighter {
609
  // ํƒ„ํ™˜ ์ดˆ๊ธฐ ์œ„์น˜ ์ €์žฅ
610
  bullet.startPosition = bullet.position.clone();
611
 
612
- const bulletSpeed = 1000;
613
  const direction = new THREE.Vector3(0, 0, 1);
614
  direction.applyEuler(this.rotation);
615
  bullet.velocity = direction.multiplyScalar(bulletSpeed);
@@ -617,39 +617,21 @@ class Fighter {
617
  scene.add(bullet);
618
  this.bullets.push(bullet);
619
 
620
- // m134.ogg ์†Œ๋ฆฌ ์žฌ์ƒ - ์ตœ๋Œ€ 5๊ฐœ๊นŒ์ง€ ์ค‘์ฒฉ, ๋žœ๋ค ํ”ผ์น˜
621
  try {
622
- // ์žฌ์ƒ ์™„๋ฃŒ๋œ ์˜ค๋””์˜ค ์ œ๊ฑฐ
623
- this.gunfireAudios = this.gunfireAudios.filter(audio => !audio.ended);
624
 
625
- // ์ตœ๋Œ€ 5๊ฐœ๊นŒ์ง€๋งŒ ์žฌ์ƒ
626
- if (this.gunfireAudios.length < 5) {
627
- const audio = new Audio('sounds/m134.ogg');
628
- audio.volume = 0.3;
629
-
630
- // ํ”ผ์น˜ ๋ณ€๊ฒฝ์„ ์œ„ํ•œ Web Audio API ์‚ฌ์šฉ
631
- const audioContext = new (window.AudioContext || window.webkitAudioContext)();
632
- const source = audioContext.createMediaElementSource(audio);
633
- const pitchShift = audioContext.createGain();
634
-
635
- // -2 ~ +2 ์‚ฌ์ด์˜ ๋žœ๋ค ํ”ผ์น˜ (playbackRate๋กœ ์‹œ๋ฎฌ๋ ˆ์ด์…˜)
636
- const randomPitch = 0.8 + Math.random() * 0.4; // 0.8 ~ 1.2 ๋ฒ”์œ„
637
- audio.playbackRate = randomPitch;
638
-
639
- source.connect(pitchShift);
640
- pitchShift.connect(audioContext.destination);
641
-
642
- audio.play().catch(e => console.log('Gunfire sound failed to play'));
643
- this.gunfireAudios.push(audio);
644
-
645
- // ์žฌ์ƒ ์™„๋ฃŒ ์‹œ ๋ฐฐ์—ด์—์„œ ์ œ๊ฑฐ
646
- audio.addEventListener('ended', () => {
647
- const index = this.gunfireAudios.indexOf(audio);
648
- if (index > -1) {
649
- this.gunfireAudios.splice(index, 1);
650
- }
651
- });
652
- }
653
  } catch (e) {
654
  console.log('Audio error:', e);
655
  }
@@ -850,7 +832,7 @@ class EnemyFighter {
850
 
851
  const direction = new THREE.Vector3(0, 0, 1);
852
  direction.applyEuler(this.rotation);
853
- bullet.velocity = direction.multiplyScalar(800);
854
 
855
  this.scene.add(bullet);
856
  this.bullets.push(bullet);
 
609
  // ํƒ„ํ™˜ ์ดˆ๊ธฐ ์œ„์น˜ ์ €์žฅ
610
  bullet.startPosition = bullet.position.clone();
611
 
612
+ const bulletSpeed = 1500; // 1000์—์„œ 1500์œผ๋กœ ์ฆ๊ฐ€ (50% ๋น ๋ฅด๊ฒŒ)
613
  const direction = new THREE.Vector3(0, 0, 1);
614
  direction.applyEuler(this.rotation);
615
  bullet.velocity = direction.multiplyScalar(bulletSpeed);
 
617
  scene.add(bullet);
618
  this.bullets.push(bullet);
619
 
620
+ // m134.ogg ์†Œ๋ฆฌ ์žฌ์ƒ - ์ค‘์ฒฉ ์ œํ•œ ํ•ด์ œ, ๋žœ๋ค ํ”ผ์น˜
621
  try {
622
+ const audio = new Audio('sounds/m134.ogg');
623
+ audio.volume = 0.3;
624
 
625
+ // -2 ~ +2 ์‚ฌ์ด์˜ ๋žœ๋ค ํ”ผ์น˜ (playbackRate๋กœ ์‹œ๋ฎฌ๋ ˆ์ด์…˜)
626
+ const randomPitch = 0.8 + Math.random() * 0.4; // 0.8 ~ 1.2 ๋ฒ”์œ„
627
+ audio.playbackRate = randomPitch;
628
+
629
+ audio.play().catch(e => console.log('Gunfire sound failed to play'));
630
+
631
+ // ์žฌ์ƒ ์™„๋ฃŒ ์‹œ ๋ฉ”๋ชจ๋ฆฌ ์ •๋ฆฌ๋ฅผ ์œ„ํ•ด ์ฐธ์กฐ ์ œ๊ฑฐ
632
+ audio.addEventListener('ended', () => {
633
+ audio.remove();
634
+ });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
635
  } catch (e) {
636
  console.log('Audio error:', e);
637
  }
 
832
 
833
  const direction = new THREE.Vector3(0, 0, 1);
834
  direction.applyEuler(this.rotation);
835
+ bullet.velocity = direction.multiplyScalar(1200); // 800์—์„œ 1200์œผ๋กœ ์ฆ๊ฐ€ (50% ๋น ๋ฅด๊ฒŒ)
836
 
837
  this.scene.add(bullet);
838
  this.bullets.push(bullet);