Overcoming The Limitations of WebAssembly


Web assembly is very cool, provides a "linux-like" run environment (if that's your thing) and offers a nearly native running speeds.

But also comes with lots of restrictions.

You Can't Copy and Faste From or To the Game

You don't have access to the clipobard from the game, maybe there is a way to overcome this limitation, but I didn't find any reliable way to do it.

In my case, I needed because the way you export levels on the game is throug text, my first idea was to create a textbox in dearimgui and then the user will copy or paste his level data, and then click import or export button and everything will be amazing. But that was not the case.

Luckly, you can call a javascript function from your game, so I manage to write in a text box the url where the level information will be encoded, the game will read the url on startup, decode and recreate the level if there is information there.

Is this the best way to do it? no, but it works and its good enough for the users to share their solution in the comments.

In Order to Play a Sound, First You Have to Click In The Game

This is the reason of "click to start" screens were created, you can not play a sound if there is no user interaction first. In my case, I show the "how to play" screen. When the user press "Ok", I initialize the sound and create all the generated samples. The problem is that the user can open the window anytime during the game, and also can interact with sound emitting things when before the sound system is initialized, if thats the case, the game will crash. 

To prevent this, I need to check if this is the first time the How To Play Windows was opened, and prevent any sound emitting interaction by hidding the UI.

Its the best solution? no, but it works.

Final Words

Working your way around limitations are part of the development, and in the context of a time restricted project like a game Jam, usually the naive implementation is the right one.

Leave a comment

Log in with itch.io to leave a comment.