display the game

This commit is contained in:
histausse 2021-05-11 17:31:39 +02:00
parent 2d8753141c
commit bef70f4482
Signed by: histausse
GPG key ID: 67486F107F62E9E9
2 changed files with 25 additions and 3 deletions

View file

@ -3,9 +3,22 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Hello wasm-pack!</title> <title>Hello wasm-pack!</title>
<style>
body {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
</style>
</head> </head>
<body> <body>
<noscript>This page contains webassembly and javascript content, please enable javascript in your browser.</noscript> <pre id="game-of-life-canvas"></pre>
<script src="./bootstrap.js"></script> <script src="./bootstrap.js"></script>
</body> </body>
</html> </html>

View file

@ -1,3 +1,12 @@
import * as wasm from "wasm-game-of-life"; import { Universe } from "wasm-game-of-life";
wasm.greet("Histausse"); const pre = document.getElementById("game-of-life-canvas");
const universe = Universe.new();
const renderLoop = () => {
pre.textContent = universe.render();
universe.tick();
requestAnimationFrame(renderLoop);
};
requestAnimationFrame(renderLoop);