mirror of
https://github.com/google/comprehensive-rust.git
synced 2025-05-22 18:30:33 +02:00
Fix GOL setup
This commit is contained in:
parent
62200ff61d
commit
59fa8ccc4a
@ -23,14 +23,9 @@ extern "C" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[wasm_bindgen]
|
#[wasm_bindgen]
|
||||||
pub fn set_panic_hook() {
|
pub fn setup() {
|
||||||
console_error_panic_hook::set_once();
|
console_error_panic_hook::set_once();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[wasm_bindgen]
|
|
||||||
pub fn start(canvas: HtmlCanvasElement, width: i32, height: i32) -> Result<(), JsValue> {
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
1. Let's create a `GameOfLife` struct that segments the canvas into cells of dimensions `10x10` pixels. Cells can be
|
1. Let's create a `GameOfLife` struct that segments the canvas into cells of dimensions `10x10` pixels. Cells can be
|
||||||
|
@ -0,0 +1,11 @@
|
|||||||
|
import init, {setup} from '/wasm/project.js';
|
||||||
|
|
||||||
|
|
||||||
|
(async () => {
|
||||||
|
// Run the init method to initiate the WebAssembly module.
|
||||||
|
await init();
|
||||||
|
setup();
|
||||||
|
const canvas = document.getElementById('game-of-life-canvas');
|
||||||
|
const ctx = canvas.getContext('2d');
|
||||||
|
const game = new GameOfLife(ctx, canvas.width, canvas.height);
|
||||||
|
})();
|
Loading…
x
Reference in New Issue
Block a user