
// Duke.java
// Robert Sedgewick and Kevin Wayne
// Slightly reformatted by Andrew Davison, Nov. 2022

/*
   Draw the sequence of images T1.gif to T17.gif stored in 
   duke/. This creates the illusion of motion, as the Java mascot 
   Duke cart-wheels across the screen.

   Usage:
     > compile Duke.java
     > run Duke

*/

public class Duke
{

  public static void main(String[] args)
  {
    int numImages = 17;  
    int WIDTH = 130, HEIGHT = 80;  // each image is 130-by-80

    StdDraw.setCanvasSize(WIDTH, HEIGHT);
    StdDraw.setXscale(0, WIDTH);
    StdDraw.setYscale(0, HEIGHT);
    StdDraw.enableDoubleBuffering();

    // animation loop
    for (int t = 0; true; t++) {
      int i = 1 + (t % numImages);
      String filename = "duke/T" + i + ".gif";    // name of ith image
      StdDraw.picture(WIDTH/2.0, HEIGHT/2.0, filename);
      StdDraw.show();
      StdDraw.pause(100);
    }
  } /* main */

}  // end of Duke class
