Spaces:
Running
Running
Update game.js
Browse files
game.js
CHANGED
|
@@ -588,8 +588,8 @@ class Fighter {
|
|
| 588 |
|
| 589 |
this.ammo--;
|
| 590 |
|
| 591 |
-
// ์ง์ ๋ชจ์์ ํํ (๋
|
| 592 |
-
const bulletGeometry = new THREE.CylinderGeometry(0.
|
| 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 |
-
//
|
| 651 |
-
if (bullet.position.distanceTo(bullet.startPosition) >
|
| 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.
|
| 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 <
|
| 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 <
|
| 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 |
|