• Advertisement


This topic is now archived and is closed to further replies.

[java] images in java games

This topic is 6361 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi i am trying to make a game in java , it is going to be a 2D iso game to be played over the net for FREE. i have been looking at the AWT , java2D , JAI to find the red tread in java image handling, but i cant seem to find it. i really need good advice to the use of images in java. if i use to many features in the 3 API''s , my performance get hanged. thanks Dennis

Share this post

Link to post
Share on other sites
Here''s how to use images in java (in an applet) :
//First delcare an image object (in java.awt.image):
Image img;

//Then in your init method of the applet gif or jpg images...

public void init() {
img = getImage("path/image.gif");
// or .. this gets the image where the code (class file) is.
img = getImage(getCodeBase(),"image.gif");

//then if you want to draw it on the screen...

public void paint(Graphics g) {

In the above code I''m assuming your planning to write an applet (you said "played over the net").
I suggest you use AWT because java2d is not supported on the browers (yet - without the plugin).
For full documentation on AWT go here.
Look for the Graphics class and Image class.

I hoped this helped a little ().

silly programmer vb is for kids.

Share this post

Link to post
Share on other sites

  • Advertisement