Update game.js
Browse files
game.js
CHANGED
|
@@ -1884,62 +1884,46 @@ class Game {
|
|
| 1884 |
});
|
| 1885 |
}
|
| 1886 |
|
| 1887 |
-
// μλ‘μ΄ λ©μλ:
|
| 1888 |
createGroundImpactEffect(position) {
|
| 1889 |
-
//
|
| 1890 |
-
const flashGeometry = new THREE.SphereGeometry(
|
| 1891 |
const flashMaterial = new THREE.MeshBasicMaterial({
|
| 1892 |
color: 0xffaa00,
|
| 1893 |
emissive: 0xffaa00,
|
| 1894 |
-
emissiveIntensity:
|
| 1895 |
transparent: true,
|
| 1896 |
-
opacity:
|
| 1897 |
});
|
| 1898 |
|
| 1899 |
const flash = new THREE.Mesh(flashGeometry, flashMaterial);
|
| 1900 |
flash.position.copy(position);
|
| 1901 |
-
flash.position.y =
|
| 1902 |
this.scene.add(flash);
|
| 1903 |
|
| 1904 |
-
//
|
| 1905 |
-
const
|
| 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(
|
| 1927 |
const particleMaterial = new THREE.MeshBasicMaterial({
|
| 1928 |
-
color: Math.random() > 0.
|
| 1929 |
emissive: 0xffaa00,
|
| 1930 |
-
emissiveIntensity:
|
| 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 =
|
| 1938 |
|
| 1939 |
-
//
|
| 1940 |
const angle = Math.random() * Math.PI * 2;
|
| 1941 |
-
const speed =
|
| 1942 |
-
const upSpeed =
|
| 1943 |
|
| 1944 |
particle.velocity = new THREE.Vector3(
|
| 1945 |
Math.cos(angle) * speed,
|
|
@@ -1947,225 +1931,134 @@ class Game {
|
|
| 1947 |
Math.sin(angle) * speed
|
| 1948 |
);
|
| 1949 |
|
| 1950 |
-
particle.life =
|
| 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
|
| 2004 |
-
const
|
| 2005 |
|
| 2006 |
-
for (let i = 0; i <
|
| 2007 |
-
const
|
| 2008 |
-
const
|
| 2009 |
-
color:
|
| 2010 |
transparent: true,
|
| 2011 |
-
opacity: 0.
|
| 2012 |
});
|
| 2013 |
|
| 2014 |
-
const
|
| 2015 |
-
|
| 2016 |
-
|
| 2017 |
-
|
| 2018 |
-
|
| 2019 |
|
| 2020 |
-
|
| 2021 |
-
(Math.random() - 0.5) *
|
| 2022 |
-
|
| 2023 |
-
(Math.random() - 0.5) *
|
| 2024 |
);
|
| 2025 |
|
| 2026 |
-
|
| 2027 |
|
| 2028 |
-
this.scene.add(
|
| 2029 |
-
|
| 2030 |
}
|
| 2031 |
|
| 2032 |
-
//
|
| 2033 |
-
const
|
| 2034 |
-
const
|
| 2035 |
-
color:
|
| 2036 |
side: THREE.DoubleSide,
|
| 2037 |
transparent: true,
|
| 2038 |
-
opacity: 0.
|
| 2039 |
});
|
| 2040 |
|
| 2041 |
-
const
|
| 2042 |
-
|
| 2043 |
-
|
| 2044 |
-
|
| 2045 |
-
this.scene.add(
|
| 2046 |
|
| 2047 |
// μ λλ©μ΄μ
|
| 2048 |
-
const
|
| 2049 |
let allDead = true;
|
| 2050 |
|
| 2051 |
-
//
|
| 2052 |
if (flash.material.opacity > 0) {
|
| 2053 |
-
flash.material.opacity -= 0.
|
| 2054 |
-
flash.scale.multiplyScalar(1.
|
| 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(
|
| 2072 |
if (particle.life > 0) {
|
| 2073 |
allDead = false;
|
| 2074 |
-
particle.life -= 0.
|
| 2075 |
|
| 2076 |
// μμΉ μ
λ°μ΄νΈ
|
| 2077 |
-
particle.position.add(particle.velocity.clone().multiplyScalar(0.
|
| 2078 |
|
| 2079 |
// μ€λ ₯
|
| 2080 |
-
particle.velocity.y -=
|
| 2081 |
-
|
| 2082 |
-
// 곡기 μ ν
|
| 2083 |
-
particle.velocity.multiplyScalar(0.98);
|
| 2084 |
|
| 2085 |
// νμ΄λ μμ
|
| 2086 |
-
particle.material.opacity = particle.life;
|
| 2087 |
|
| 2088 |
// ν¬κΈ° κ°μ
|
| 2089 |
-
const scale = particle.life *
|
| 2090 |
particle.scale.set(scale, scale, scale);
|
| 2091 |
} else if (particle.parent) {
|
| 2092 |
this.scene.remove(particle);
|
| 2093 |
}
|
| 2094 |
});
|
| 2095 |
|
| 2096 |
-
//
|
| 2097 |
-
|
| 2098 |
-
if (
|
| 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 |
-
|
| 2133 |
|
| 2134 |
// μμΉ μ
λ°μ΄νΈ
|
| 2135 |
-
|
| 2136 |
|
| 2137 |
-
// μμΉ
|
| 2138 |
-
|
| 2139 |
|
| 2140 |
// νμ°
|
| 2141 |
-
|
| 2142 |
|
| 2143 |
// νμ΄λ μμ
|
| 2144 |
-
|
| 2145 |
-
} else if (
|
| 2146 |
-
this.scene.remove(
|
| 2147 |
}
|
| 2148 |
});
|
| 2149 |
|
| 2150 |
-
//
|
| 2151 |
-
if (
|
| 2152 |
-
|
| 2153 |
allDead = false;
|
| 2154 |
-
} else if (
|
| 2155 |
-
this.scene.remove(
|
| 2156 |
}
|
| 2157 |
|
| 2158 |
if (!allDead) {
|
| 2159 |
-
requestAnimationFrame(
|
| 2160 |
}
|
| 2161 |
};
|
| 2162 |
|
| 2163 |
-
|
| 2164 |
|
| 2165 |
-
//
|
| 2166 |
try {
|
| 2167 |
-
const impactSound = new Audio('sounds/
|
| 2168 |
-
impactSound.volume = 0.
|
| 2169 |
impactSound.play().catch(e => {});
|
| 2170 |
} catch (e) {}
|
| 2171 |
}
|
|
@@ -2181,15 +2074,16 @@ class Game {
|
|
| 2181 |
|
| 2182 |
const distance = bullet.position.distanceTo(enemy.position);
|
| 2183 |
if (distance < 90) { // 60μμ 90μΌλ‘ μ¦κ° (100% νλ)
|
| 2184 |
-
this.scene.remove(bullet);
|
| 2185 |
-
this.fighter.bullets.splice(i, 1);
|
| 2186 |
-
|
| 2187 |
// ννΈ νμ μΆκ°
|
| 2188 |
this.showHitMarker(enemy.position);
|
| 2189 |
// νΌκ²© μ΄ννΈ μΆκ°
|
| 2190 |
this.createHitEffect(enemy.position);
|
| 2191 |
|
| 2192 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2193 |
enemy.destroy();
|
| 2194 |
this.enemies.splice(j, 1);
|
| 2195 |
this.score += 100;
|
|
@@ -2201,20 +2095,22 @@ class Game {
|
|
| 2201 |
|
| 2202 |
// μ νν vs νλ μ΄μ΄ μΆ©λ
|
| 2203 |
this.enemies.forEach(enemy => {
|
| 2204 |
-
enemy.bullets.
|
|
|
|
| 2205 |
const distance = bullet.position.distanceTo(this.fighter.position);
|
| 2206 |
if (distance < 100) { // 65μμ 100μΌλ‘ μ¦κ° (100% νλ)
|
| 2207 |
-
this.scene.remove(bullet);
|
| 2208 |
-
enemy.bullets.splice(index, 1);
|
| 2209 |
-
|
| 2210 |
// νλ μ΄μ΄ νΌκ²© μ΄ννΈ
|
| 2211 |
this.createHitEffect(this.fighter.position);
|
| 2212 |
|
| 2213 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2214 |
this.endGame(false);
|
| 2215 |
}
|
| 2216 |
}
|
| 2217 |
-
}
|
| 2218 |
});
|
| 2219 |
}
|
| 2220 |
|
|
|
|
| 1884 |
});
|
| 1885 |
}
|
| 1886 |
|
| 1887 |
+
// μλ‘μ΄ λ©μλ: νν ν¬κΈ°μ μ§λ©΄ μΆ©λ ν¨κ³Ό
|
| 1888 |
createGroundImpactEffect(position) {
|
| 1889 |
+
// μμ νλμ
|
| 1890 |
+
const flashGeometry = new THREE.SphereGeometry(3, 8, 8);
|
| 1891 |
const flashMaterial = new THREE.MeshBasicMaterial({
|
| 1892 |
color: 0xffaa00,
|
| 1893 |
emissive: 0xffaa00,
|
| 1894 |
+
emissiveIntensity: 2.0,
|
| 1895 |
transparent: true,
|
| 1896 |
+
opacity: 0.8
|
| 1897 |
});
|
| 1898 |
|
| 1899 |
const flash = new THREE.Mesh(flashGeometry, flashMaterial);
|
| 1900 |
flash.position.copy(position);
|
| 1901 |
+
flash.position.y = 0.5;
|
| 1902 |
this.scene.add(flash);
|
| 1903 |
|
| 1904 |
+
// μμ ννΈ νν°ν΄
|
| 1905 |
+
const particleCount = 10;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1906 |
const particles = [];
|
|
|
|
| 1907 |
|
| 1908 |
for (let i = 0; i < particleCount; i++) {
|
| 1909 |
// λΆκ½ νν°ν΄
|
| 1910 |
+
const particleGeometry = new THREE.SphereGeometry(0.3 + Math.random() * 0.3, 4, 4);
|
| 1911 |
const particleMaterial = new THREE.MeshBasicMaterial({
|
| 1912 |
+
color: Math.random() > 0.5 ? 0xffaa00 : 0xff6600,
|
| 1913 |
emissive: 0xffaa00,
|
| 1914 |
+
emissiveIntensity: 1.5,
|
| 1915 |
transparent: true,
|
| 1916 |
opacity: 1.0
|
| 1917 |
});
|
| 1918 |
|
| 1919 |
const particle = new THREE.Mesh(particleGeometry, particleMaterial);
|
| 1920 |
particle.position.copy(position);
|
| 1921 |
+
particle.position.y = 0.2;
|
| 1922 |
|
| 1923 |
+
// μ λΉν μλ
|
| 1924 |
const angle = Math.random() * Math.PI * 2;
|
| 1925 |
+
const speed = 10 + Math.random() * 30;
|
| 1926 |
+
const upSpeed = 15 + Math.random() * 25;
|
| 1927 |
|
| 1928 |
particle.velocity = new THREE.Vector3(
|
| 1929 |
Math.cos(angle) * speed,
|
|
|
|
| 1931 |
Math.sin(angle) * speed
|
| 1932 |
);
|
| 1933 |
|
| 1934 |
+
particle.life = 0.5; // 0.5μ΄ μ§μ
|
| 1935 |
|
| 1936 |
this.scene.add(particle);
|
| 1937 |
particles.push(particle);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1938 |
}
|
| 1939 |
|
| 1940 |
+
// μμ λ¨Όμ§ ν¨κ³Ό
|
| 1941 |
+
const dustCount = 3;
|
| 1942 |
+
const dusts = [];
|
| 1943 |
|
| 1944 |
+
for (let i = 0; i < dustCount; i++) {
|
| 1945 |
+
const dustGeometry = new THREE.SphereGeometry(1 + Math.random() * 1, 6, 6);
|
| 1946 |
+
const dustMaterial = new THREE.MeshBasicMaterial({
|
| 1947 |
+
color: 0x8b7355,
|
| 1948 |
transparent: true,
|
| 1949 |
+
opacity: 0.4
|
| 1950 |
});
|
| 1951 |
|
| 1952 |
+
const dust = new THREE.Mesh(dustGeometry, dustMaterial);
|
| 1953 |
+
dust.position.copy(position);
|
| 1954 |
+
dust.position.y = 0.5;
|
| 1955 |
+
dust.position.x += (Math.random() - 0.5) * 2;
|
| 1956 |
+
dust.position.z += (Math.random() - 0.5) * 2;
|
| 1957 |
|
| 1958 |
+
dust.velocity = new THREE.Vector3(
|
| 1959 |
+
(Math.random() - 0.5) * 5,
|
| 1960 |
+
3 + Math.random() * 5,
|
| 1961 |
+
(Math.random() - 0.5) * 5
|
| 1962 |
);
|
| 1963 |
|
| 1964 |
+
dust.life = 0.8;
|
| 1965 |
|
| 1966 |
+
this.scene.add(dust);
|
| 1967 |
+
dusts.push(dust);
|
| 1968 |
}
|
| 1969 |
|
| 1970 |
+
// νμ°©μ λ§ν¬
|
| 1971 |
+
const impactGeometry = new THREE.RingGeometry(0.5, 2, 8);
|
| 1972 |
+
const impactMaterial = new THREE.MeshBasicMaterial({
|
| 1973 |
+
color: 0x333333,
|
| 1974 |
side: THREE.DoubleSide,
|
| 1975 |
transparent: true,
|
| 1976 |
+
opacity: 0.5
|
| 1977 |
});
|
| 1978 |
|
| 1979 |
+
const impact = new THREE.Mesh(impactGeometry, impactMaterial);
|
| 1980 |
+
impact.position.copy(position);
|
| 1981 |
+
impact.position.y = 0.05;
|
| 1982 |
+
impact.rotation.x = -Math.PI / 2;
|
| 1983 |
+
this.scene.add(impact);
|
| 1984 |
|
| 1985 |
// μ λλ©μ΄μ
|
| 1986 |
+
const animateImpact = () => {
|
| 1987 |
let allDead = true;
|
| 1988 |
|
| 1989 |
+
// νλμ
|
| 1990 |
if (flash.material.opacity > 0) {
|
| 1991 |
+
flash.material.opacity -= 0.08;
|
| 1992 |
+
flash.scale.multiplyScalar(1.1);
|
| 1993 |
allDead = false;
|
| 1994 |
} else if (flash.parent) {
|
| 1995 |
this.scene.remove(flash);
|
| 1996 |
}
|
| 1997 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1998 |
// νν°ν΄ μ
λ°μ΄νΈ
|
| 1999 |
+
particles.forEach(particle => {
|
| 2000 |
if (particle.life > 0) {
|
| 2001 |
allDead = false;
|
| 2002 |
+
particle.life -= 0.03;
|
| 2003 |
|
| 2004 |
// μμΉ μ
λ°μ΄νΈ
|
| 2005 |
+
particle.position.add(particle.velocity.clone().multiplyScalar(0.03));
|
| 2006 |
|
| 2007 |
// μ€λ ₯
|
| 2008 |
+
particle.velocity.y -= 2;
|
|
|
|
|
|
|
|
|
|
| 2009 |
|
| 2010 |
// νμ΄λ μμ
|
| 2011 |
+
particle.material.opacity = particle.life * 2;
|
| 2012 |
|
| 2013 |
// ν¬κΈ° κ°μ
|
| 2014 |
+
const scale = particle.life * 2;
|
| 2015 |
particle.scale.set(scale, scale, scale);
|
| 2016 |
} else if (particle.parent) {
|
| 2017 |
this.scene.remove(particle);
|
| 2018 |
}
|
| 2019 |
});
|
| 2020 |
|
| 2021 |
+
// λ¨Όμ§ μ
λ°μ΄νΈ
|
| 2022 |
+
dusts.forEach(dust => {
|
| 2023 |
+
if (dust.life > 0) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2024 |
allDead = false;
|
| 2025 |
+
dust.life -= 0.02;
|
| 2026 |
|
| 2027 |
// μμΉ μ
λ°μ΄νΈ
|
| 2028 |
+
dust.position.add(dust.velocity.clone().multiplyScalar(0.02));
|
| 2029 |
|
| 2030 |
+
// μμΉ κ°μ
|
| 2031 |
+
dust.velocity.y *= 0.95;
|
| 2032 |
|
| 2033 |
// νμ°
|
| 2034 |
+
dust.scale.multiplyScalar(1.03);
|
| 2035 |
|
| 2036 |
// νμ΄λ μμ
|
| 2037 |
+
dust.material.opacity = dust.life * 0.5;
|
| 2038 |
+
} else if (dust.parent) {
|
| 2039 |
+
this.scene.remove(dust);
|
| 2040 |
}
|
| 2041 |
});
|
| 2042 |
|
| 2043 |
+
// νμ°©μ νμ΄λ
|
| 2044 |
+
if (impact.material.opacity > 0) {
|
| 2045 |
+
impact.material.opacity -= 0.01;
|
| 2046 |
allDead = false;
|
| 2047 |
+
} else if (impact.parent) {
|
| 2048 |
+
this.scene.remove(impact);
|
| 2049 |
}
|
| 2050 |
|
| 2051 |
if (!allDead) {
|
| 2052 |
+
requestAnimationFrame(animateImpact);
|
| 2053 |
}
|
| 2054 |
};
|
| 2055 |
|
| 2056 |
+
animateImpact();
|
| 2057 |
|
| 2058 |
+
// μμ μΆ©λμ
|
| 2059 |
try {
|
| 2060 |
+
const impactSound = new Audio('sounds/hit.ogg');
|
| 2061 |
+
impactSound.volume = 0.2;
|
| 2062 |
impactSound.play().catch(e => {});
|
| 2063 |
} catch (e) {}
|
| 2064 |
}
|
|
|
|
| 2074 |
|
| 2075 |
const distance = bullet.position.distanceTo(enemy.position);
|
| 2076 |
if (distance < 90) { // 60μμ 90μΌλ‘ μ¦κ° (100% νλ)
|
|
|
|
|
|
|
|
|
|
| 2077 |
// ννΈ νμ μΆκ°
|
| 2078 |
this.showHitMarker(enemy.position);
|
| 2079 |
// νΌκ²© μ΄ννΈ μΆκ°
|
| 2080 |
this.createHitEffect(enemy.position);
|
| 2081 |
|
| 2082 |
+
// νν μ κ±°λ μ΄ννΈ μμ± νμ
|
| 2083 |
+
this.scene.remove(bullet);
|
| 2084 |
+
this.fighter.bullets.splice(i, 1);
|
| 2085 |
+
|
| 2086 |
+
if (enemy.takeDamage(GAME_CONSTANTS.BULLET_DAMAGE)) { // 50 λ°λ―Έμ§
|
| 2087 |
enemy.destroy();
|
| 2088 |
this.enemies.splice(j, 1);
|
| 2089 |
this.score += 100;
|
|
|
|
| 2095 |
|
| 2096 |
// μ νν vs νλ μ΄μ΄ μΆ©λ
|
| 2097 |
this.enemies.forEach(enemy => {
|
| 2098 |
+
for (let index = enemy.bullets.length - 1; index >= 0; index--) {
|
| 2099 |
+
const bullet = enemy.bullets[index];
|
| 2100 |
const distance = bullet.position.distanceTo(this.fighter.position);
|
| 2101 |
if (distance < 100) { // 65μμ 100μΌλ‘ μ¦κ° (100% νλ)
|
|
|
|
|
|
|
|
|
|
| 2102 |
// νλ μ΄μ΄ νΌκ²© μ΄ννΈ
|
| 2103 |
this.createHitEffect(this.fighter.position);
|
| 2104 |
|
| 2105 |
+
// νν μ κ±°
|
| 2106 |
+
this.scene.remove(bullet);
|
| 2107 |
+
enemy.bullets.splice(index, 1);
|
| 2108 |
+
|
| 2109 |
+
if (this.fighter.takeDamage(GAME_CONSTANTS.BULLET_DAMAGE)) { // 50 λ°λ―Έμ§
|
| 2110 |
this.endGame(false);
|
| 2111 |
}
|
| 2112 |
}
|
| 2113 |
+
}
|
| 2114 |
});
|
| 2115 |
}
|
| 2116 |
|