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

class AnimatedSprite extends Sprite {
  private int frameX = 0;         //  upper left corner of current frame 
  private int frameY = 0;         //  w/in the entire source image
/*  Note:  assumes "images" is a horizontal series of frames, and  */
/*  all frames have equal width (frameW) and height (frameH). */
  private int frameW, frameH;


  public AnimatedSprite(Image images, int numframes)
  {
    super(images);
    this.frameH = this.getHeight();
    this.frameW = (int) (this.getWidth() / numframes);
  } // end constructor


    //  public void addState(int track, int frame, int ticks, int dx, int dy);


/*  Must handle transparent pixels, and must also handle  */
/*  all cases where the sprite overhangs the playfield.   */
  public void Draw(Raster bgnd)
  {
    super.Draw(bgnd, frameH, frameW, frameX, frameY);
  }

public boolean clickedOn(int Xclick, int Yclick, Raster bgnd)
  {
    return (super.clickedOn(Xclick, Yclick, bgnd, 
			    frameH, frameW, frameX, frameY));
  }

  public void nextState(int dx, int dy)
  {
    this.MoveRel(dx, dy);
    frameX += frameW;
    if (frameX >= this.getWidth())  frameX=0;   // repeat sequence
  }

  // public void setTrack();

} // end AnimatedSprite class

 
/* ---------
class AnimatedSprite extends Sprite {
     int frames; // frames in sprite
 // there are other private variables
 
     public AnimatedSprite(Image images, int frames);
     public void addState(int track, int frame, int ticks, int dx, int dy);
     public void Draw(Raster bgnd);
     public void nextState();
     public void setTrack();
 }
 
-------- */
