Java Applet Pains
I recently had the pleasure of building a low-fi promotional video game. One of the requirements? The game needs to deploy as an in-browser Java Applet. When was the last time you created one of those?
LWJGL “nicely” allows you to deploy your game in different ways, while not drastically changing your game’s codebase. From the browser-based applet, standalone .jar executible, to the .jnlp web-start application; however, each has it’s own little quirks and frustrations.
I recall spending an evening completely befuddled as to why my game wasn’t deploying properly to the browser. I could run other java applets (a separate headache on linux, for sure) and followed any tutorial I could find on deploying applets. Key-signing files. You name it … futile.
Finally, I stumbled upon a combination that worked:
- Make sure your main Slick2D class driving your game is called “MyGame”.
- Deploy.js can be found here. It’s Sun’s helper library.
- The ‘gamelib’ is a child-level directory of your game project where your lwjgl libs are likely stored.
- Incorporate the snippet below, and load in your browser.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31