Spaces:
Running
Running
Update game.js
Browse files
game.js
CHANGED
|
@@ -569,7 +569,7 @@ startReload() {
|
|
| 569 |
}
|
| 570 |
|
| 571 |
updateAmmoDisplay() {
|
| 572 |
-
document.getElementById('ammoDisplay').textContent =
|
| 573 |
}
|
| 574 |
}
|
| 575 |
|
|
@@ -1749,8 +1749,8 @@ class Game {
|
|
| 1749 |
// 적 도트 생성 및 추가
|
| 1750 |
const dot = document.createElement('div');
|
| 1751 |
dot.className = 'enemy-dot';
|
| 1752 |
-
dot.style.left =
|
| 1753 |
-
dot.style.top =
|
| 1754 |
radar.appendChild(dot);
|
| 1755 |
}
|
| 1756 |
});
|
|
@@ -2141,11 +2141,11 @@ class Game {
|
|
| 2141 |
this.isLoading = false;
|
| 2142 |
const loadingElement = document.getElementById('loading');
|
| 2143 |
if (loadingElement) {
|
| 2144 |
-
loadingElement.innerHTML =
|
| 2145 |
<div class="loading-text" style="color: red;">
|
| 2146 |
Loading failed. Please refresh the page.
|
| 2147 |
</div>
|
| 2148 |
-
|
| 2149 |
}
|
| 2150 |
}
|
| 2151 |
|
|
@@ -2161,7 +2161,7 @@ class Game {
|
|
| 2161 |
}
|
| 2162 |
|
| 2163 |
this.gameTime--;
|
| 2164 |
-
document.getElementById('time').textContent =
|
| 2165 |
|
| 2166 |
if (this.gameTime <= 0) {
|
| 2167 |
clearInterval(this.gameTimer);
|
|
@@ -2340,7 +2340,7 @@ class Game {
|
|
| 2340 |
enemy.bullets.splice(bulletIndex, 1);
|
| 2341 |
|
| 2342 |
document.getElementById('health').style.width =
|
| 2343 |
-
|
| 2344 |
}
|
| 2345 |
});
|
| 2346 |
});
|
|
@@ -2389,7 +2389,7 @@ this.enemies.forEach(enemy => {
|
|
| 2389 |
enemy.bullets.splice(bulletIndex, 1);
|
| 2390 |
|
| 2391 |
document.getElementById('health').style.width =
|
| 2392 |
-
|
| 2393 |
}
|
| 2394 |
});
|
| 2395 |
});
|
|
@@ -2422,7 +2422,7 @@ this.enemies.forEach(enemy => {
|
|
| 2422 |
enemy.destroy();
|
| 2423 |
this.enemies.splice(j, 1);
|
| 2424 |
this.score += 100;
|
| 2425 |
-
document.getElementById('score').textContent =
|
| 2426 |
}
|
| 2427 |
|
| 2428 |
this.tank.createExplosionEffect(this.scene, bullet.position);
|
|
@@ -2500,7 +2500,7 @@ this.enemies.forEach(enemy => {
|
|
| 2500 |
gameOverDiv.style.padding = '20px';
|
| 2501 |
gameOverDiv.style.borderRadius = '10px';
|
| 2502 |
gameOverDiv.style.textAlign = 'center';
|
| 2503 |
-
gameOverDiv.innerHTML =
|
| 2504 |
${isVictory ? 'Victory!' : 'Game Over'}<br>
|
| 2505 |
Score: ${this.score}<br>
|
| 2506 |
Time Survived: ${GAME_DURATION - this.gameTime}s<br>
|
|
@@ -2510,7 +2510,7 @@ this.enemies.forEach(enemy => {
|
|
| 2510 |
color: black; border-radius: 5px;">
|
| 2511 |
Play Again
|
| 2512 |
</button>
|
| 2513 |
-
|
| 2514 |
document.body.appendChild(gameOverDiv);
|
| 2515 |
}
|
| 2516 |
|
|
@@ -2519,17 +2519,17 @@ this.enemies.forEach(enemy => {
|
|
| 2519 |
if (!this.isGameOver) {
|
| 2520 |
const healthBar = document.getElementById('health');
|
| 2521 |
if (healthBar) {
|
| 2522 |
-
healthBar.style.width =
|
| 2523 |
}
|
| 2524 |
|
| 2525 |
const timeElement = document.getElementById('time');
|
| 2526 |
if (timeElement) {
|
| 2527 |
-
timeElement.textContent =
|
| 2528 |
}
|
| 2529 |
|
| 2530 |
const scoreElement = document.getElementById('score');
|
| 2531 |
if (scoreElement) {
|
| 2532 |
-
scoreElement.textContent =
|
| 2533 |
}
|
| 2534 |
}
|
| 2535 |
}
|
|
@@ -2587,8 +2587,8 @@ updateCrosshair() {
|
|
| 2587 |
const label = document.createElement('div');
|
| 2588 |
label.className = 'enemy-label';
|
| 2589 |
label.textContent = 'T-90';
|
| 2590 |
-
label.style.left =
|
| 2591 |
-
label.style.top =
|
| 2592 |
|
| 2593 |
// 거리에 따른 투명도 조정
|
| 2594 |
const opacity = Math.max(0.2, 1 - (distance / this.radarRange));
|
|
|
|
| 569 |
}
|
| 570 |
|
| 571 |
updateAmmoDisplay() {
|
| 572 |
+
document.getElementById('ammoDisplay').textContent = APFSDS: ${this.ammo}/${this.maxAmmo};
|
| 573 |
}
|
| 574 |
}
|
| 575 |
|
|
|
|
| 1749 |
// 적 도트 생성 및 추가
|
| 1750 |
const dot = document.createElement('div');
|
| 1751 |
dot.className = 'enemy-dot';
|
| 1752 |
+
dot.style.left = ${dotX}px;
|
| 1753 |
+
dot.style.top = ${dotY}px;
|
| 1754 |
radar.appendChild(dot);
|
| 1755 |
}
|
| 1756 |
});
|
|
|
|
| 2141 |
this.isLoading = false;
|
| 2142 |
const loadingElement = document.getElementById('loading');
|
| 2143 |
if (loadingElement) {
|
| 2144 |
+
loadingElement.innerHTML =
|
| 2145 |
<div class="loading-text" style="color: red;">
|
| 2146 |
Loading failed. Please refresh the page.
|
| 2147 |
</div>
|
| 2148 |
+
;
|
| 2149 |
}
|
| 2150 |
}
|
| 2151 |
|
|
|
|
| 2161 |
}
|
| 2162 |
|
| 2163 |
this.gameTime--;
|
| 2164 |
+
document.getElementById('time').textContent = Time: ${this.gameTime}s;
|
| 2165 |
|
| 2166 |
if (this.gameTime <= 0) {
|
| 2167 |
clearInterval(this.gameTimer);
|
|
|
|
| 2340 |
enemy.bullets.splice(bulletIndex, 1);
|
| 2341 |
|
| 2342 |
document.getElementById('health').style.width =
|
| 2343 |
+
${(this.tank.health / MAX_HEALTH) * 100}%;
|
| 2344 |
}
|
| 2345 |
});
|
| 2346 |
});
|
|
|
|
| 2389 |
enemy.bullets.splice(bulletIndex, 1);
|
| 2390 |
|
| 2391 |
document.getElementById('health').style.width =
|
| 2392 |
+
${(this.tank.health / MAX_HEALTH) * 100}%;
|
| 2393 |
}
|
| 2394 |
});
|
| 2395 |
});
|
|
|
|
| 2422 |
enemy.destroy();
|
| 2423 |
this.enemies.splice(j, 1);
|
| 2424 |
this.score += 100;
|
| 2425 |
+
document.getElementById('score').textContent = Score: ${this.score};
|
| 2426 |
}
|
| 2427 |
|
| 2428 |
this.tank.createExplosionEffect(this.scene, bullet.position);
|
|
|
|
| 2500 |
gameOverDiv.style.padding = '20px';
|
| 2501 |
gameOverDiv.style.borderRadius = '10px';
|
| 2502 |
gameOverDiv.style.textAlign = 'center';
|
| 2503 |
+
gameOverDiv.innerHTML =
|
| 2504 |
${isVictory ? 'Victory!' : 'Game Over'}<br>
|
| 2505 |
Score: ${this.score}<br>
|
| 2506 |
Time Survived: ${GAME_DURATION - this.gameTime}s<br>
|
|
|
|
| 2510 |
color: black; border-radius: 5px;">
|
| 2511 |
Play Again
|
| 2512 |
</button>
|
| 2513 |
+
;
|
| 2514 |
document.body.appendChild(gameOverDiv);
|
| 2515 |
}
|
| 2516 |
|
|
|
|
| 2519 |
if (!this.isGameOver) {
|
| 2520 |
const healthBar = document.getElementById('health');
|
| 2521 |
if (healthBar) {
|
| 2522 |
+
healthBar.style.width = ${(this.tank.health / MAX_HEALTH) * 100}%;
|
| 2523 |
}
|
| 2524 |
|
| 2525 |
const timeElement = document.getElementById('time');
|
| 2526 |
if (timeElement) {
|
| 2527 |
+
timeElement.textContent = Time: ${this.gameTime}s;
|
| 2528 |
}
|
| 2529 |
|
| 2530 |
const scoreElement = document.getElementById('score');
|
| 2531 |
if (scoreElement) {
|
| 2532 |
+
scoreElement.textContent = Score: ${this.score};
|
| 2533 |
}
|
| 2534 |
}
|
| 2535 |
}
|
|
|
|
| 2587 |
const label = document.createElement('div');
|
| 2588 |
label.className = 'enemy-label';
|
| 2589 |
label.textContent = 'T-90';
|
| 2590 |
+
label.style.left = ${x}px;
|
| 2591 |
+
label.style.top = ${y}px;
|
| 2592 |
|
| 2593 |
// 거리에 따른 투명도 조정
|
| 2594 |
const opacity = Math.max(0.2, 1 - (distance / this.radarRange));
|