chore: scaffold Dino Land with canvas base game loop

This commit is contained in:
OpenClaw Engineer
2026-03-03 20:39:07 -06:00
commit 93958c02a4
3 changed files with 110 additions and 0 deletions
+28
View File
@@ -0,0 +1,28 @@
const canvas = document.getElementById('game');
const ctx = canvas.getContext('2d');
const state = {
running: true,
lastTs: performance.now()
};
function drawBackground() {
ctx.fillStyle = '#88d34f';
ctx.fillRect(0, 420, canvas.width, 120);
}
function tick(ts) {
if (!state.running) return;
const dt = Math.min((ts - state.lastTs) / 1000, 0.05);
state.lastTs = ts;
ctx.clearRect(0, 0, canvas.width, canvas.height);
drawBackground();
requestAnimationFrame(tick);
}
requestAnimationFrame((ts) => {
state.lastTs = ts;
requestAnimationFrame(tick);
});