Created
July 30, 2020 17:21
-
-
Save randomPoison/2cf4d81efa9c444801fe4912e46d5a71 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[wasm_bindgen] | |
pub struct MyEmulator { | |
// Put any state that needs to persist between frames. | |
} | |
#[wasm_bindgen] | |
impl MyEmulator { | |
#[wasm_bindgen(constructor)] | |
pub fn new() -> Self { | |
// ... | |
} | |
pub fn do_one_frame(&mut self) { | |
// Perform any necessary simulation for one frame. | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { MyEmulator } from './emulator'; | |
let emulator = new MyEmulator(); | |
function step(timestamp) { | |
emulator.do_one_frame(); | |
window.requestAnimationFrame(step); | |
} | |
window.requestAnimationFrame(step); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment