开发者

how to make a drawing buffer in java

I'm new to java. and I want to create a game like snake. Ho开发者_StackOverfloww can I make a drawing buffer java, where I can draw all the images? Like the background images, the objects such as the snake, etc.

Please advise.

Many thanks.


you have to look at official tutorials 2D Graphics and Performing Custom Painting, tons of examples here


You can use a BufferedImage if CPU-based drawing is good enough for you. Rendering using BufferedImage is pretty easy by utilizing the Graphics2D class.

However, if you need full graphics acceleration, then I would suggest looking into some OpenGl binding for java, like JOGL or LWGL, or maybe even Java3D. I'm not personally familiar with these technologies, but from what I understand, they are all pretty popular portals for game programming in Java.


The exact term you are looking for is "canvas".
Here is an example: http://www.java2s.com/Code/Java/2D-Graphics-GUI/Drawcanvaswithcolorandtext.htm

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜