/**  This is my AnimatedSprite class.
 *
 */

import java.io.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import Raster;

class AnimatedSprite
{
   public int current_state, num_states;
   Sprite[] sprites;

   public AnimatedSprite( Image[] images)
   {
      current_state = 0;
      num_states = images.length;
      sprites = new Sprite[ num_states];

      for (int i = 0; i < num_states; i++)
      {
         sprites[i] = new Sprite( images[i]);
         //System.out.println("image " + i + "inited");
      }
   }

   public int getHeight() {
      return sprites[ current_state].getHeight();
   }

   public int getWidth() {
      return sprites[ current_state].getWidth();
   }

   public void Draw( Raster bg, int x, int y, int x_top_pixels, int state) {
      //System.out.println("AnimatedSprite: state is " + state + "; x_top is " + x_top_pixels);
      current_state = state;
      sprites[ state].Draw( bg, x, y, x_top_pixels);
   }

/*   public void Draw( Raster bg, int x, int y, int x_top_pixels) {
      sprites[ current_state].Draw( bg, x, y, x_top_pixels);
   }
*/
   public void Draw( Raster bg, int x, int y, int state) {
      sprites[ state].Draw( bg, x, y, sprites[state].getHeight());
   }

   public void Draw( Raster bg) {
      sprites[ current_state].Draw( bg, sprites[current_state].x, sprites[current_state].y,
                                    sprites[current_state].getHeight());
   }

   public void nextState() {
      if (current_state < (num_states-1))
         current_state++;
   }
}
