Basic Setup
From Slick2D Wiki
- Download Slick2D from here and LWJGL from here.
- Create a library in your IDE, call it however you want!
- Include slick.jar (under the lib folder inside the slick.zip file), lwjgl.jar (under the jar folder inside the lwjgl.zip file) and lwjgl-util (again, under the jar folder inside the lwjgl.zip file).
- Create a new project in your IDE and add the library you created.
- Extract the native folder from the lwjgl.zip file.
- Go to your project properties (yeah, the one you created with me) and add the natives path. But how?
Adding natives in NetBeans
- Right click your project -> properties.
- Select the run category.
- Enter the following into VMOptions: -Djava.library.path=<lwjgl-X.X path>/native/<linux|macosx|solaris|windows> (complete needed).
- Cheer.
- Now we'll try running a very simple game! The point of the game will be checking if our setup succeeded!
Create a main class includes the following:
package simpleslickgame;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.newdawn.slick.AppGameContainer;
import org.newdawn.slick.BasicGame;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.SlickException;
public class SimpleSlickGame extends BasicGame {
public SimpleSlickGame(String gamename) {
super(gamename);
}
@Override
public void init(GameContainer gc) throws SlickException {
}
@Override
public void update(GameContainer gc, int i) throws SlickException {
}
@Override
public void render(GameContainer gc, Graphics g) throws SlickException {
g.drawString("Howdy!", 10, 10);
}
public static void main(String[] args) {
try {
AppGameContainer appgc;
appgc = new AppGameContainer(new SimpleSlickGame("Simple Slick Game"));
appgc.setDisplayMode(640, 480, false);
appgc.start();
} catch (SlickException ex) {
Logger.getLogger(SimpleSlickGame.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
- If everything went smooth, cheer harder.