开发者

Game Programming in Java

I know this is a somewhat common subject, but the information is outdated quickly. I want to stay with the times on the topic...

Anyway, I am looking into creating a 2D game in Java that is able to work cross-platform. As many others have said on Stack, much of the example code and information about Java graphics APIs is outdated to no end.

Here's the deal:

  • Rolling my own is not a problem, but if there is a decent third-party API available I would like to look into it.
  • Which Java API do I use for Graphics / Sound?
  • I am very versed in Swing already, but from my experience it is not the best way to 开发者_StackOverflowgo for a game. I could be proven wrong on that.


Two of the more interesting game libraries for making 2D games in Java are the Golden T Game Engine and the Lightweight Java Game Library (LWJGL).

I would recommend taking a look at LWJGL first, as there have been several examples of rather successful cross-platform games that were made with it, including most, if not all, of the games released by PuppyGame Studios.


For graphics, you might consider Qt Jambi. It gives Qt-like API to Java, including graphics view(arbitrary 2D drawing, high level API) and its OpenGL classes (OpenGL bindings to Qt, nothing special here). It also contains Phonon, multimedia architecture that can be used to play audio and video.

The minus is that it is just bindings to Qt, so it requires native libraries in order to work.

(Yes sorry I’m part of that project)


If you are interested in an old-School answer, I personnaly like a lot to master the Java Graphics API and understand how you can simply draw graphics from within swing components. The basics of Java Graphics are quite interesting and the platform offers advanced graphic operations, ease double buffering, gradients, textures, affine transforms, image manipulation and (limited) audio support, floating points precision, full screen drawings. The advantage of mastering a "relatively low" level API if that, after that, you understand much better how advanced librairy work and what they have to offer.

So I would recommend building your game from only what's available in the JSDK. I did it for a lot of classic games and teached it to my students and I think it's been a pretty good way to form them.

If you already know much of the basics, then I would recommend putting your hands on a more productive librairy, or even explore some. @Smar pointed out an interesting one.

Regards, stéphane

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜