Spaces:
Running
Running
cutechicken
commited on
Update index.html
Browse files- index.html +33 -17
index.html
CHANGED
@@ -194,10 +194,11 @@
|
|
194 |
const weaponInfo = document.getElementById('weaponInfo');
|
195 |
const countdownEl = document.getElementById('countdown');
|
196 |
const bossButton = document.getElementById('bossButton');
|
197 |
-
//
|
198 |
-
|
199 |
-
const
|
200 |
-
|
|
|
201 |
canvas.width = window.innerWidth;
|
202 |
canvas.height = window.innerHeight;
|
203 |
|
@@ -1265,23 +1266,38 @@ function updateBF109Damage() {
|
|
1265 |
}
|
1266 |
function gameLoop(timestamp) {
|
1267 |
if (!gameOver && gameStarted) {
|
1268 |
-
|
1269 |
-
|
1270 |
-
|
1271 |
-
|
1272 |
-
|
1273 |
-
|
1274 |
-
|
1275 |
-
|
1276 |
-
|
1277 |
-
|
1278 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1279 |
}
|
1280 |
|
1281 |
-
//
|
1282 |
-
|
|
|
|
|
|
|
1283 |
}
|
|
|
|
|
|
|
1284 |
}
|
|
|
1285 |
class Enemy {
|
1286 |
constructor(isBoss = false) {
|
1287 |
this.x = Math.random() * canvas.width;
|
|
|
194 |
const weaponInfo = document.getElementById('weaponInfo');
|
195 |
const countdownEl = document.getElementById('countdown');
|
196 |
const bossButton = document.getElementById('bossButton');
|
197 |
+
// κ²μμ κΈ°λ³Έ μν λ³μλ€ κ·Όμ²μ μΆκ°
|
198 |
+
let lastFrameTime = 0; // λ§μ§λ§ νλ μμ΄ μ€νλ μκ°
|
199 |
+
const FPS = 60; // λͺ©ν FPS
|
200 |
+
const frameDelay = 1000 / FPS; // νλ μ μ¬μ΄μ κ°κ²© (16.67ms)
|
201 |
+
let deltaTime = 0; // νλ μ κ°μ μκ° μ°¨μ΄
|
202 |
canvas.width = window.innerWidth;
|
203 |
canvas.height = window.innerHeight;
|
204 |
|
|
|
1266 |
}
|
1267 |
function gameLoop(timestamp) {
|
1268 |
if (!gameOver && gameStarted) {
|
1269 |
+
// 첫 νλ μμΌ κ²½μ° μκ° μ΄κΈ°ν
|
1270 |
+
if (!lastFrameTime) {
|
1271 |
+
lastFrameTime = timestamp;
|
1272 |
+
}
|
1273 |
+
|
1274 |
+
// νμ¬ νλ μκ³Ό μ΄μ νλ μμ μκ° μ°¨μ΄ κ³μ°
|
1275 |
+
deltaTime = timestamp - lastFrameTime;
|
1276 |
+
|
1277 |
+
// 16.67ms(60FPS)κ° μ§λ¬λμ§ νμΈ
|
1278 |
+
if (deltaTime >= frameDelay) {
|
1279 |
+
// μ
λ°μ΄νΈν νλ μ μ κ³μ°
|
1280 |
+
const numUpdates = Math.floor(deltaTime / frameDelay);
|
1281 |
+
|
1282 |
+
// νλ²μ λ무 λ§μ μ
λ°μ΄νΈ λ°©μ§ (μ΅λ 3νλ μ)
|
1283 |
+
const maxUpdates = 3;
|
1284 |
+
|
1285 |
+
// κ²μ μν μ
λ°μ΄νΈ
|
1286 |
+
for (let i = 0; i < Math.min(numUpdates, maxUpdates); i++) {
|
1287 |
+
updateGame(frameDelay / 1000);
|
1288 |
}
|
1289 |
|
1290 |
+
// νλ©΄ 그리기
|
1291 |
+
drawGame();
|
1292 |
+
|
1293 |
+
// λ§μ§λ§ νλ μ μκ° μ
λ°μ΄νΈ
|
1294 |
+
lastFrameTime = timestamp - (deltaTime % frameDelay);
|
1295 |
}
|
1296 |
+
|
1297 |
+
// λ€μ νλ μ μμ²
|
1298 |
+
requestAnimationFrame(gameLoop);
|
1299 |
}
|
1300 |
+
}
|
1301 |
class Enemy {
|
1302 |
constructor(isBoss = false) {
|
1303 |
this.x = Math.random() * canvas.width;
|