display the game
This commit is contained in:
parent
2d8753141c
commit
bef70f4482
2 changed files with 25 additions and 3 deletions
15
index.html
15
index.html
|
@ -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>
|
||||||
|
|
13
index.js
13
index.js
|
@ -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);
|
||||||
|
|
Loading…
Reference in a new issue