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

Update game.js

Browse files
Files changed (1) hide show
  1. game.js +35 -9
game.js CHANGED
@@ -588,8 +588,8 @@ class Fighter {
588
 
589
  this.ammo--;
590
 
591
- // ์ง์„  ๋ชจ์–‘์˜ ํƒ„ํ™˜ (๋” ๋‘๊ป๊ฒŒ)
592
- const bulletGeometry = new THREE.CylinderGeometry(0.5, 0.5, 8, 8); // ๋ฐ˜์ง€๋ฆ„ 0.5, ๊ธธ์ด 8
593
  const bulletMaterial = new THREE.MeshBasicMaterial({
594
  color: 0xffff00,
595
  emissive: 0xffff00,
@@ -620,7 +620,7 @@ class Fighter {
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 ๋ฒ”์œ„
@@ -647,8 +647,8 @@ class Fighter {
647
  const angle = Math.atan2(direction.x, direction.z);
648
  bullet.rotation.y = angle;
649
 
650
- // 3000m ์ด์ƒ ๋‚ ์•„๊ฐ€๋ฉด ์ œ๊ฑฐ
651
- if (bullet.position.distanceTo(bullet.startPosition) > 3000 ||
652
  bullet.position.y < 0 ||
653
  bullet.position.y > GAME_CONSTANTS.MAX_ALTITUDE + 500) {
654
  scene.remove(bullet);
@@ -700,6 +700,7 @@ class EnemyFighter {
700
  this.patrolCenter = position.clone();
701
  this.patrolRadius = 2000;
702
  this.lastStateChange = 0;
 
703
  }
704
 
705
  async initialize(loader) {
@@ -813,8 +814,8 @@ class EnemyFighter {
813
  shoot() {
814
  this.lastShootTime = Date.now();
815
 
816
- // ์ง์„  ๋ชจ์–‘์˜ ํƒ„ํ™˜ (์ ๊ธฐ๋„ ๋™์ผํ•˜๊ฒŒ ์ ์šฉ)
817
- const bulletGeometry = new THREE.CylinderGeometry(0.4, 0.4, 6, 8);
818
  const bulletMaterial = new THREE.MeshBasicMaterial({
819
  color: 0xff0000,
820
  emissive: 0xff0000,
@@ -836,6 +837,30 @@ class EnemyFighter {
836
 
837
  this.scene.add(bullet);
838
  this.bullets.push(bullet);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
839
  }
840
 
841
  updateBullets(deltaTime) {
@@ -1001,6 +1026,7 @@ class Game {
1001
  );
1002
 
1003
  const enemy = new EnemyFighter(this.scene, position);
 
1004
  await enemy.initialize(this.loader);
1005
  this.enemies.push(enemy);
1006
  }
@@ -1627,7 +1653,7 @@ class Game {
1627
  if (!enemy.mesh || !enemy.isLoaded) continue;
1628
 
1629
  const distance = bullet.position.distanceTo(enemy.position);
1630
- if (distance < 25) {
1631
  this.scene.remove(bullet);
1632
  this.fighter.bullets.splice(i, 1);
1633
 
@@ -1647,7 +1673,7 @@ class Game {
1647
  this.enemies.forEach(enemy => {
1648
  enemy.bullets.forEach((bullet, index) => {
1649
  const distance = bullet.position.distanceTo(this.fighter.position);
1650
- if (distance < 30) {
1651
  this.scene.remove(bullet);
1652
  enemy.bullets.splice(index, 1);
1653
 
 
588
 
589
  this.ammo--;
590
 
591
+ // ์ง์„  ๋ชจ์–‘์˜ ํƒ„ํ™˜ (50% ๋” ํฌ๊ฒŒ)
592
+ const bulletGeometry = new THREE.CylinderGeometry(0.75, 0.75, 12, 8); // ๋ฐ˜์ง€๋ฆ„ 0.5โ†’0.75, ๊ธธ์ด 8โ†’12
593
  const bulletMaterial = new THREE.MeshBasicMaterial({
594
  color: 0xffff00,
595
  emissive: 0xffff00,
 
620
  // m134.ogg ์†Œ๋ฆฌ ์žฌ์ƒ - ์ค‘์ฒฉ ์ œํ•œ ํ•ด์ œ, ๋žœ๋ค ํ”ผ์น˜
621
  try {
622
  const audio = new Audio('sounds/m134.ogg');
623
+ audio.volume = 0.15; // 0.3์—์„œ 0.15๋กœ ๊ฐ์†Œ (50% ์ค„์ž„)
624
 
625
  // -2 ~ +2 ์‚ฌ์ด์˜ ๋žœ๋ค ํ”ผ์น˜ (playbackRate๋กœ ์‹œ๋ฎฌ๋ ˆ์ด์…˜)
626
  const randomPitch = 0.8 + Math.random() * 0.4; // 0.8 ~ 1.2 ๋ฒ”์œ„
 
647
  const angle = Math.atan2(direction.x, direction.z);
648
  bullet.rotation.y = angle;
649
 
650
+ // 6000m ์ด์ƒ ๋‚ ์•„๊ฐ€๋ฉด ์ œ๊ฑฐ
651
+ if (bullet.position.distanceTo(bullet.startPosition) > 6000 ||
652
  bullet.position.y < 0 ||
653
  bullet.position.y > GAME_CONSTANTS.MAX_ALTITUDE + 500) {
654
  scene.remove(bullet);
 
700
  this.patrolCenter = position.clone();
701
  this.patrolRadius = 2000;
702
  this.lastStateChange = 0;
703
+ this.playerFighter = null; // ํ”Œ๋ ˆ์ด์–ด ์ฐธ์กฐ ์ €์žฅ์šฉ
704
  }
705
 
706
  async initialize(loader) {
 
814
  shoot() {
815
  this.lastShootTime = Date.now();
816
 
817
+ // ์ง์„  ๋ชจ์–‘์˜ ํƒ„ํ™˜ (50% ๋” ํฌ๊ฒŒ)
818
+ const bulletGeometry = new THREE.CylinderGeometry(0.6, 0.6, 9, 8); // ๋ฐ˜์ง€๋ฆ„ 0.4โ†’0.6, ๊ธธ์ด 6โ†’9
819
  const bulletMaterial = new THREE.MeshBasicMaterial({
820
  color: 0xff0000,
821
  emissive: 0xff0000,
 
837
 
838
  this.scene.add(bullet);
839
  this.bullets.push(bullet);
840
+
841
+ // mglaunch.ogg ์†Œ๋ฆฌ ์žฌ์ƒ - ํ”Œ๋ ˆ์ด์–ด๊ฐ€ 1000m ์ด๋‚ด์— ์žˆ์„ ๋•Œ๋งŒ
842
+ if (this.playerFighter) {
843
+ const distanceToPlayer = this.position.distanceTo(this.playerFighter.position);
844
+ if (distanceToPlayer < 1000) {
845
+ try {
846
+ const audio = new Audio('sounds/mglaunch.ogg');
847
+ audio.volume = 0.5; // 50% ์Œ๋Ÿ‰
848
+
849
+ // ๊ฑฐ๋ฆฌ์— ๋”ฐ๋ฅธ ์Œ๋Ÿ‰ ์กฐ์ ˆ (๊ฑฐ๋ฆฌ๊ฐ€ ๋ฉ€์ˆ˜๋ก ์ž‘๊ฒŒ)
850
+ const volumeMultiplier = 1 - (distanceToPlayer / 1000);
851
+ audio.volume = 0.5 * volumeMultiplier;
852
+
853
+ audio.play().catch(e => console.log('Enemy gunfire sound failed to play'));
854
+
855
+ // ์žฌ์ƒ ์™„๋ฃŒ ์‹œ ๋ฉ”๋ชจ๋ฆฌ ์ •๋ฆฌ
856
+ audio.addEventListener('ended', () => {
857
+ audio.remove();
858
+ });
859
+ } catch (e) {
860
+ console.log('Audio error:', e);
861
+ }
862
+ }
863
+ }
864
  }
865
 
866
  updateBullets(deltaTime) {
 
1026
  );
1027
 
1028
  const enemy = new EnemyFighter(this.scene, position);
1029
+ enemy.playerFighter = this.fighter; // ํ”Œ๋ ˆ์ด์–ด ์ฐธ์กฐ ์ „๋‹ฌ
1030
  await enemy.initialize(this.loader);
1031
  this.enemies.push(enemy);
1032
  }
 
1653
  if (!enemy.mesh || !enemy.isLoaded) continue;
1654
 
1655
  const distance = bullet.position.distanceTo(enemy.position);
1656
+ if (distance < 35) { // 25์—์„œ 35๋กœ ์ฆ๊ฐ€ (๋ช…์ค‘ ํŒ์ • ํ™•๋Œ€)
1657
  this.scene.remove(bullet);
1658
  this.fighter.bullets.splice(i, 1);
1659
 
 
1673
  this.enemies.forEach(enemy => {
1674
  enemy.bullets.forEach((bullet, index) => {
1675
  const distance = bullet.position.distanceTo(this.fighter.position);
1676
+ if (distance < 40) { // 30์—์„œ 40์œผ๋กœ ์ฆ๊ฐ€ (๋ช…์ค‘ ํŒ์ • ํ™•๋Œ€)
1677
  this.scene.remove(bullet);
1678
  enemy.bullets.splice(index, 1);
1679