views:

146

answers:

4

I want to write a small java game (snake like game) but im not sure what graphics library to use. Ive heard about SWT and Swing and I have a little bit of experience with both but I dont know what is best for a simple 2D game... what do you recommend?

thanks :)

A: 

these 2 libraries are used for creating GUI's (graphical user interfaces). So things like buttons, listboxes etc.

for a 2d game you probably want buttons and GUI elements with a custom look.

For the game itself, you need to use the graphics classes of java (Image, Graphics, etc) to draw the snake and all other things to the screen.

Toad
A: 

Since you are talking about simple games as in Snake (not MGS Snake :-), then it should suffice to use a plain canvas/JPanel which you can draw on using the Graphics object. Nothing more is needed really.

In case you are doing something more with your game and it need to scroll for instance, I suggest you start looking into a tile based framework. That really helps when designing levels and such.

Martin Wickman
+1  A: 

The Lightweight Java Game Library looks nice.

stacker
thanks! that looks like what i wasb searching!
APT
+3  A: 

Have a look at Slick 2D which is made exactly for cases like you have. Have a look at the WebStart Demos to see whats possible with Slick. Besides Graphcis things, it also provides implementations for common needed techniques and algorithms like A*.

Good luck with your project! :-)

Malax
+1 for the a* support
stacker
Slick is very easy to work with +1
Stefan Hendriks