Spaces:
Running
Running
cutechicken
commited on
Update index.html
Browse files- index.html +29 -6
index.html
CHANGED
@@ -194,6 +194,10 @@
|
|
194 |
const weaponInfo = document.getElementById('weaponInfo');
|
195 |
const countdownEl = document.getElementById('countdown');
|
196 |
const bossButton = document.getElementById('bossButton');
|
|
|
|
|
|
|
|
|
197 |
canvas.width = window.innerWidth;
|
198 |
canvas.height = window.innerHeight;
|
199 |
|
@@ -325,6 +329,13 @@
|
|
325 |
gameStarted = true;
|
326 |
initRound();
|
327 |
gameLoop();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
328 |
}
|
329 |
function startCountdown() {
|
330 |
isCountingDown = true;
|
@@ -1252,13 +1263,25 @@ function updateBF109Damage() {
|
|
1252 |
return true;
|
1253 |
});
|
1254 |
}
|
1255 |
-
function gameLoop() {
|
1256 |
-
|
1257 |
-
|
1258 |
-
|
1259 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1260 |
}
|
1261 |
-
}
|
1262 |
class Enemy {
|
1263 |
constructor(isBoss = false) {
|
1264 |
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 |
+
const FPS = 60; // λͺ©ν FPS
|
199 |
+
const frameDelay = 1000 / FPS; // νλ μλΉ μκ° (μ½ 16.67ms)
|
200 |
+
let lastFrameTime = 0; // λ§μ§λ§ νλ μμ μκ°μ μ μ₯
|
201 |
canvas.width = window.innerWidth;
|
202 |
canvas.height = window.innerHeight;
|
203 |
|
|
|
329 |
gameStarted = true;
|
330 |
initRound();
|
331 |
gameLoop();
|
332 |
+
|
333 |
+
// λ§μ§λ§ νλ μ μκ° μ΄κΈ°ν
|
334 |
+
lastFrameTime = performance.now();
|
335 |
+
// κ²μ 루ν μμ
|
336 |
+
gameStarted = true;
|
337 |
+
initRound();
|
338 |
+
requestAnimationFrame(gameLoop);
|
339 |
}
|
340 |
function startCountdown() {
|
341 |
isCountingDown = true;
|
|
|
1263 |
return true;
|
1264 |
});
|
1265 |
}
|
1266 |
+
function gameLoop(timestamp) {
|
1267 |
+
if (!gameOver && gameStarted) {
|
1268 |
+
// νμ¬ νλ μκ³Ό μ΄μ νλ μμ μκ° μ°¨μ΄ κ³μ°
|
1269 |
+
const elapsed = timestamp - lastFrameTime;
|
1270 |
+
|
1271 |
+
// frameDelay(16.67ms)λ³΄λ€ λ λ§μ μκ°μ΄ μ§λ¬λμ§ νμΈ
|
1272 |
+
if (elapsed > frameDelay) {
|
1273 |
+
// λ§μ§λ§ νλ μ μκ° μ
λ°μ΄νΈ
|
1274 |
+
lastFrameTime = timestamp - (elapsed % frameDelay);
|
1275 |
+
|
1276 |
+
// κ²μ μ
λ°μ΄νΈ λ° κ·Έλ¦¬κΈ°
|
1277 |
+
updateGame();
|
1278 |
+
drawGame();
|
1279 |
+
}
|
1280 |
+
|
1281 |
+
// λ€μ νλ μ μμ²
|
1282 |
+
requestAnimationFrame(gameLoop);
|
1283 |
+
}
|
1284 |
}
|
|
|
1285 |
class Enemy {
|
1286 |
constructor(isBoss = false) {
|
1287 |
this.x = Math.random() * canvas.width;
|