[java] What API to use for 2D game development?

Started by
5 comments, last by MarcusLM 23 years, 10 months ago
I love Java and I am wanting to experiment with some 2D game edevelopment. My question is what API is best to use for this?? Are people using Java2D for game dev?? Are there other API''s/Libraries out there good for this?? Any suggestions will be appreciated. Thanks. Marcus
Advertisement
Just Use The Regular Java Pain Methods.

public void paint(Graphics g)
{
g.drawString(X,Y,"");
g.drawOval(X,Y,Width,Height);
g.DrawRect(X,Y,Width,Height);
}

And So On...
Expanding on that, if you want to use Java2D, just cast your Graphics instance to Graphics2D, and you''re good to go:

public void paint(Graphics g)
{
Graphics2D g2d = (Graphics2D) g;
...
}

Java2D is really nice, you can do a lot with it. Also, if you subclass a JComponent as your main drawing area, you can get double buffering for free:

public class MyPanel extends JPanel
{
public MyPanel()
{
super();
setDoubleBuffered(true);
...
}

public void paint(Graphics g)
{
super.paint(g);

Graphics2D g2d = (Graphics2D) g;
...
/* paint stuff */
}
}

Here''s a very good Java2D tutorial on Sun''s Java website:

http://java.sun.com/docs/books/tutorial/2d/index.html
I am a Jedi, like my father before me
You can also use OpenGL with Magician or some other interface. But hey, don''t underestimate normal Graphics, because you can do alot of things only with it.

Time comes, time goes and I only am.
And DirectX is an option, even if it''s not a very good option because:

1- The latest version of DirectX that provides Java bindings is DirectX 3.0 (They are now on 7)

2- Microsoft has stated they have no intention of supporting langauges other than VC++ and VB with DirectX.

3- Going over the COM interface that is available for Visual Basic in DirectX 7.0 is full of gotcha''s. You would also pretty much be on your own as very few individuals have tried this.

I''m not sure about further implement of Dirext X for java because Sun and Microsoft made treaty which stops MS raping Java even more so their un platformintependent API is supposingly held, too.

Time comes, time goes and I only am.
If that is true, it sucks! Why are we being denied the choice? I mean I''ve been using pure Java quite happily alongside Microsoft Java in my GF4J library. It is merely the question of understanding what you are doing. You really can make code that runs under both MS Java VM with enhancements and normal Java VM without the bells and whistles.

If Microsoft''s DirectX support in their Java library is pulled out or left dying in the form it is today, it just makes it that much more difficult for us the more open minded game programmers.

But in a more larger scale this is just a thing you can expect to happen when two bone headed giants collide. And it makes me even more interested about what happens after Microsoft gets their videogame console XBox out and notices that they have a "leak" of profits when game programmers publish their games under Windows 2000 or Windows Millenium . Will they offer a DirectX+ version for the XBox or just keep the latest version of DirectX XBox exclusive for half a year at a time?
-Pasi Keranen

This topic is closed to new replies.

Advertisement