cutechicken commited on
Commit
ea91682
Β·
verified Β·
1 Parent(s): 404f86f

Update index.html

Browse files
Files changed (1) hide show
  1. 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
- if (!gameOver && gameStarted) {
1257
- updateGame();
1258
- drawGame();
1259
- requestAnimationFrame(gameLoop);
 
 
 
 
 
 
 
 
 
 
 
 
 
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;