import java.awt.image.*;
import java.awt.*;

public class Sprite extends Raster
{
  int x, y;           // current position of sprite on playfield
  
  public Sprite(Image image)
    {		
      super(image);
      
      x = 0;
      y = 0;
    }
	
	
  public void Draw(Raster bgnd)
    {		// draws sprite on a Raster	}
      
      if((x+this.width+11)>=bgnd.width)
	this.setPosition(this.x-this.width-12,this.y);
      
      if((y+this.height)>= bgnd.height)
	this.setPosition(this.x,this.y-11-this.height);
      
      if(y-10<=0)
	this.setPosition(this.x,this.y+11);
      
      if(x-10<=0)
	this.setPosition(this.x+11, this.y);
      
      for (int i=0; i<this.width; i++)
	{
	  for (int j=0; j<this.height; j++)
	    {
	      if((getPixel(i,j) & 0xff000000) != 0)
		bgnd.setPixel(this.getPixel(i,j), i+x, j+y);
	    }		
	}
      
    }
	
  public boolean isNotTransparent(int x, int y)
    {
      if(this.height<y || this.width<x)
	return true;
      
      if(y<0 || x<0)
	return true;
      
      if((getPixel(x,y) & 0xff000000) == 0)
	return false;
      return true;
    }
	
                   
  public void setPosition(int xpos, int ypos)
    {
      x = xpos;
      y = ypos;
    }
	
}

