Do Slick2D have advantages over Swing? Example, do it interfere with the native system better than Swing do? Why is it better than Swing?
Isint Slick2D just a modified Swing window?
Slick2D is better than Swing for a number of reasons, chief among them is its simplicity. It is very easy to jump in with just the documentation behind it. It also runs somewhat faster since it is layered over LWJGL, which uses OpenGL, to speed up the process. I would recommend using it for a beginning project, then moving on to other libraries or using straight-up LWJGL.
Slick2D’s API is also good for newbie who never used anything but Java2D.
Slick2D is not modified Swing, it’s a 2d graphics library that uses OpenGL for rendering. Java2D (an extension of Swing) has an OpenGL-accelerated path, but it’s very finicky, drops to software rendering easily, and doesn’t let you use any extra OpenGL features. Slick2D on the other hand strictly uses OpenGL, which makes it much much faster.
Where Slick is somewhat like Swing is in the API, specifically that the API is familiar to Java2D users. It’s not an exact copy, but it’s close enough that porting code is not extremely difficult.
For integrating with the native window system, Swing does much better (as good as Swing does anyway). Slick2D doesn’t even have a concept of a button built in, you need third party widget sets like TWL or NiftyGUI to make those.
Personally, I tend to recommend LibGDX these days as a 2D library, but I won’t hijack a Slick thread evangelizing it.
Actually you have done it.
Like I said Slick2D is easier for first step of migration. IMHO Libgdx’s architecture is harder.
IMHO somebody should write a minimal Java2D-like wrapper on top of LibGDX, i.e. to replace Slick and feed the newbies a library that doesn’t include words like “matrix”, “blending” or what have you.
The only advantage to Slick is that it hides GL concepts (whereas LibGDX makes them visible), so if you are afraid to learn what actual graphic programming entails, and would rather be spoon fed, then you may prefer Slick.
Don’t forget that Slick2D has a ton of features that Java2D does not. It’s not just two different ways to display graphics - Slick2D has tools that makes game development easier.
I’ll just leave a list of things Slick2D has, that Java2D does not.
- Pathfinding
- Resource loading
- Support for TiLED
- Animation framework
- Particle systems
- Audio
- Transitions between screens
- Spritesheet support
I’m doing that in this last 3 weeks :point: but not to become Slick, just simple wrapper (higher than Game and Screen classes).
Well, I am not that convinced to use Slick2D. I am not creating a high performance game anyway. However, my game looks laggy on my laptop for some odd reson(it is not really laggy as the fps is locked at 66. Its more like an graphical glitch), which is why I am considering switching to Slick2D.
This is a curious thread for me.
I started converting my 2D game over from AWT over to Slick last night for several reasons.
The input handler on AWT was missing mouse events
The input handler on AWT was slow on keyboard event
I finally maxed out the Java2D canvas painter, and 90% of of my CPU time was sitting on the call to Graphics.drawImage() which I could not do anything to optimize.
Using Slick2D I am able to not have to fake the shading and other effects to keep performance. I used to keep 4 versions of my tiles in different shades to quickly achieve the desired shading effect. With Slick2D, I am able to pull the shading off on the fly using the same logic.
However, Slick2D is over-simplified for my tastes. If you use BasicGame you don’t have direct control over which GL “canvas” you are writing to it seems. The draw logic for an sprite/image seems to be in the Image() class and not in the rendering method. You call a whole bunch of methods to draw the images individually. This seems counter intuitive to me. There is probably some reason for it that is beyond my limited knowledge.
What I do know is I went from 20 fps in my game to 160fps. The memory footprint also went down because my images are now stored in VRAM, and the CPU went down a whole helluva lot (now it runs at 20% instead of 100%
I also had the same laggy problem with Java2D as well. I had locked it at 20-30fps, but my sprites never refreshed more than once-twice a second. I could never figure it out.
Not having that problem with Slick.
There is only one “GL canvas” – it’s the Display that you see. Unless you use an AWT container, which you generally shouldn’t need.
Slick has some horrible design errors, like Image rendering logic inside of the Image class. For a cleaner API and stronger control over GL, shaders, vertex buffers, etc. you should use LibGDX.
That is the thing, for this game, for a first effort, I don’t need or want stronger control over OpenGL. When I get to be a Knight on here, I will probably want that then. I have a ways to go. This game, an old school RPG does just fine under Slick2D.
Maybe Game #2 can be libGDX.