Hello people!,I was programming games in c++, and now Im moving to Java world .

In my game design, I use a GameContext interface:

1 2 3 4 5 6

publicinterfaceGameContext {publicvoidstart(); // called by GamePlayerpublicvoidlogic(InputEventsi); // InputEvents are all my game inputspublicvoidrender(Screens); // Screen is another class from my packagepublicvoidend(); // called by GamePlayer}

My question is how the main game loop is coded in java, which classes should I use, and how?.(I already now the FPS and that stuff, but I don't know how to code it, the API is huge!!! )I read some books and tutorials, but they are old or very confusing .

If you're doing a FPS, you will really need one of the 3D extension libraries. JOGL or LWJGL will provide the basic OpenGL, but you will need to draw all your models yourself as triangles. The scenegraph based extensions will allow you to load models exported from maya or 3ds and position them in the world space, but scenegraphs aren't as fast as hand tuned code.

Now I need:1) Catch inputs events and store them.2) Double Buffer3) Run the game at constant rate

1) For the key events, I store each key state in a variable, set it true when its pressed and false when its released?. How is the best mechanism?The only way to "listen" those events is implementing the Component interface? (The only way I know to read inpur is with Component addKeyListener. Is there another way?)

OK, that isn't obvious. It means create a window at least 640 x 480 and preferably 800 x 600, with at least 16bpp colour depth, preferably with the colour depth already in use, and a frame rate of between 60fps and 85fps, with 60fps preferred.

It's a bit complex, but safer then insisting on a fixed size and then the computer says it can't do it.

To go fullscreen use

1 2

Display.create();Display.setFullscreen(true);

To draw on the screen, just use the OpenGL functions anywhere you feel like. e.g.

The libraries consist of part Java, part native library. Native libraries are generally available for PC, Mac OSX & Linux.

I thought you were doing a FPS & hence needed 3D. If you only need 2D, you could use the built in Java2D functionality (no extensions). For Java2D, it's worth looking at Kevglass' Space Invaders tutorial

BTW, regarding running at constant rate. It can be done, however different computers run at different speeds, so you might overframe on slower computers. Personally I prefer to run flat out & calculate the elapsed time between frames and use that to scale the user's inputs.

Just a suggestion, if you want something simple and for making 2D games.Perhaps you want to check out my game engine, Golden T Game Engine (GTGE):http://www.goldenstudios.or.id/products/GTGE/It's a simple 2D game engine (you can take my word!), built on top of Java2D by default and can use OpenGL via JOGL/LWJGL for more performance.It's new enough since no one never mention it, but it has been developed by 1.5 year already.It's stable enough and many games has been developed with GTGE.

These are the list of some games developed with it, and some of them are made by GTGE users:http://www.games.goldenstudios.or.id/The games are hosted on different site that currently is down, so most of the games can't be played right now.

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org