I wrote this game entirely in Java2D and the tank game is in Slick. I’m getting much better Frames per second in Slick2D.
Slick has some oddness to it, they overloaded the Image class so any time you used a BufferedImage you now use their Image class. However, you load a class simply by handing it the file name and you’re done.
Slick handles the game loop for you.
Slick handles transitions. You’ll notice in the video that the first scene fades out and the new scene fades in. That entire transition is done with one line of code.
game.enterState(Level1.ID, new FadeOutTransition(Color.black, 300), new FadeInTransition(Color.black, 300));
Slick2D already has particle emmiters so you can do fire, smoke, and waterfall effects. It’s also quite easy to rotate individual images without having to deal with affine transforms manually.
It also can handle a tiled background made from The Tiled Editor. The code to load is is simply:
TiledMap tiledMap = new TiledMap("assets/common/images/Map2.tmx");
What it doesn’t have is a camera class to scroll around that map. There’s a class in the SLick2D forums which I used. I think it should be part of the core SLick2D API.
Apparently, everything in Slick2D is wrapping lwjgl so all the graphics calls are being done in OpenGL. This should mean that if I needed to use some sort of special OpenGL call I could do so. I don’t know enough about OpenGL yet to know if I can write shaders yet but that would be pretty darn cool. Imagine a tank game in the dark where you can only see what’s in the headlights.
The Tiled map creator which Slick2D uses so easily has some limitations though. I’d like to have buildings which can show different levels of damage. There isn’t, as far as I can tell, a way to turn individual tiles on or off for a tiled layer. I’d probably have to modify the Slick2D source code to do that. Also, each level must be loaded up front so they take up memory for the entire game. I’d rather see the level (or GameState class) take a string of the class name and as that level is requested it can lazy load it via Java Reflection. I’d also like to see a boolean for a GameState class where I can say it’s volatile. That way, when we move away from that level we can tell the engine that it’s ok to free up it’s memory usage.