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

class Playfield extends Raster
{
  // Playfield is a raster that contains the background and sprites
	Raster background;
	Sprite[] sprite = new Sprite[10]; //maximum 10 sprites allowed
  
	int numOfSprites=0;
	
	//Constructor
	public Playfield(Image bgnd, int numSprites)
	{
		background = new Raster(bgnd);
		numOfSprites = numSprites;	
	}
	
	public void addSprite(Sprite newSprite)
	{
		if (numOfSprites < 10)
		{
			sprite[numOfSprites] = newSprite;
			numOfSprites++;
		}
		else
		{
		  System.out.println("Can't add any more sprites");
		}
	}
	
	public void Draw()
	{
		pixels = new int[background.pixels.length];

		// we'll start with our playfield being
		// just the background
		System.arraycopy(background.pixels, 0, pixels, 0,
						 background.pixels.length);
	 	width = background.getWidth();
		height = background.getHeight();
		//now add all the sprites
		for (int i = 0; i < numOfSprites; i++)
				sprite[i].Draw(this);
	}
		
	
}
