• they/them

i am into accessibility and game design. i go by sysopod on other platforms as well


posts from @silasoftrees tagged #wasm

also:

good news! i've figured out how to write wasm with rust and get it running in the browser, and i've got it playing nice with the html in the browser. neat!

bad news! wasm written in this way appears to be hugely bloated for a variety of reasons, and now i have to either figure out how to optimize, figure out how to do everything on a very low level- possibly both. suddenly i've got to pay a memory cost of many kb to send the word "pants" from js to wasm.

i guess it's not impossible to write all the game logic in my rust code to only use data types that map to wasm's data types, but it will be significantly less human readable. maybe the solution here is to write one version in a human readable format and then write some other program to pack that into wasm-friendly rust, but then i need to make sure that gets synchronized with the js and at that point i'm just recreating wasm-bindgen...



edit: thanks for the shares! i think i have figured out the way forward now

note up front for anyone who wants to give me advice (which i will appreciate!)- i am doing this as an exercise to learn how to use rust and web assembly (wasm), so any suggestions that it would be easier to just not use rust or wasm will not be viable, even if that is probably very accurate. just wanted to say that to save time and energy for any kind people offering their thoughts.

this is for the js13k submission i'm working on. i need to keep the current game state in memory (what floor the player is on, what items are haunted, how much progress has the player made, etc) and i need to do that while also taking input from the player via their interactions with the html.

i had previously created a demo of the game as a pure rust command line version. in that version of the game, this whole thing is handled by std::io::stdin and just passing around the game state as a struct in a loop in the main run() function. the problem is, i don't really know how to modify or recreate std::io::stdin to fit with taking input from html form data/JS functions through wasm, so i've been trying to just switch to passing the game state as an object to the js/browser to keep in memory there and then throw it back to rust whenever i need to modify it/run some logic on it. that's a lot of work, wasm_bindgen is not exactly easy to make work with custom structs or even standard composite data types like vectors, and the whole endeavour is probably wasteful in terms of making me write redundant code when i really don't need to be using the game struct at all in the js- which should just be asking the rust code for the result of input taken from the html/user interactions.

i could go down the rabbit hole of trying to create a web worker to handle messaging between the rust code and the js, so it keeps the game state in memory and then modifies and renews it as needed...? but that also seems really janky. i'm kinda at a loss for what the correct direction is, here. rust/wasm seems to be pretty under supported, given the main tutorial in the book is flatly broken due to dependency issues and the community seems pretty fractured (this might be a misconception, i'm just going off what i can find online), so it's not like i can find a ton of support or wealth of historical solutions to this stuff like i can with most other languages.



silasoftrees
@silasoftrees

development on my js13k entry is beginning in earnest now. as usual, i'm working with my partner @eladnarra. kinda excited since the horror angle on the theme is fun.

currently thinking about making a sort of "spot the difference" game where you have to traverse from level 13 down to level 1 to escape, and if you mess up at some point during the 13 levels you get reset back to level 13. taking inspiration from Exit 8 and I'm on Observation Duty


silasoftrees
@silasoftrees

i have started writing a fair amount of the logic for the game in rust since i can use that to make web assembly (wasm) to run alongside the js, which means i've had to learn how rust works. it's only sort of a struggle 😅

so far i've made a command line version of just one floor of the game, which is fairly bare bones; you get a little description of where you are, what items are around you, and what commands you can enter to either inspect an item or attempt to leave the floor. once you finish your inspection of an item, you are prompted to enter an assessment of either "normal" or "haunted" based on what you observe about that item. attempting to leave either gives you a "win" description of leaving the building if you've made correct assessments and identified the haunted object(s), or a "lose" description of walking down the stairs to end up back at the 13th floor if you've made an incorrect assessment.

i suppose it's time to hook this up to the js and get it running in a browser before i start further iteration...