I'm starting to create my own side scroller, in Java. I think I've read that, when you create a game in Java, there is something you can extend your class with, like GamePanel.

Is this true, or can you just use JFrame for your Java games?

  • \$\begingroup\$ Can we have more information about the game? For example, if you are using JOGL or Java3D for rendering, then those would have specific requirements for what you can draw to. If you're doing a 2D game and not using any libraries (i.e. overriding paintComponent()), then I guess pretty much any Swing component would work and a bunch of event listeners, but I wouldn't think that would be the most performant piece of code. \$\endgroup\$ – PatrickB Aug 15 '11 at 3:54
  • \$\begingroup\$ Alright! At the moment i am not using any libraries for my game.. But if i should which library is good you think? \$\endgroup\$ – TheCompBoy Aug 15 '11 at 6:26
  • \$\begingroup\$ If you're going without libraries (which IMHO isn't neccessarily a bad thing) take a look at BufferStrategy: docs.oracle.com/javase/7/docs/api/java/awt/image/… \$\endgroup\$ – Steve Smith Jun 13 '17 at 11:41

For a Java game that uses no libraries, I would suggest you extend the Canvas class and override the paint(Graphics) method. It is the most basic component you can use without a lot of overhead.

However, I strongly suggest you look into Slick or JMonkeyEngine. They both use LWJGL; the former is for 2D while the latter is for 2D and 3D.

To kill two birds with one stone, I would also suggest you look into Artemis, which is an awesome Entity System that works on top of Slick. The site contains some example games to help you get started.

| improve this answer | |
  • 2
    \$\begingroup\$ Note that the Slick2D forums are EXTREMELY active and helpful \$\endgroup\$ – liamzebedee Dec 13 '11 at 1:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.