0.3.0-0-pre.4-fix.2

This commit is contained in:
2026-09-20 13:33:39 +02:00
parent f433e99a12
commit 023825b89b
7 changed files with 108 additions and 9 deletions

View File

@@ -1,5 +1,5 @@
// file: Web/game-snake-poc/frontend/ts/game.ts
// version: 1
// version: 2
import init, { SnakeWasmGame } from "@snake-wasm";
@@ -77,6 +77,7 @@ export async function startGame(
if (context === null) {
throw new Error("Le contexte Canvas 2D est indisponible.");
}
const renderingContext: CanvasRenderingContext2D = context;
const game = new SnakeWasmGame();
let previous = performance.now();
let accumulator = 0;
@@ -89,11 +90,11 @@ export async function startGame(
game.tick();
accumulator -= FRAME_MILLIS;
}
render(game, canvas, context, score, length);
render(game, canvas, renderingContext, score, length);
window.requestAnimationFrame(frame);
}
render(game, canvas, context, score, length);
render(game, canvas, renderingContext, score, length);
window.requestAnimationFrame(frame);
return {
queueDirection(direction: SnakeDirection): void {