import java.awt.Color;
import java.awt.Component;
import java.awt.Image;

import java.awt.image.ImageObserver;
import java.awt.image.MemoryImageSource;
import java.awt.image.PixelGrabber;

class   Sprite 
extends Raster
{
    protected int x; // Position of the sprite in the PlayField
	protected int y; // Position of the sprite in the PlayField

    /**
     *  This constructor which takes no arguments
     *  allows for future extension.
     */
    public Sprite() 
	{
    }


    /**
     *  This constructor creates an uninitialized
     *  Raster Object of a given size (w x h).
     */
    public Sprite( int w, int h )
	{
		super( w, h );
    }


    /**
     *  This constructor creates an Raster initialized
     *  with the contents of an image.
     */
    public Sprite( Image img )
    {
		super( img );
    }


    /**
     *  Draw the sprite on the input raster.
     */
    public void
	draw( Raster raster )
    {
		for ( int i=0; i<height; i++ ) {
			for( int j=0; j<width; j++ ) {
				if ( !isTransparent( pixel[i*width+j] ) ) {
					raster.setPixel( pixel[i*width+j], x+j, y+i );
				}
			}
		}
    }


    /**
     *  Test if the pixel is transparent. White pixels are 
	 *  assumed to be transparent.
     */
    public boolean
	isTransparent( int pixel )
    {
		if ( pixel == 0x00FFFFFF ) {
			return true;
		} else {
			return false;
		}
    }
}
