Advertisement

[java] images in java games

Started by August 24, 2000 01:39 AM
0 comments, last by pekkert 24 years, 4 months ago
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
Hello;
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) {   g.drawImage(img,x,y,null);}    


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.
============================
www.thejpsystem.com
==============================================I feel like a kid in some kind of store... ============================================== www.thejpsystem.com

This topic is closed to new replies.

Advertisement