Applets

From Slick2D Wiki
Jump to: navigation, search

Note: Due to continuing security issues in the Java browser plugin, it is advisable to avoid distributing your game in the form of an applet. Use Webstart or simply distribute your game's executable JAR.

Applet support in LWJGL is being still it's early stages and so it still has some compatibility issues in certain browsers (notably Opera). However, the concensus agrees that having a full OpenGL context in an Applet leads to some great jumps forward in Java games.

Slick allows applets in a very convienient manner. A game written originally to sit within an application game container can be easily transfered into an AppletGameContainer and hence be used an Applet. The “applet” directory of the distribution contains the required libraries and an example HTML page that will display a game as an Applet.

Example HTML[edit]

The following HTML is used for all Slick games displayed as Applet. Note that you may have to include extra signed JARs in the archive tags depending on what libraries you use in your game:

<html>
<body>
	<applet code="org.newdawn.slick.AppletGameContainer" 
archive="slick.jar,testdata.jar,lwjgl_applet.jar,lwjgl.jar,lwjgl_util_applet.jar,natives.jar,jinput.jar" 
width="640" height="480">
		<param name="game" value="org.newdawn.slick.tests.InputTest">
	</applet>
</body>
</html>

The significant change required from game to game is changing the value of the parameter “game” passed into the applet. The parameter should be set to the fully qualified name of your Game implementation.

Known Issues[edit]

  • Low specification/Old machines stutter heavily
  • Opera often doesn't show the applet at all
  • Major security risks with the Java browser plugin has led to many users disabling the Java plugin, thus support may be spotty