3 ms·
I was thinking you can create a byte buffer of fixed size instructions that you can pass from Rust to JavaScript. With for example DataView you can fairly easil
by blixt 9y ago
I was thinking you can create a byte buffer of fixed size instructions that you can pass from Rust to JavaScript. With for example DataView you can fairly easily inspect that data in JavaScript.
Or to keep things even simpler, if every class of draw instructions is always performed in order (so not drawEnemy, drawText, then another drawEnemy) you could just have separate arrays of arguments for every draw type.
Anyway for your game specifically I doubt this is even close to an issue, but I'm curious just how performance scales when you jump in and out of JS a lot in WASM.
- wofo 9y agoNever heard of DataView before, thanks! This is the first time I do something "low level" in Javascript, so there is probably a lot that could be improved. BTW, here is an example passing arrays between Javascript and Rust: https://www.hellorust.com/demos/canvas/index.html https://www.hellorust.com/demos/canvas/index.html