From ee4ead95430b57e1c8d4d699b20b4d40bcd3269f Mon Sep 17 00:00:00 2001 From: bye <bye@byecorps.com> Date: Wed, 14 Aug 2024 09:55:08 +0100 Subject: [PATCH] basic setup --- index.html | 8 ++++++++ src/main.js | 22 ++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 index.html create mode 100644 src/main.js diff --git a/index.html b/index.html new file mode 100644 index 0000000..c4cd701 --- /dev/null +++ b/index.html @@ -0,0 +1,8 @@ +<style> + canvas {width: 100vw; height: 100vh} + body {margin: 0} +</style> +<canvas id="canvas"> + This browser requires the <code><canvas></code> element to work +</canvas> +<script src="./src/main.js" type="module"></script> \ No newline at end of file diff --git a/src/main.js b/src/main.js new file mode 100644 index 0000000..15cd173 --- /dev/null +++ b/src/main.js @@ -0,0 +1,22 @@ + +import Canvas from "../hampsterengine/src/canvas.js"; +import Engine from "../hampsterengine/src/engine.js"; + +const canvas = new Canvas('canvas'); +const engine = new Engine(canvas); + +function main() { + requestAnimationFrame(main); + canvas.updateCanvasSize(); +} + +function load() { + if (engine.loading) { + engine.loadLoop(); + setTimeout(load, 1000/60); + } else { + main(); + } +} + +load(); -- GitLab