twiddlingbits / twr-wasm

twr-wasm: easily run C/C++ code in a web browser using Web Assembly, with examples
https://twiddlingbits.dev/
MIT License
17 stars 1 forks source link

add deeplinks? #49

Open twiddlingbits opened 6 days ago

twiddlingbits commented 6 days ago

I was thinking of posting a link to Pong to the discord wasm demos section. But i was thinking I would like to paste a link to the Pong 2 Player AI version (and skip the intro menu, when this demo link is used). For example, i sorted of wanted to select the 2 Player AI mode, than copy the link in the address bar (but of course the link didn't change when i selected the 2P AI menu). How would we do that in a general way? Is it just an app feature (you could easily add the code to your index.html to look at the #Pong2AI (like we do for #async sometimes). But is there a more generic feature?

It seems like it might be a feature of your button widget library.

Or, more generically, a feature of a UI library. For example, one might have "screens" that can be deep linked to. Or one might have various UI status adjust the URL in the title bar so that they contain all the state info in the link so that a copy/paste of the link can deep link to that state.

JohnDog3112 commented 5 days ago

I'm not fully sure how it could be made generic. As you said, one approach would be to just store all of the relevant variables as URL parameters, but I'm not quite sure how to allow the programmer to set those and load them generically other than setting up some list of pointers.

Alternatively, there could be "menus" or "scenes" in the widget library. Then each scene just needs a unique name and some mechanism for skipping to specific scenes. Maybe using some sort of event-based model? The init phase registers the objects in a scene, then events are called when things happen. That way the "root" can have a function called after the initial setup to move into the desired scene.

twiddlingbits commented 4 days ago

I'm not fully sure how it could be made generic.

Or a "state snapshot". I wouldn't stress over this. If we keep it in the back of our head, maybe something will come to light as we work though the API. Many (most) things take iteration and evolution to get good.