I’ve been trying to figure out how to make an applet with Slick2D and I just can’t seem to get it to work. I made a Main class and a Game class which extends BasicGame. The “game” runs perfectly on Eclipse, but when I compile it and launch it on a browser, it loads the content and shows a blank page after.
I posted the applet on my site as well as the FULL src to the project. Any help would be appreciated!
Applet: http://ghostid.net/games/applet_test/
Source: http://ghostid.net/external/downloads/Applet_TEST.zip
Here’s all my code…
Main Class:
public class Main {
public static void main(String[] args) {
try {
AppGameContainer game = new AppGameContainer(new Game("Test"));
game.setDisplayMode(350, 250, false);
game.start();
} catch (SlickException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
Game Class:
public class Game extends BasicGame {
public Game(String title) {
super(title);
// TODO Auto-generated constructor stub
}
@Override
public void render(GameContainer gc, Graphics g) throws SlickException {
g.setColor(Color.red);
g.fillRect(45, 45, 125, 100);
g.setColor(Color.black);
g.drawString("Hello. .__.", 60, 75);
}
@Override
public void init(GameContainer gc) throws SlickException { }
@Override
public void update(GameContainer gc, int ticks) throws SlickException { }
}
Here’s my code for my HTML file.
<applet code="org.lwjgl.util.applet.AppletLoader"
archive="lwjgl_util_applet.jar, lzma.jar"
codebase="." width="350" height="250">
<param name="al_title" value="test">
<param name="al_main" value="org.newdawn.slick.AppletGameContainer">
<param name="game" value="net.ghostid.Main">
<param name="al_jars" value="game.jar, slick.jar, lwjgl.jar.pack.lzma, jinput.jar.pack.lzma, lwjgl_util.jar.pack.lzma">
<param name="al_windows" value="natives/windows_natives.jar.lzma">
<param name="al_linux" value="natives/linux_natives.jar.lzma">
<param name="al_mac" value="natives/macosx_natives.jar.lzma">
<param name="al_solaris" value="natives/solaris_natives.jar.lzma">
<param name="al_debug" value="true">
<param name="separate_jvm" value="true">
</applet>
Sorry for the sloppy code, tried making it as small as possible so this post wouldn’t be insanely long.
So what’s wrong? Why is my Applet just giving a white screen?
Thanks an advanced,
Once I get this working, I’ll make a CLEAR tutorial on how to make a slick2d applet… ._. I can’t seem to find a full one with source code.