package uk.co.patrickhaston.mars;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Toolkit;

public class MarsFace extends MarsType 
{
  private MarsFaceImage image = null;
  // the image of the item

  public MarsFace(int id)
  {
    super(id);
  }
  
  public MarsFace(MarsFace f)
  {
    super(f);
    if(f != null)
    {
      image = f.image;
    }
    else
    {
      image = null;
    }
  }
  
  public MarsFace(String line, MarsModel model)
  {
    super(line);
    if( this.getName().length() > 4)
    {
      // find the image on the directory
      Toolkit toolkit = Toolkit.getDefaultToolkit();
      // get the image from disk
      Image i = toolkit.getImage(
        model.applicationDirectory + "\\" + model.imageDirectory +
        "\\" + getName() + ".gif");
      // add it to this class
      image = new MarsFaceImage(i, model.theFrame);
      // add the image to the media tracker to speed up drawing
      model.mediaTracker.addImage(i, 1);
    }
  }
  
  public void paintAt(Graphics g, int x, int y, int mood)
  {
    if(image!= null)
    {
      image.paintAt(g, x, y, mood);
    }
  }
  
}
