import AnimatedSprite;
import Raster;
import java.awt.*;
import java.awt.image.*;

class Playfield extends Raster {
  Raster background; // background image
  Sprite spritelist[]; // list of sprites on this playfield
         
  // constructor

  public Playfield(Image bgnd, int numSprites) {
    super(bgnd);
    background = new Raster(bgnd);
    spritelist = new Sprite[numSprites];
  } // end constructor

  // methods

  public void addSprite(int i, Sprite s) {
    spritelist[i] = s;
  } // end addSprite

  public void Draw() {
    for (int i = 0; i < this.height; i++) {
	for (int j = 0; j < this.width; j++) {
	    setPixel(background.getPixel(j, i), j, i);
	    }
	}
    for (int i = 0; i < spritelist.length; i++) {
      spritelist[i].Draw(this);
    }
    //return this.toImage();
  } // end Draw

  public Image returnImage() {
    this.Draw();
    return this.toImage();
  }
  
} // end Playfield

