added update loop and game state.

This commit is contained in:
2025-08-22 11:35:45 -05:00
parent 56c2a6440c
commit 6c7662b5e6
3 changed files with 192 additions and 67 deletions

View File

@@ -1,14 +1,33 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Rust WASM Game Window</title>
</head>
<body style="margin:0; background:#222; display:flex; justify-content:center; align-items:center; height:100vh;">
<canvas id="game-canvas"></canvas>
<script type="module">
import init from "./pkg/hyperbolic_asteroids.js";
init();
</script>
</body>
<head>
<meta charset="utf-8"/>
<title>Rust WASM Game Window</title>
</head>
<body style="margin:0; background:#222; display:flex; justify-content:center; align-items:center; height:100vh;">
<canvas id="game-canvas"></canvas>
<script type="module">
import init, { Game } from "./pkg/hyperbolic_asteroids.js";
async function run() {
await init();
let game = new Game("game-canvas");
let last = performance.now();
function loop(now) {
const dt = (now - last);
last = now;
game.update(dt);
game.draw();
requestAnimationFrame(loop);
}
//game.update(1);
requestAnimationFrame(loop);
}
run();
</script>
</body>
</html>