Skip to main content
GameDev.net gamedev.net
🔒 Locked

Java Game Programmer

Started by kronus980 Jan 1, 2012 at 6:34 AM 9 replies 4.8k views
Original Post
kronus980
kronus980
Where would be a good place to start learning java game programming?
boogyman19946
boogyman19946
That all depends on how you define "good." In reality, there are a few good places to start. My personal suggestion is to start learning the language first. As a general rule of thumb, you should "start small and progress gradually." Once you know the language, you can start making simple text-based games (like card games, simple adventures, etc.). Then once you feel comfortable with the concepts, move on to graphics and, again, start simple. Print something to the screen, move it around using keys, etc. etc. I think it's pretty self explanatory.
Yo dawg, don't even trip.
Florian22222
Florian22222
I think nowadays java isn´t a language for games. I am currently running a project for a simple action game in java with AWT, and the main menu(only a few buttons) is rendered with 60 fps only! I would recommend C# or C++.

If you say: "But I want to learn Java" then you should start with the basics as boogyman said.
Furthermore you have to be really patiently cause noone just starts game programming. First comes normal programming.
larsbutler
larsbutler

I think nowadays java isn´t a language for games. I am currently running a project for a simple action game in java with AWT, and the main menu(only a few buttons) is rendered with 60 fps only!


Why not? Java isn't quite as popular as C++ in the game industry, sure, but let's not forget about Minecraft, for example. Minecraft is hugely successful and it's written in Java.

Also, why could you only get it to render at 60 FPS? This seems strange.
rip-off
rip-off
60 fps is plenty - users will not be able to see any visual difference above this frame rate. The frame rate is probably vsync capped anyway. Either way, it is not a conclusive argument against using Java for games.

Generally one does not use AWT for games (unless they are the kind that lend themselves particularly to such a "standard" GUI, or a prototype). There are many libraries or frameworks which allow you to use Java with something like OpenGL for rendering.
DenverD
DenverD
Java is the language used for Android apps (along with XML for the manifest file) -- I just started learning Java too, to eventually develop Android games.

Check out these tutorials from Oracle (the developers of the Java language, if I'm not mistaken). I'm using these, and it's coming along great. It helps to have a bit of background in some other language to use these tuts, though:

http://docs.oracle.com/javase/tutorial/
Florian22222
Florian22222

[quote name='IceBreaker23' timestamp='1325440029' post='4898711']
I think nowadays java isn´t a language for games. I am currently running a project for a simple action game in java with AWT, and the main menu(only a few buttons) is rendered with 60 fps only!


Why not? Java isn't quite as popular as C++ in the game industry, sure, but let's not forget about Minecraft, for example. Minecraft is hugely successful and it's written in Java.

Also, why could you only get it to render at 60 FPS? This seems strange.
[/quote]

That seemed weird to me too. I think the problem is that there are 5 images which are getting scaled real time. I need to improve this^^



60 fps is plenty - users will not be able to see any visual difference above this frame rate. The frame rate is probably vsync capped anyway. Either way, it is not a conclusive argument against using Java for games.

Generally one does not use AWT for games (unless they are the kind that lend themselves particularly to such a "standard" GUI, or a prototype). There are many libraries or frameworks which allow you to use Java with something like OpenGL for rendering.


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

We are only using AWT, because in our school we only learn standard java and I hope the performance of AWT does it.
[/quote]
That is OK. But it is not an excuse to claim "java isn´t a language for games", because that cannot logically follow from your experience* with a single API.

* [size=2]And not to be mean, but I could just as easily say "relative inexperience" here, as you are still learning.
kronus980
kronus980
I want to thank you guys for the replies. I know the language at about a novice level, and those are great examples for me to start. What I need help with are handling resources, such as sounds, images, 3D models, and loading and playing sounds. I already have input covered.

I think nowadays java isn´t a language for games. I am currently running a project for a simple action game in java with AWT, and the main menu(only a few buttons) is rendered with 60 fps only! I would recommend C# or C++.

If you say: "But I want to learn Java" then you should start with the basics as boogyman said.
Furthermore you have to be really patiently cause noone just starts game programming. First comes normal programming.

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.
daviangel
daviangel
I wrote a Zelda clone in Java using the "

Beginning Java SE 6 Game Programming" book by Harbour. It covers creating a 2D game engine in Java using Java2D. For a more detailed book with better error detection and better full screen performance check out the

"Developing Games in Java" Brakeen book. His website also has same code you can check out to get an idea of what you need to know. Finally, the most in depth and largest Java game programming book I have read and is "Killer Game Programming".

[size="2"]Don't talk about writing games, don't write design docs, don't spend your time on web boards. Sit in your house write 20 games when you complete them you will either want to do it the rest of your life or not * Andre Lamothe
cmasupra
cmasupra
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 ;)
kronus980
kronus980
Thanks again. I got the language to an extent.. but the API and book tip helps. Thanks again!
j-dog
j-dog

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.
SimonForsman
SimonForsman

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!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.