Java Game Development

Much of the focus on Java has recently moved away from the client side into server side development. However, when it comes down to it, Java is still the only universal platform for providing advanced multimedia and interactivity on the client side that accommodates all browsers back to Netscape 2.0. Because of this, providing interactive games that reaches all platforms and all browsers still needs to be done in Java.

I’ve developed over thirty games or infographics for Discovery Channel Online (DCOL) over the last eighteen months. Discovery Channel Online is the web presence of the hugely popular Discovery Channel and as such has a distinct corporate image to live up to. Game development on DCOL must be consistent with Discovery’s mission to allow people to "Explore Your World". The site is mainly focused on Feature Stories and Expeditions to strange and interested places such as Antarctica, Madagascar, or sometimes the stories are right in your own backyard such as Rollercoasters.

Rapid Game Development

Using game development we try to enhance the experience and give people an opportunity to interact with the content in a manner not possible on TV. In the Antarctica story, it was a drag and drop game where you pieced together the Antarctic food chain from plankton to killer whales. In Madagascar, we studied the Humpback whales and an infographic allowed you to look at the anatomy of the whale. The Rollercoaster story was perhaps the most successful of all. In the game, users Build A Coaster in order to find out what makes a coaster scary and learn about the physics behind it.

Sun Java Studio

Developing Java games rapidly does not always mean programming them from scratch every time. While I still do most simple infographics by hand I rely on RAD tools and authoring tools to speed development. For games that require text interaction and calculations I rely on Java Studio from Sun. Studio is a GUI driven tool for assembling Java Beans. The tool comes with over 50 Java Beans and many other developers including IBM have been developing more compatible Java Beans. The built-in beans allow JDBC connectivity, multimedia, charts and computation.

mBed Interactor

While Java Studio is a nice tool, Discovery has always been about visual presentation and Studio is somewhat limited in its multimedia capabilities. For the more advanced games I turn to mBed Interactor. For those of you who might have worked with Macromedia’s Director this product is similar though it has been designed to be web centric and doesn’t have legacy of being a CD-ROM development tool as Director does. This means that Interactor is lean and mean while still delivering a top-notch multimedia experience. Interactor works with precompiled Java classes that draw their parameters from a text based file. Because it uses an open text-based system, Interactor can be dynamically generated using CGIs, Microsoft’s Active Server Pages or Allaire’s Cold Fusion. The strength of this open text based system also allows Interactor files to pass variables to and from JavaScript or VBScript. I’ve often used these features to add personalization to game development. Simple personalization can be done with JavaScript and cookies. It can be used to track the user's name and their personal high scores. The text-based standard allows me to mix and match a number of client side and server side technologies to provide true interactive multimedia at very low bandwidth.

Performance Issues

As with all online multimedia performance issues are critical both for download time and performance once loaded.

Download time is critical in web based games. Interactor Lite uses stripped down Java classes that are between 20 and 33K total. It is very good for simple infographic that download quickly. Even with the limited capabilities, it still delivers sprites, animation paths, buttons, text, score (timelines), sound and vector based boxes. It leaves out much of the ability to handle variables and do math. The Standard version of Interactor is composed of Java classes closer to 100K. Along with the accompanying graphics, which are kept in their native formats, the total interactive package is in the 130K-150K range. Interactor Standard allows for full-blown game development such as the Rollercoaster and Food Web games we saw earlier. It is also capable of communicating with JavaScript and server side applications to give personalization and track high scores.

Performance is another issue. My experience indicates that Java based games run fine on a Pentium 133MHz and faster. As games acquire more layering, more animations and drag and drop interfaces the performance degrades. Simple infographics with rollovers will perform fine on nearly any machine. Older browsers such as Netscape 3 are only capable of displaying graphics in 8-bit (256 colors). If full color graphics are used, the browser goes through several rounds of dithering the graphics to the correct color palette before they display on the screen. If you expect a significant portion of your users to have Netscape 3 it is best to stick with 8-bit graphics.

Interactor has some weaknesses. The Java version is weak in mathematical calculations beyond simple addition and subtraction. Complex math must be passed out to JavaScript calculated and passed back into the applet. It is also weak on entering text and this must be handled using HTML forms and passed into the applet again using JavaScript. mBed is good about providing demos on how Interactor and JavaScript work together.

Java based gaming while suffering from browser incompatibility and performance issues is still the only way to deliver multimedia games and interactivity to a wide range of browsers. Using tested classes such as those provided by Sun and mBed Interactor the developer can be assured that they will get playback in nearly every Java compatible browser.

Jeff Rule is a principal at RuleWeb Development specializing in DHTML, SMIL, WebTV Interactive TV and Java based multimedia enhancements for advanced media sites. His first book, Dynamic HTML: The HTML Developer's Guide was published in Decemeber 1998 by Addison Wesley Longman. It features many DHTML multimedia examples from his popular DHTML Demo's web site.