void draw(Graphics g,int x,int y){
  if (image == null) {
    image=new BufferedImage(width,height,BufferedImage.TYPE_INT_RGB);
  }
  if (needsRedraw) {
    needsRedraw=false;
    Graphics gr=image.createGraphics();
    drawImage(gr);
    gr.dispose();
  }
  g.drawImage(image,x,y,null);
}

void draw ( Graphics g , int x , int y ) { if ( image == null ) { image = new BufferedImage ( width , height , BufferedImage . TYPE_INT_RGB ) ; } if ( needsRedraw ) { needsRedraw = false ; Graphics gr = image . createGraphics ( ) ; drawImage ( gr ) ; gr . dispose ( ) ; } g . drawImage ( image , x , y , null ) ; }
draw the health bar .
