Making Melons Bounce (in the browser!)


Hopefully not being mistaken for boob physics or anything, what I've achieved here is the integration of a 3D physics engine into libGDX!


That may be a strange sentence to those familiar with libGDX - this is because it actually already has a physics engine included in its extensions. It's called Bullet, and it's originally written in C++. Since our game library and game is written in Java, we can use a native java technology called JNI (java native interface), and using it, we can access code written in other languages.

Now obviously my original submission into the libGDX game jam, a .jar using the above technology to cause such melons to roll and collide is not that impressive. However, such a game in the web browser, embedded into a page for luls or something of the sort, now that is much nicer!

libGDX has its browser implementation by using Googles GWT technology, which transpiles java source code into javascript source code. This however, has severe limitations - you must have the source code available for all the libraries you wish to use (not just the compiled binary or distributable). A funny thing about libGDX is that there is a java version of box2d, another popular 2d library, just so it can be used with GWT. Bullet has no such luck.

However, to cut out any suspense, there is also a library called ammo.js, which is essentially Bullet, but crosscompiled into javascript using some existing technology I'm not familar with. Using that, along with JNI to use javascript (which works with GWT), our melons could exist in browserland!

The best part of my journey, is that I found a 4 year old project that did a massive amount of the work of integrating ammo.js (I wasn't looking for anything advanced), but there was everything I needed, short of being part of some sort of build tool ecosystem. Thus, I slapped some existing libGDX gradle builds that I commonly used in there, and after a LARGE amount of hassle (out of scope for this article)...


Play it now!

https://developer-doge.itch.io/the-world-is-melon


Thanks for reading a post by @DeveloperDoge,

Files

build.zip Play in browser
Jan 17, 2020

Get The World Is Melon

Leave a comment

Log in with itch.io to leave a comment.