Whats the best startup code for a java2d game ?

Well you know:

  • Setting up full screen

  • Quering and allocating the right buffers (after setting full screen)

  • Setting up the events to dismiss all those swing and awt unnecessary stuff

  • building the right class and callback methods and swap buffers at the right times

  • setting up the right game cycle:
    setup, (read input, process input, render and swap buffer)*, cleanup and exit

Any idea on the best way to do this ?

this might get you up and running http://www.java-gaming.org/cgi-bin/JGOForums/YaBB.cgi?board=share;action=display;num=1036791657

[quote]this might get you up and running http://www.java-gaming.org/cgi-bin/JGOForums/YaBB.cgi?board=share;action=display;num=1036791657
[/quote]
That looks good thanks.

As anyone tried to do a 2d scene graph ?

Are there any alternatives for the game interface instead of using awt (i mean for the requirements of 2d game ) ?

if you’re going to use that windowed BufferStrategy example and do it like that, i dont think you can use AWT or Swing components.

With a bit of planning you can make your own classes that manage how the various sprites/tiles/GUI stuff display.

by 2d scene graph i assume you mean a tile map?

it’s not hard to do. Easy way is to have a 2d Tile[][] array (you’ve probably already done this) and in a double for loop, do something like drawImage(tile[i][j], i32, j32, null) (if your tiles are 32x32)

for scrolling tile maps and ones that are larger than the screen you’ll have to make a minor alteration that paints only those tiles that are visible to save on processing power, and just use an X offset and a Y offset, for example, to adjust the location of the tiles.

if you need more detail, just ask.

A 2D scene graph is far more than a simple tile map.

I’ve never come across 1 myself - but then again - i’ve never looked.

My idea of a 2d scene is something similar to the java3d scene graph but with a 3rd coordinate for z ordering of sprites (in screen coordinate system).

I think that having some sort of behaviours like in java3d would be could and maybe 2d positional sound.

It would have have tiles of course, but in a sort of Tile node and probably the possibility for several projections (isometric , top, front, side) to view the maps.

The 2d interface would be a part of the 2d scene graph.

Anyway I have to think better on this since nobody has ever done anything similar for what I have been able to search in the net.