libGDX - What about that?

Hi lads! :slight_smile:

J0 speaking in newbie question — talk about newbie, I’m here to ask about libGDX, in a very… Let’s say newbie way.
I was actually wondering what libGDX was. Let me explain.
I’m currently coding my second java game — something between an RPG, a tower-defense and a puzzle game.
I have never used any extension. My first game and all of my attempts and experiments were mostly coded using swing for the graphical part.
Naturally, I’ve been working on my new project using swing. I have by now nearly finished the core part, and by that I mean everything that proceeds during a game session, as well as the graphical side of my ‘puzzle’ part and of my main menu, the two of them using swing of course. It has now been a few days I started working on the ‘RPG’ part. I’ve set the vectorial movements, the collision framework, etc… Actually, it should theoretically work fine, clean and everything. But — here’s the thing — the graphical part does not follow my expectations. :persecutioncomplex:
It seems to me that I came to the limits of coding a game’s graphics in swing. Maybe I have too much running everywhere, I’m not sure, the fact is that the graphical part I started working on just does not fit.
Images that should be drawn stuck together get separated on certain frames.
Some frames have trouble loading.
Some objects get blurry and move around while they should remain calm. ::slight_smile:
You can trust me on this one: nothing in the code sounds wrong. All the object positions, images, movements are very clearly defined and their access is not a trouble. Actually, even the console gets it better than swing.
So yeah, I basically need to move on to something else than swing. At first, I thought about AWT, but then I realized that, as swing was more recent, that should logically mean that if it can’t do it, AWT won’t be able to do it either. ???
So I thought, hey, how about I learn a little about libGDX? I mean, I’ve heard of it quite a lot around here, but I never really got interested in it. So here are my few questions regarding libGDX, and, remember, we’re in the newbie tab :wink:

  • Would it be possible to have an application working part libGDX / part swing? Can you make a libGDX component show up in a JFrame?
  • Would libGDX be faster and/or more efficient than swing?
  • Would libGDX be adapted for a top-down RPG-like game?
  • Would I need to rewrite my procedural part for collision detection, positions, or can all that be kept?
  • How difficult is libGDX to understand to someone who never dealt with anything else than swing?
  • And, most importantly, where would you recommend me to look for for easy libGDX tutorials to get started? ;D

Thanks a lot for having read it all through, I realize it’s quite a long paragraph I wrote here 8)

Good evening folks!

J0

EDIT: Or maybe should I try to have a look to JavaFX? Would that be better in terms of performance than swing for a 2D game?

Hello J0,

Yes, Swing is awesome, but it is not meant for games:

There are a lot of tricks to counter this, like drawing your game on one image and replacing your screen with that image when you are done with it, but that’s not what you came to ask for right:

A wrapper to create games for: iOS/Android/Mac/Linux/Windows/Web all at once. This wrapper uses OpenGL for all platforms, in short.

Sorry for skipping a few questions, but I think you should find out for yourself. Here the main part though:

  • Yes, but your application won’t be cross-platform anymore. So it would make more sense to use plain OpenGL in this matter, in other words: LWJGL (OpenGL itself is written in C++ so LWJGL ports it to Java)
    From now on I will translate ‘libGDX’ as ‘OpenGL’, since that is applicable to OpenGL itself.
  • OpenGL is indeed much faster than Swing since it doesn’t use software rendering like Swing but hardware rendering. It also does a lot for you, you don’t have to write your own gameloop anymore and all those nice things.
  • You can keep almost all of your code, almost the only thing you must change is the way you draw onto the screen, but I would do it as soon as possible if I where you, I might be forgetting some things.
  • Hard to say, but for 2D games it’s not too hard. LibGDX makes things easier as well, although I really recommend using LWJGL (and thus plain OpenGL) if you want to learn the depths of game programming.

Hopefully my answers helped, even if it is only a little.

Thank you very much for the quick answer! I’ll have a look at that tomorrow (it’s 1130 pm here in France so my laptop is off for now) :wink:

J0

I disagree with this part. Learning OpenGL will teach you the depths of graphic programming, not game programming. If your goal is to make a game, use libGDX. If you want to learn how the rendering pipeline works, use OpenGL.