cutechicken commited on
Commit
8cc3811
β€’
1 Parent(s): 26bd7d5

Update game.js

Browse files
Files changed (1) hide show
  1. game.js +37 -35
game.js CHANGED
@@ -1858,45 +1858,47 @@ this.enemies.forEach(enemy => {
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
- 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
- this.updateParticles();
1893
- this.checkCollisions();
1894
- this.updateUI();
1895
- this.updateRadar(); // λ ˆμ΄λ” μ—…λ°μ΄νŠΈ μΆ”κ°€
1896
- }
1897
-
1898
- this.renderer.render(this.scene, this.camera);
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