Couple of Optimal Questions

Ok, which renderer is the BEST and fastest for rendering a 2d game in an 800*600 Canvas app window. Is it the openGL one, yet there are two version i hear of a JOGL or soemthing and a LWJGL something like that. Well what is the best to learn. CokeandCode goes over both, but I dont know which one is better.

ALSO, sound. Lets say I want to play .mp3 files in java, and not wave in a game, because .wav is too large for music files. Do I use something called openAL, is this the best? Any tutorials on openAL? I just want to use the right stuff to start off.

ty for help.

Best is really subjective. OpenGL means you’ll get better performance on most games playing systems - but it means you’ll get the tricky-ness of making sure your end users have appropriate drivers. If you use pure Java2D it’s likely to be slower than your bespoke implementation but it’s easier to grasp and more likely to be compatible everywhere.

If you do choose OpenGL then the choice between JOGL and LWJGL is more about API style and support requirements. LWJGL uses a very static oriented API (mapping to that of OpenGL). JOGL uses a more object based API (mapping to that of Java). Which is better is really just a matter of what fits for you. Support-wise the forums here for JOGL are pretty active -but LWJGL has a more game oriented user base - so again, it’s a matter of taste.

Finally, I’d advise using OGG over MP3 - mostly because of the odd licensing around MP3 but more because there are plenty of sources of OGG decoding playing code for Java. If you were to choose LWJGL (OpenGL/OpenAL) and want to decode oggs you could use another of the coke and code tutorials on playing sounds - sorry blatant plug. Though it might make more sense if you start at the beginning.

Kev

is it possible to make your game support BOTH java2d and LWJGL and let them choose? i think the space invaders tut # 3 lets you choose both, but its longer.

Yeah, it’s definitely possible. You write an abstraction layer across the top. However, here’s one firm piece of advice (unusual for me). Pick your renderer and stick with it - good looking games are targetting to their audience’s platform. You could spend alot of time of time making the rendering work in both system only to find you’ve got the lowest common capabilities between them.

If your requirements are:

  • Render a 2D games - sprite based
  • At 800x600

Then either works for you. Work out a few more requirements like:

  • Want some special effects
  • Must work everywhere
  • Must have a small download
  • Its my first real game, I want someone to ask questions to
  • I want to render thousands of sprites per frame
  • I’ve never developed with OpenGL and I need to have this finished next week (short timescale requirement :))

You could determine what was right for you.

Kev

My game will have a lot of animation on its tiles, and the units will have movement animations, shooting,idle, ect… which can osmetimes lead to about or more than a 1000 sprite animations on screen. Time is not an issue. And i plan to use transparency a lot.

Then I’d suggest OpenGL in your case. Now you have to choose LWJGL or JOGL. I personalyl use LWJGL as my port of call. JOGL (or rather the JSR) will eventually become a part of the JRE (should be noted that this is still very eventually).

I use LWJGL mostly because I find the support to be outstanding - but secondly becomes I’ve seen commercial games written using it. I also prefer to be working outside of the shadow of the Sun. The benefit of having input/graphics/sound all packed into one consistant API also makes it very appealing.

Taking JOGL/JOAL/JInput as a comparison still seems to have it’s issues (reading around the forums you’ll see them). That’s not to say it wouldn’t work for you - I’d say LWJGL is less of a risk.

At the end the day the decision isn’t terribly important, it’s pretty easy to move back and forward. The import bit is to get on with the game :slight_smile:

Kev

Ok ty for help, I will utilize LWJGL and OpenAL components.

Seconded. The lwjgl forum also tends to be faster than the one here (although they’re both pretty active).

Are you sure these questions are really optimal? (sorry)

Ok, I actually am deciding to do accelerated Java2D instead, as most of my books cover it, and I am noob.

But as far as the sound handeler? I should still use OpenAL right, or something else? Also .ogg, does openAL allow me to modify all sounds it plays, so like I could have my game have a “sound enhancer” checkbox for people who want to utilized my coded sound enhancer?

As for sound, another option would be the standard JavaSound API. I personally prefer the JavaSound API over OpenAL as the former seems to be cleaner and easier to understand and learn. If you want to enhance sound on the fly, you will have to do streaming. Trivial in JavaSound, a bit more difficult and fiddly in OpenAL.
OTOH, OpenAL seems to be faster and has far less latency (at least on my machine).

So if you are a noob, I suggest to start with JavaSound. If you are a bit further in your learning process and you encounter problems with JavaSound that could be solved by OpenAL, you can always consider switching APIs later.
If you suspect you might be switching APIs at a later stage, create abstract interfaces for your sound system so you can simply reimplement them later using another API.

Yes, I am a noob. ;D

I will utilize the JavaSound components ;D

EDIT: But i thought JavaSound cant play .ogg or .mp3?

[quote]EDIT: But i thought JavaSound cant play .ogg or .mp3?
[/quote]
Sure it can. Look here: http://www.jcraft.com/jorbis/

If you need to convert your files to .ogg I found that oggdrop is pretty nice with its drag-and-drop interface:

Oggdrop

But I also want a file format that isnt so “lossy” I know mp3 is pretty crap as far as lossy, hmm I dunno.

It all depends a bit on with what quality settings you encode your mp3 or ogg. If you encode with 256Kbps or more, the quality is pretty good. Maybe ogg sounds slightly better than mp3 with the same bitrate settings but the difference is pretty small with 256Kpbs and up. With such high bitrates, most people won’t be able to tell the difference between mp3 and CD sound.

If you want lossless compression you have flac, but that leaves you with only 1/2 compression ratio and I don’t know if there’s a java lib for that.