import java.awt.*; // I added this

/*
 * CharacterNode has a picture for a given character.
 * Don't ever try to traverse this one!
 */
public class CharacterNode extends LLNode {
  /**
   * The picture I'm associated with
   */
  private Picture myPict;
  
  /*
   * Make me with this picture
   * @param pict the Picture I'm associated with
   */
  public CharacterNode(Picture pict) {
    super(); // Call superclass constructor
    myPict = pict;
  }
  
  /**
   * Don't try to remove() from a circular list!
   */
  public void remove(LLNode node) {
    System.out.println("Very dangerous to try to remove a node from this list!");
  }
  
  /**
   * Don't try to get the last() from a circular list!
   * @return the current node
   */
  public LLNode last() {
    System.out.println("Don't try to find last() from a circular list!");
    return this;
  }
  
  /**
   * Method to return a string with informaiton 
   * about this node
   */
  public String toString() {
    return "CharacterNode with picture: " + myPict;
  }
  
  /*
   * Use the given turtle to draw oneself
   * @param turtle the Turtle to draw with
   */
  public void drawWith(Turtle turtle) {
    // Assume that we're at the lower-left corner
    turtle.setHeading(0); 
    turtle.forward(myPict.getHeight());
    Picture bg = turtle.getPicture();
    myPict.blueScreen(bg,turtle.getXPos(),turtle.getYPos());
  }
  
    /*
   * Use the given turtle to draw oneself
   * @param turtle the Turtle to draw with
   */
  public void drawWith(Turtle turtle, Color back) {
    // Assume that we're at the lower-left corner
    turtle.setHeading(0); 
    turtle.forward(myPict.getHeight());
    Picture bg = turtle.getPicture();
    myPict.chromakey(bg,back,50,
                     turtle.getXPos(),turtle.getYPos());
  }
  public static void main(String[] args){
    // Set up frame player
    FrameSequencer frames = new FrameSequencer("C:/Temp/");
    frames.show();
    
    // Set up the CharacterNode list
    Picture p = new Picture("C:/Users/MarkGuzdial/Desktop/Wing/wing1.png");
    CharacterNode node1 = new CharacterNode(p);
    p = new Picture("C:/Users/MarkGuzdial/Desktop/Wing/wing2.png");
    CharacterNode node2 = new CharacterNode(p);
    p = new Picture("C:/Users/MarkGuzdial/Desktop/Wing/wing3.png");
    CharacterNode node3 = new CharacterNode(p);
    p = new Picture("C:/Users/MarkGuzdial/Desktop/Wing/wing4.png");
    CharacterNode node4 = new CharacterNode(p);
    node1.setNext(node2); node2.setNext(node3);
    node3.setNext(node4); node4.setNext(node1);
    
    // Let's make the character fly
    Picture bg;
    Turtle position;
    CharacterNode current = node1;
    for (int i=0; i < 60; i++){
      // Get frame
      bg = new Picture(480,300);
      // Position the sprite
      position = new Turtle(bg); position.penUp();
      position.moveTo(i*5,
                      (int)((i*5)+(Math.sin(i)*5)));
      //current.drawWith(position);
      current.drawWith(position,new Color(133,217,234));
      
      // Add to frame sequence
      frames.addFrame(bg);
      
      // Go to next frame
      current = (CharacterNode)(current.getNext());
    }
  }
}
