From bare metals to web. A rough road.
My game is now available to play in bs-odin.onkush.dev
I built my application for the Web and it works. Probably the most dirty work I had to do in this project overall. I probably have read all available Odin/WASM templates.
Setting the Sail
I knew what WASM is, I once to compile one of my C++ games to WASM too, but seeing more than 500+ errors in the first try took a big toll on me and I didn’t bother. I don’t want this project to end up like that.
I didn’t have to search much to find a template that builds Odin + raylib in WASM. So I started to implement ‘Offline Mode’ for my game. Didn’t take much time tbh, easy work. So I went to sleep and assigned WASM implementation to future me.
Thunderstorm
Next morning, I looked at how the {template](https://github.com/karl-zylinski/odin-raylib-web/) works - really simple and straightforward. I copied their code with proper attribution ofc. After fixing some build bugs, I ran my build.sh and…It didn’t work. But nothing works the first time…
Spoiler, it didn’t work in the 69th time either.
Tsunami
By evening, I was able to make it compile, I won’t get into the specifics but it had to do with multiple definition of functions within Odin core libraries.
So, after it compiled. I had a huge sigh of relief, I ran it in my browser and bam! A fully dark screen! Wait…What? NOO
I opened up the console… and Alas! Errors, not 500 errors, only one error Uncaught (in promise) InternalError: too much recursion
I couldn’t find what caused this error, how to fix it, how to narrow it down. Lastly I gave up and went to sleep. After I woke up! I one by one tested each file and their dependency. Lastly I found the culprit…it was Box2D 
After I dug deeper I found the fix, but it was concerned with changing the source code of Odin…so virtually no one can compile my game to WASM but me…
I’ll try to find a workaround for it, till then - if it works, it works.
The arrival to the forbidden Island
After a lot of hardwork, I got the fruits of my labour. This journey was not as much fun, but seeing my game run in my browser is so much worth it!
I fixed few visual glitches and frame time capture fixes. And then I pushed it into my domain :)
Comments 0
No comments yet. Be the first!
Sign in to join the conversation.