import java.awt.*;

public class AnimatedSprite extends Sprite
{
	private int curr_frame = 0;
	private int num_frames = 0;
	private int max_frames = 10;
	private Image frames[] = new Image[max_frames];

	//***********************************************************
	//Constructors
	//***********************************************************
    // This constructor which takes no arguments allows for future extension.
    public AnimatedSprite()
    {
    }

    // This constructor creates an asprite initialized with the contents of an image.
    public AnimatedSprite(Image img, int x_start, int y_start)
    {
		//Init the asprite with the first frame and set the current frame to 0
		super(img, x_start, y_start);
		frames[0] = img;
		num_frames = 1;
		curr_frame = 0;
    }

	//Increments the number of frames in the asprite
	public void AddFrame(Image img)
	{
		//Check the bounds
		if (num_frames < max_frames)
		{
			//Increment the frames and add to the array
			num_frames += 1;
			frames[num_frames-1] = img;
		}
	}

	//Sets the active frame to the next in the series
	public void NextFrame()
	{
		curr_frame += 1;		
		if (curr_frame >= num_frames)
			curr_frame = 0;
		
		//This is the call that required me to extend the definition of the Raster
		this.fillImage(frames[curr_frame]);
	}
}
