domlao
domlao

Reputation: 16029

how to make a drawing buffer in java

I'm new to java. and I want to create a game like snake. How 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.

Upvotes: 0

Views: 1391

Answers (3)

mKorbel
mKorbel

Reputation: 109815

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

Upvotes: 3

Ken Wayne VanderLinde
Ken Wayne VanderLinde

Reputation: 19339

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.

Upvotes: 2

Artium
Artium

Reputation: 5329

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

Upvotes: 1

Related Questions