package uk.co.patrickhaston.pdhsprites;
import java.applet.Applet;
import java.awt.Component;
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.Image;

public class PdhBitmapSprite extends PdhSprite 
{
  /**
   * Contents
   */
  protected int locx;
  protected int locy;
  
  // image dimensions
  protected int width, height;
  
  // the bitmap
  protected Image image;
  
  // where the image will get drawn
  protected Component component;
  
  /**
   * Constructors
   */
  public PdhBitmapSprite()
  {
    super();
    image = null;
  }
  
  public PdhBitmapSprite(int x, int y, Image i, Component c)
  {
    super();
    locx = x;
    locy = y;
    image = i;
    component = c;
    restore();
  }

  /**
   * Methods
   */
  // Setup
  public void setup(int x, int y, Image i, Component c)
  {
    locx = x;
    locy = y;
    image = i;
    component = c;
    restore();
  }
   
  // set the size of the bitmap
  public void setSize(int w, int h)
  {
    width = w;
    height = h;
  }
  
  public void update()
  {
    // do nothing
  }
  
  public void paint(Graphics g)
  {
    if(visible)
    {
      g.drawImage(image, locx, locy, component);
    }
  }
  
  public void paintAt(Graphics g, int x, int y)
  {
    if(visible)
    {
      g.drawImage(image, x, y, component);
    }
  }

  public void paintAt(Graphics g, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2)
  {
    if(visible)
    {
      g.drawImage(image, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, component);
    }
  }
  
  public Component getComponent()
  {
    return component;
  }
}
