Spaces:
Running
Running
cutechicken
commited on
Commit
β’
8cc3811
1
Parent(s):
26bd7d5
Update game.js
Browse files
game.js
CHANGED
@@ -1858,45 +1858,47 @@ this.enemies.forEach(enemy => {
|
|
1858 |
}
|
1859 |
|
1860 |
animate() {
|
1861 |
-
|
1862 |
-
|
1863 |
-
|
1864 |
-
}
|
1865 |
-
return;
|
1866 |
-
}
|
1867 |
-
|
1868 |
-
this.animationFrameId = requestAnimationFrame(() => this.animate());
|
1869 |
-
// κ²μμ΄ μμλμ§ μμμΌλ©΄ λ λλ§λ§ μν
|
1870 |
-
if (!this.isStarted) {
|
1871 |
-
this.renderer.render(this.scene, this.camera);
|
1872 |
-
return;
|
1873 |
}
|
|
|
|
|
1874 |
|
1875 |
-
|
1876 |
-
|
1877 |
-
|
|
|
|
|
|
|
1878 |
|
1879 |
-
|
1880 |
-
|
1881 |
-
|
1882 |
-
|
1883 |
-
const tankPosition = this.tank.getPosition();
|
1884 |
-
this.enemies.forEach(enemy => {
|
1885 |
-
enemy.update(tankPosition);
|
1886 |
-
|
1887 |
-
if (enemy.isLoaded && enemy.mesh.position.distanceTo(tankPosition) < ENEMY_CONFIG.ATTACK_RANGE) {
|
1888 |
-
enemy.shoot(tankPosition);
|
1889 |
-
}
|
1890 |
-
});
|
1891 |
|
1892 |
-
|
1893 |
-
|
1894 |
-
|
1895 |
-
|
1896 |
-
|
1897 |
-
|
1898 |
-
|
1899 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1900 |
}
|
1901 |
|
1902 |
// Start game
|
|
|
1858 |
}
|
1859 |
|
1860 |
animate() {
|
1861 |
+
if (this.isGameOver) {
|
1862 |
+
if (this.animationFrameId) {
|
1863 |
+
cancelAnimationFrame(this.animationFrameId);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1864 |
}
|
1865 |
+
return;
|
1866 |
+
}
|
1867 |
|
1868 |
+
this.animationFrameId = requestAnimationFrame(() => this.animate());
|
1869 |
+
// κ²μμ΄ μμλμ§ μμμΌλ©΄ λ λλ§λ§ μν
|
1870 |
+
if (!this.isStarted) {
|
1871 |
+
this.renderer.render(this.scene, this.camera);
|
1872 |
+
return;
|
1873 |
+
}
|
1874 |
|
1875 |
+
const currentTime = performance.now();
|
1876 |
+
const deltaTime = (currentTime - this.lastTime) / 1000;
|
1877 |
+
this.lastTime = currentTime;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1878 |
|
1879 |
+
if (!this.isLoading) {
|
1880 |
+
this.handleMovement();
|
1881 |
+
this.tank.update(this.mouse.x, this.mouse.y, this.scene);
|
1882 |
+
|
1883 |
+
const tankPosition = this.tank.getPosition();
|
1884 |
+
this.enemies.forEach(enemy => {
|
1885 |
+
if (enemy.isLoaded && enemy.body) { // bodyμ μ‘΄μ¬ μ¬λΆ 체ν¬
|
1886 |
+
enemy.update(tankPosition);
|
1887 |
+
|
1888 |
+
// mesh λμ body μ¬μ©
|
1889 |
+
if (enemy.body.position.distanceTo(tankPosition) < ENEMY_CONFIG.ATTACK_RANGE) {
|
1890 |
+
enemy.shoot(tankPosition);
|
1891 |
+
}
|
1892 |
+
}
|
1893 |
+
});
|
1894 |
+
|
1895 |
+
this.updateParticles();
|
1896 |
+
this.checkCollisions();
|
1897 |
+
this.updateUI();
|
1898 |
+
this.updateRadar();
|
1899 |
+
}
|
1900 |
+
|
1901 |
+
this.renderer.render(this.scene, this.camera);
|
1902 |
}
|
1903 |
|
1904 |
// Start game
|