Spaces:
Running
Running
Update game.js
Browse files
game.js
CHANGED
|
@@ -641,7 +641,7 @@ class Fighter {
|
|
| 641 |
}
|
| 642 |
}
|
| 643 |
|
| 644 |
-
updateBullets(scene, deltaTime) {
|
| 645 |
for (let i = this.bullets.length - 1; i >= 0; i--) {
|
| 646 |
const bullet = this.bullets[i];
|
| 647 |
bullet.position.add(bullet.velocity.clone().multiplyScalar(deltaTime));
|
|
@@ -651,9 +651,17 @@ class Fighter {
|
|
| 651 |
const angle = Math.atan2(direction.x, direction.z);
|
| 652 |
bullet.rotation.y = angle;
|
| 653 |
|
| 654 |
-
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 655 |
if (bullet.position.distanceTo(bullet.startPosition) > 6000 ||
|
| 656 |
-
bullet.position.y < 0 ||
|
| 657 |
bullet.position.y > GAME_CONSTANTS.MAX_ALTITUDE + 500) {
|
| 658 |
scene.remove(bullet);
|
| 659 |
this.bullets.splice(i, 1);
|
|
@@ -695,7 +703,7 @@ class EnemyFighter {
|
|
| 695 |
this.velocity = new THREE.Vector3(0, 0, 120);
|
| 696 |
this.rotation = new THREE.Euler(0, 0, 0);
|
| 697 |
this.health = GAME_CONSTANTS.MAX_HEALTH; // ์ฒด๋ ฅ 1000
|
| 698 |
-
this.speed =
|
| 699 |
this.bullets = [];
|
| 700 |
this.lastShootTime = 0;
|
| 701 |
|
|
@@ -1034,8 +1042,18 @@ class EnemyFighter {
|
|
| 1034 |
const bullet = this.bullets[i];
|
| 1035 |
bullet.position.add(bullet.velocity.clone().multiplyScalar(deltaTime));
|
| 1036 |
|
| 1037 |
-
|
| 1038 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1039 |
this.scene.remove(bullet);
|
| 1040 |
this.bullets.splice(i, 1);
|
| 1041 |
}
|
|
@@ -1866,6 +1884,292 @@ class Game {
|
|
| 1866 |
});
|
| 1867 |
}
|
| 1868 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1869 |
checkCollisions() {
|
| 1870 |
// ํ๋ ์ด์ด ํํ vs ์ ๊ธฐ ์ถฉ๋
|
| 1871 |
for (let i = this.fighter.bullets.length - 1; i >= 0; i--) {
|
|
@@ -2073,7 +2377,7 @@ class Game {
|
|
| 2073 |
|
| 2074 |
this.fighter.updateControls(this.keys, deltaTime);
|
| 2075 |
this.fighter.updatePhysics(deltaTime);
|
| 2076 |
-
this.fighter.updateBullets(this.scene, deltaTime);
|
| 2077 |
|
| 2078 |
// ๋ง์ฐ์ค ๋๋ฆ ์ํ์ผ ๋ ์ฐ์ ๋ฐ์ฌ
|
| 2079 |
if (this.fighter.isMouseDown && this.isStarted) {
|
|
|
|
| 641 |
}
|
| 642 |
}
|
| 643 |
|
| 644 |
+
updateBullets(scene, deltaTime, gameInstance) {
|
| 645 |
for (let i = this.bullets.length - 1; i >= 0; i--) {
|
| 646 |
const bullet = this.bullets[i];
|
| 647 |
bullet.position.add(bullet.velocity.clone().multiplyScalar(deltaTime));
|
|
|
|
| 651 |
const angle = Math.atan2(direction.x, direction.z);
|
| 652 |
bullet.rotation.y = angle;
|
| 653 |
|
| 654 |
+
// ์ง๋ฉด ์ถฉ๋ ์ฒดํฌ ์ถ๊ฐ
|
| 655 |
+
if (bullet.position.y <= 0) {
|
| 656 |
+
// ํฌ๊ณ ํ๋ คํ ์ง๋ฉด ์ถฉ๋ ํจ๊ณผ
|
| 657 |
+
gameInstance.createGroundImpactEffect(bullet.position);
|
| 658 |
+
scene.remove(bullet);
|
| 659 |
+
this.bullets.splice(i, 1);
|
| 660 |
+
continue;
|
| 661 |
+
}
|
| 662 |
+
|
| 663 |
+
// 6000m ์ด์ ๋ ์๊ฐ๊ฑฐ๋ ๋์ด ์ ํ ์ด๊ณผ ์ ์ ๊ฑฐ
|
| 664 |
if (bullet.position.distanceTo(bullet.startPosition) > 6000 ||
|
|
|
|
| 665 |
bullet.position.y > GAME_CONSTANTS.MAX_ALTITUDE + 500) {
|
| 666 |
scene.remove(bullet);
|
| 667 |
this.bullets.splice(i, 1);
|
|
|
|
| 703 |
this.velocity = new THREE.Vector3(0, 0, 120);
|
| 704 |
this.rotation = new THREE.Euler(0, 0, 0);
|
| 705 |
this.health = GAME_CONSTANTS.MAX_HEALTH; // ์ฒด๋ ฅ 1000
|
| 706 |
+
this.speed = 386; // 750kt in m/s (750 * 0.514444) - 1000kt์์ 750kt๋ก ๊ฐ์
|
| 707 |
this.bullets = [];
|
| 708 |
this.lastShootTime = 0;
|
| 709 |
|
|
|
|
| 1042 |
const bullet = this.bullets[i];
|
| 1043 |
bullet.position.add(bullet.velocity.clone().multiplyScalar(deltaTime));
|
| 1044 |
|
| 1045 |
+
// ์ง๋ฉด ์ถฉ๋ ์ฒดํฌ ์ถ๊ฐ
|
| 1046 |
+
if (bullet.position.y <= 0) {
|
| 1047 |
+
// ํฌ๊ณ ํ๋ คํ ์ง๋ฉด ์ถฉ๋ ํจ๊ณผ - Game ์ธ์คํด์ค๋ฅผ ํตํด ํธ์ถ
|
| 1048 |
+
if (window.gameInstance) {
|
| 1049 |
+
window.gameInstance.createGroundImpactEffect(bullet.position);
|
| 1050 |
+
}
|
| 1051 |
+
this.scene.remove(bullet);
|
| 1052 |
+
this.bullets.splice(i, 1);
|
| 1053 |
+
continue;
|
| 1054 |
+
}
|
| 1055 |
+
|
| 1056 |
+
if (bullet.position.distanceTo(this.position) > 5000) {
|
| 1057 |
this.scene.remove(bullet);
|
| 1058 |
this.bullets.splice(i, 1);
|
| 1059 |
}
|
|
|
|
| 1884 |
});
|
| 1885 |
}
|
| 1886 |
|
| 1887 |
+
// ์๋ก์ด ๋ฉ์๋: ํฌ๊ณ ํ๋ คํ ์ง๋ฉด ์ถฉ๋ ํจ๊ณผ
|
| 1888 |
+
createGroundImpactEffect(position) {
|
| 1889 |
+
// ๋ฉ์ธ ํญ๋ฐ ํ๋์
|
| 1890 |
+
const flashGeometry = new THREE.SphereGeometry(15, 16, 16);
|
| 1891 |
+
const flashMaterial = new THREE.MeshBasicMaterial({
|
| 1892 |
+
color: 0xffaa00,
|
| 1893 |
+
emissive: 0xffaa00,
|
| 1894 |
+
emissiveIntensity: 3.0,
|
| 1895 |
+
transparent: true,
|
| 1896 |
+
opacity: 1.0
|
| 1897 |
+
});
|
| 1898 |
+
|
| 1899 |
+
const flash = new THREE.Mesh(flashGeometry, flashMaterial);
|
| 1900 |
+
flash.position.copy(position);
|
| 1901 |
+
flash.position.y = 2; // ์ง๋ฉด์์ ์ฝ๊ฐ ์
|
| 1902 |
+
this.scene.add(flash);
|
| 1903 |
+
|
| 1904 |
+
// ์ถฉ๊ฒฉํ ๋ง
|
| 1905 |
+
const ringGeometry = new THREE.RingGeometry(1, 15, 32);
|
| 1906 |
+
const ringMaterial = new THREE.MeshBasicMaterial({
|
| 1907 |
+
color: 0xff6600,
|
| 1908 |
+
side: THREE.DoubleSide,
|
| 1909 |
+
transparent: true,
|
| 1910 |
+
opacity: 0.8
|
| 1911 |
+
});
|
| 1912 |
+
|
| 1913 |
+
const shockwaveRing = new THREE.Mesh(ringGeometry, ringMaterial);
|
| 1914 |
+
shockwaveRing.position.copy(position);
|
| 1915 |
+
shockwaveRing.position.y = 1;
|
| 1916 |
+
shockwaveRing.rotation.x = -Math.PI / 2;
|
| 1917 |
+
this.scene.add(shockwaveRing);
|
| 1918 |
+
|
| 1919 |
+
// ํํธ ํํฐํด (๋ ๋ง์ด, ๋ ํฌ๊ฒ)
|
| 1920 |
+
const particleCount = 30;
|
| 1921 |
+
const particles = [];
|
| 1922 |
+
const debris = [];
|
| 1923 |
+
|
| 1924 |
+
for (let i = 0; i < particleCount; i++) {
|
| 1925 |
+
// ๋ถ๊ฝ ํํฐํด
|
| 1926 |
+
const particleGeometry = new THREE.SphereGeometry(1 + Math.random(), 6, 6);
|
| 1927 |
+
const particleMaterial = new THREE.MeshBasicMaterial({
|
| 1928 |
+
color: Math.random() > 0.3 ? 0xffaa00 : 0xff0000,
|
| 1929 |
+
emissive: 0xffaa00,
|
| 1930 |
+
emissiveIntensity: 2.0,
|
| 1931 |
+
transparent: true,
|
| 1932 |
+
opacity: 1.0
|
| 1933 |
+
});
|
| 1934 |
+
|
| 1935 |
+
const particle = new THREE.Mesh(particleGeometry, particleMaterial);
|
| 1936 |
+
particle.position.copy(position);
|
| 1937 |
+
particle.position.y = 1;
|
| 1938 |
+
|
| 1939 |
+
// ๋ ๊ฐ๋ ฅํ ํญ๋ฐ ์๋
|
| 1940 |
+
const angle = Math.random() * Math.PI * 2;
|
| 1941 |
+
const speed = 50 + Math.random() * 150;
|
| 1942 |
+
const upSpeed = 30 + Math.random() * 100;
|
| 1943 |
+
|
| 1944 |
+
particle.velocity = new THREE.Vector3(
|
| 1945 |
+
Math.cos(angle) * speed,
|
| 1946 |
+
upSpeed,
|
| 1947 |
+
Math.sin(angle) * speed
|
| 1948 |
+
);
|
| 1949 |
+
|
| 1950 |
+
particle.life = 1.5; // ๋ ์ค๋ ์ง์
|
| 1951 |
+
|
| 1952 |
+
this.scene.add(particle);
|
| 1953 |
+
particles.push(particle);
|
| 1954 |
+
|
| 1955 |
+
// ํ ํํธ
|
| 1956 |
+
if (i % 3 === 0) {
|
| 1957 |
+
const debrisGeometry = new THREE.BoxGeometry(
|
| 1958 |
+
2 + Math.random() * 3,
|
| 1959 |
+
2 + Math.random() * 3,
|
| 1960 |
+
2 + Math.random() * 3
|
| 1961 |
+
);
|
| 1962 |
+
const debrisMaterial = new THREE.MeshLambertMaterial({
|
| 1963 |
+
color: 0x4a3c28, // ํ์
|
| 1964 |
+
transparent: true,
|
| 1965 |
+
opacity: 1.0
|
| 1966 |
+
});
|
| 1967 |
+
|
| 1968 |
+
const debrisPiece = new THREE.Mesh(debrisGeometry, debrisMaterial);
|
| 1969 |
+
debrisPiece.position.copy(position);
|
| 1970 |
+
debrisPiece.position.y = 1;
|
| 1971 |
+
|
| 1972 |
+
// ํ์ ์ถ๊ฐ
|
| 1973 |
+
debrisPiece.rotation.set(
|
| 1974 |
+
Math.random() * Math.PI,
|
| 1975 |
+
Math.random() * Math.PI,
|
| 1976 |
+
Math.random() * Math.PI
|
| 1977 |
+
);
|
| 1978 |
+
|
| 1979 |
+
// ํํธ ์๋
|
| 1980 |
+
const debrisAngle = Math.random() * Math.PI * 2;
|
| 1981 |
+
const debrisSpeed = 30 + Math.random() * 70;
|
| 1982 |
+
|
| 1983 |
+
debrisPiece.velocity = new THREE.Vector3(
|
| 1984 |
+
Math.cos(debrisAngle) * debrisSpeed,
|
| 1985 |
+
20 + Math.random() * 50,
|
| 1986 |
+
Math.sin(debrisAngle) * debrisSpeed
|
| 1987 |
+
);
|
| 1988 |
+
|
| 1989 |
+
debrisPiece.angularVelocity = new THREE.Vector3(
|
| 1990 |
+
(Math.random() - 0.5) * 10,
|
| 1991 |
+
(Math.random() - 0.5) * 10,
|
| 1992 |
+
(Math.random() - 0.5) * 10
|
| 1993 |
+
);
|
| 1994 |
+
|
| 1995 |
+
debrisPiece.life = 2.0;
|
| 1996 |
+
|
| 1997 |
+
this.scene.add(debrisPiece);
|
| 1998 |
+
debris.push(debrisPiece);
|
| 1999 |
+
}
|
| 2000 |
+
}
|
| 2001 |
+
|
| 2002 |
+
// ์ฐ๊ธฐ ํจ๊ณผ
|
| 2003 |
+
const smokeCount = 8;
|
| 2004 |
+
const smokes = [];
|
| 2005 |
+
|
| 2006 |
+
for (let i = 0; i < smokeCount; i++) {
|
| 2007 |
+
const smokeGeometry = new THREE.SphereGeometry(5 + Math.random() * 5, 8, 8);
|
| 2008 |
+
const smokeMaterial = new THREE.MeshBasicMaterial({
|
| 2009 |
+
color: 0x222222,
|
| 2010 |
+
transparent: true,
|
| 2011 |
+
opacity: 0.6
|
| 2012 |
+
});
|
| 2013 |
+
|
| 2014 |
+
const smoke = new THREE.Mesh(smokeGeometry, smokeMaterial);
|
| 2015 |
+
smoke.position.copy(position);
|
| 2016 |
+
smoke.position.y = 2 + Math.random() * 5;
|
| 2017 |
+
smoke.position.x += (Math.random() - 0.5) * 10;
|
| 2018 |
+
smoke.position.z += (Math.random() - 0.5) * 10;
|
| 2019 |
+
|
| 2020 |
+
smoke.velocity = new THREE.Vector3(
|
| 2021 |
+
(Math.random() - 0.5) * 10,
|
| 2022 |
+
5 + Math.random() * 15,
|
| 2023 |
+
(Math.random() - 0.5) * 10
|
| 2024 |
+
);
|
| 2025 |
+
|
| 2026 |
+
smoke.life = 3.0;
|
| 2027 |
+
|
| 2028 |
+
this.scene.add(smoke);
|
| 2029 |
+
smokes.push(smoke);
|
| 2030 |
+
}
|
| 2031 |
+
|
| 2032 |
+
// ์ง๋ฉด ํฌ๋ ์ดํฐ (์์ ํจ๊ณผ)
|
| 2033 |
+
const craterGeometry = new THREE.RingGeometry(5, 20, 16);
|
| 2034 |
+
const craterMaterial = new THREE.MeshBasicMaterial({
|
| 2035 |
+
color: 0x2a2a2a,
|
| 2036 |
+
side: THREE.DoubleSide,
|
| 2037 |
+
transparent: true,
|
| 2038 |
+
opacity: 0.7
|
| 2039 |
+
});
|
| 2040 |
+
|
| 2041 |
+
const crater = new THREE.Mesh(craterGeometry, craterMaterial);
|
| 2042 |
+
crater.position.copy(position);
|
| 2043 |
+
crater.position.y = 0.1;
|
| 2044 |
+
crater.rotation.x = -Math.PI / 2;
|
| 2045 |
+
this.scene.add(crater);
|
| 2046 |
+
|
| 2047 |
+
// ์ ๋๋ฉ์ด์
|
| 2048 |
+
const animateExplosion = () => {
|
| 2049 |
+
let allDead = true;
|
| 2050 |
+
|
| 2051 |
+
// ๋ฉ์ธ ํ๋์
|
| 2052 |
+
if (flash.material.opacity > 0) {
|
| 2053 |
+
flash.material.opacity -= 0.03;
|
| 2054 |
+
flash.scale.multiplyScalar(1.15);
|
| 2055 |
+
allDead = false;
|
| 2056 |
+
} else if (flash.parent) {
|
| 2057 |
+
this.scene.remove(flash);
|
| 2058 |
+
}
|
| 2059 |
+
|
| 2060 |
+
// ์ถฉ๊ฒฉํ ๋ง
|
| 2061 |
+
if (shockwaveRing.material.opacity > 0) {
|
| 2062 |
+
shockwaveRing.material.opacity -= 0.02;
|
| 2063 |
+
shockwaveRing.scale.x += 0.5;
|
| 2064 |
+
shockwaveRing.scale.y += 0.5;
|
| 2065 |
+
allDead = false;
|
| 2066 |
+
} else if (shockwaveRing.parent) {
|
| 2067 |
+
this.scene.remove(shockwaveRing);
|
| 2068 |
+
}
|
| 2069 |
+
|
| 2070 |
+
// ํํฐํด ์
๋ฐ์ดํธ
|
| 2071 |
+
particles.forEach((particle, index) => {
|
| 2072 |
+
if (particle.life > 0) {
|
| 2073 |
+
allDead = false;
|
| 2074 |
+
particle.life -= 0.02;
|
| 2075 |
+
|
| 2076 |
+
// ์์น ์
๋ฐ์ดํธ
|
| 2077 |
+
particle.position.add(particle.velocity.clone().multiplyScalar(0.02));
|
| 2078 |
+
|
| 2079 |
+
// ์ค๋ ฅ
|
| 2080 |
+
particle.velocity.y -= 3;
|
| 2081 |
+
|
| 2082 |
+
// ๊ณต๊ธฐ ์ ํญ
|
| 2083 |
+
particle.velocity.multiplyScalar(0.98);
|
| 2084 |
+
|
| 2085 |
+
// ํ์ด๋ ์์
|
| 2086 |
+
particle.material.opacity = particle.life;
|
| 2087 |
+
|
| 2088 |
+
// ํฌ๊ธฐ ๊ฐ์
|
| 2089 |
+
const scale = particle.life * 0.8 + 0.2;
|
| 2090 |
+
particle.scale.set(scale, scale, scale);
|
| 2091 |
+
} else if (particle.parent) {
|
| 2092 |
+
this.scene.remove(particle);
|
| 2093 |
+
}
|
| 2094 |
+
});
|
| 2095 |
+
|
| 2096 |
+
// ํํธ ์
๋ฐ์ดํธ
|
| 2097 |
+
debris.forEach(piece => {
|
| 2098 |
+
if (piece.life > 0) {
|
| 2099 |
+
allDead = false;
|
| 2100 |
+
piece.life -= 0.02;
|
| 2101 |
+
|
| 2102 |
+
// ์์น ์
๋ฐ์ดํธ
|
| 2103 |
+
piece.position.add(piece.velocity.clone().multiplyScalar(0.02));
|
| 2104 |
+
|
| 2105 |
+
// ํ์
|
| 2106 |
+
piece.rotation.x += piece.angularVelocity.x * 0.02;
|
| 2107 |
+
piece.rotation.y += piece.angularVelocity.y * 0.02;
|
| 2108 |
+
piece.rotation.z += piece.angularVelocity.z * 0.02;
|
| 2109 |
+
|
| 2110 |
+
// ์ค๋ ฅ
|
| 2111 |
+
piece.velocity.y -= 5;
|
| 2112 |
+
|
| 2113 |
+
// ์ง๋ฉด ์ถฉ๋
|
| 2114 |
+
if (piece.position.y <= 0) {
|
| 2115 |
+
piece.position.y = 0;
|
| 2116 |
+
piece.velocity.y *= -0.3;
|
| 2117 |
+
piece.velocity.x *= 0.7;
|
| 2118 |
+
piece.velocity.z *= 0.7;
|
| 2119 |
+
}
|
| 2120 |
+
|
| 2121 |
+
// ํ์ด๋ ์์
|
| 2122 |
+
piece.material.opacity = piece.life / 2;
|
| 2123 |
+
} else if (piece.parent) {
|
| 2124 |
+
this.scene.remove(piece);
|
| 2125 |
+
}
|
| 2126 |
+
});
|
| 2127 |
+
|
| 2128 |
+
// ์ฐ๊ธฐ ์
๋ฐ์ดํธ
|
| 2129 |
+
smokes.forEach(smoke => {
|
| 2130 |
+
if (smoke.life > 0) {
|
| 2131 |
+
allDead = false;
|
| 2132 |
+
smoke.life -= 0.015;
|
| 2133 |
+
|
| 2134 |
+
// ์์น ์
๋ฐ์ดํธ
|
| 2135 |
+
smoke.position.add(smoke.velocity.clone().multiplyScalar(0.02));
|
| 2136 |
+
|
| 2137 |
+
// ์์น
|
| 2138 |
+
smoke.velocity.y *= 0.98;
|
| 2139 |
+
|
| 2140 |
+
// ํ์ฐ
|
| 2141 |
+
smoke.scale.multiplyScalar(1.02);
|
| 2142 |
+
|
| 2143 |
+
// ํ์ด๋ ์์
|
| 2144 |
+
smoke.material.opacity = smoke.life / 5;
|
| 2145 |
+
} else if (smoke.parent) {
|
| 2146 |
+
this.scene.remove(smoke);
|
| 2147 |
+
}
|
| 2148 |
+
});
|
| 2149 |
+
|
| 2150 |
+
// ํฌ๋ ์ดํฐ ํ์ด๋
|
| 2151 |
+
if (crater.material.opacity > 0) {
|
| 2152 |
+
crater.material.opacity -= 0.005;
|
| 2153 |
+
allDead = false;
|
| 2154 |
+
} else if (crater.parent) {
|
| 2155 |
+
this.scene.remove(crater);
|
| 2156 |
+
}
|
| 2157 |
+
|
| 2158 |
+
if (!allDead) {
|
| 2159 |
+
requestAnimationFrame(animateExplosion);
|
| 2160 |
+
}
|
| 2161 |
+
};
|
| 2162 |
+
|
| 2163 |
+
animateExplosion();
|
| 2164 |
+
|
| 2165 |
+
// ์ถฉ๋ ์ฌ์ด๋ ์ฌ์
|
| 2166 |
+
try {
|
| 2167 |
+
const impactSound = new Audio('sounds/explode.ogg');
|
| 2168 |
+
impactSound.volume = 0.4;
|
| 2169 |
+
impactSound.play().catch(e => {});
|
| 2170 |
+
} catch (e) {}
|
| 2171 |
+
}
|
| 2172 |
+
|
| 2173 |
checkCollisions() {
|
| 2174 |
// ํ๋ ์ด์ด ํํ vs ์ ๊ธฐ ์ถฉ๋
|
| 2175 |
for (let i = this.fighter.bullets.length - 1; i >= 0; i--) {
|
|
|
|
| 2377 |
|
| 2378 |
this.fighter.updateControls(this.keys, deltaTime);
|
| 2379 |
this.fighter.updatePhysics(deltaTime);
|
| 2380 |
+
this.fighter.updateBullets(this.scene, deltaTime, this); // this ์ถ๊ฐ
|
| 2381 |
|
| 2382 |
// ๋ง์ฐ์ค ๋๋ฆ ์ํ์ผ ๋ ์ฐ์ ๋ฐ์ฌ
|
| 2383 |
if (this.fighter.isMouseDown && this.isStarted) {
|