import java.awt.*;
import java.applet.*;

public class Picture {
   int width, height;
   Image pix;
   JBill2 game;
   
   public Picture() {
      game=null;
   }
   
   public Picture(JBill2 a) {
      game=a;
   }
   
   void draw (Graphics g, int x, int y) {
      g.drawImage(pix,x,y,game);
   }
   void draw_centered (Graphics g) {
      int x = (game.scrwidth-width)/2;
      int y = (game.scrheight-height)/2;
      draw(g,x,y);
   }
   void load(String name) {
      load(name,-1);
   }
   void load(String name, int index) {
      if (index>-1)
	pix=game.getImage(game.getCodeBase(),name+"_"+index+".gif");
      else
	pix=game.getImage(game.getCodeBase(),name+".gif");
      MediaTracker mt = new MediaTracker(game);
      mt.addImage(pix,0);
      game.getToolkit().prepareImage(pix,50,50,game);
      try {
	 mt.waitForAll();
      }
      catch (Exception e) {
      }
      width = pix.getWidth(game);
      height = pix.getHeight(game);
   }
}
