Java Game Programmer

Started by
9 comments, last by cmasupra 12 years, 3 months ago
I only use Java for my game programming because it's an easy language and the one I know best.

The largest problem you'll encounter is a lot of people don't have Java installed or don't know what to do with a .jar file. You can use tools such as Launch4j to create executables that don't require Java to be installed, but then it makes a different file for each platform.

Also, don't use the built-in Graphics API for Java game programming. It uses the CPU to do everything, so it's slow. Use an OpenGL-based library. I use Slick2D (slick.cokeandcode.com). A popular 3D engine is jMonkeyEngine. Once you become more experienced, you could write the OpenGL code yourself without using a library or engine, but I'm not there yet, so I can't say anything about that.

The first thing to do, though, is learn the language, of course ;)
Advertisement
Thanks again. I got the language to an extent.. but the API and book tip helps. Thanks again!

I find nothing wrong with java for games. The only difference I see in java and C/C++, is that java isn't officially supported on consoles, other than rumored performance differences.


These "rumors" happen to be true - Java runs off a virtual machine, a highly optimised one, but still a virtual machine. That, plus garbage collection, do incur a slight performance cost. In games, performance matters. A lot. However, although those who state that java is slower are correct, such claims tend to be greatly exaggerated. It really comes down to how well the code is written. Well-written java code will obviously outperform the unoptimised counterparts of "faster" languages.

We are only using AWT, because in our school we only learn standard java and I hope the performance of AWT does it.


If you want good performance with AWT you should:

1) enable OpenGL hardware acceleration using -Dsun.java2d.opengl=true (If your system and VM supports it)
2) make sure the BufferedImage has an appropriate format, look at the GraphicsConfiguration class and its createCompatibleImage method.

You can skip the OpenGL part if you want but part 2 is essential, incompatible image formats will completely ruin your performance. (60fps is not bad though, if vsync is active it is the most you can possibly get)
[size="1"]I don't suffer from insanity, I'm enjoying every minute of it.
The voices in my head may not be real, but they have some good ideas!

This topic is closed to new replies.

Advertisement