A very basicexample of a "game" that works both natively and in a browser using wasm. The idea is that you divide your game into the platform layer and the game layer. The game layer contains all logic and calls functions from the platform (like drawing, playing sounds etc). The platform layer is implemented for every supported platform, in the case of this example in raylib for dekstop and javascript for browser.
The "game" is written in odin, as such you need a working odin compiler.
Building the game on the desktop platform is quite straightforward, from within the project root directory run:
odin build .To run the "game" in the browser compile the game directory to wasm with the command:
odin build .\game -no-crt -no-entry-point -o:speed -target:js_wasm32Afterward you need to host an http server. The simplest way i know of is to use python's http.server module:
<path_to_interpreter> -m http.serverThe game should be hosted on http://localhost:8000.