You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

45 lines
792 B

import { Time } from "./Time.js";
import { init_game_state } from "./game.js";
/**
* @typedef {import('./game.js').GameState} GameState
*/
/** @type {GameState} */
let game_state = init_game_state();
let time = new Time(game_state);
/** @type {number} */
let last = performance.now();
/**
* Main game loop - runs every frame
* @param {number} now - Current timestamp from requestAnimationFrame
*/
function loop(now) {
const dt = now - last;
last = now;
update(dt);
render();
requestAnimationFrame(loop);
}
/**
* Updates game state based on elapsed time
* @param {number} dt - Delta time in milliseconds
*/
function update(dt) {
time.update(dt);
}
/**
* Renders the current game state
*/
function render() {
//render stuff here
}
requestAnimationFrame(loop);