import java.applet.*; import java.awt.*; import java.net.*; import java.util.*; public class Animator extends Applet implements Runnable { protected int numImgs; // number of images protected Image[] imgs; // Array of 64ish images protected int frameNum; // Current frame number protected MediaTracker mt; protected Thread movieThread = null; // The thread for animation Movie[] cube; public class Movie { int which; // Movie frames in chrono order: value of "which" is // which of the images in imgs to show for this frame int time; // time for each frame to be displayed public Movie(int which, int time) { this.which = which; this.time = time; } public Movie() { this.which = 0; this.time = 0; } } public void init() { String prefix = "imgs/Untitled-"; String suffix = ".jpg"; numImgs = 86; int i,j; // _i_ goes from 2 to 87, which are the images. imgs and the mt // will have 0 through 85, I guess. mt = new MediaTracker(this); imgs = new Image[numImgs]; for(i = 2; i < numImgs+2; i++) { imgs[i-2] = this.getImage(this.getDocumentBase(), prefix+i+suffix); mt.addImage(imgs[i-2], i-2); } cube = new Movie[600]; frameNum = 0; for (j=0; j<3; j++) { //sunrise, sunset, night for (i=0; i<8; i++) cube[frameNum++] = new Movie(85-i,100+50*(8-i)); // 85 to 54 for (i=8; i<32; i++) cube[frameNum++] = new Movie(85-i,100); // 85 to 54 for (i=0; i<26; i++) cube[frameNum++] = new Movie(22+i,100); // 22 to 52 for (i=26; i<31; i++) cube[frameNum++] = new Movie(22+i,100+20*(i-26)); // 22 to 52 cube[frameNum++] = new Movie(53,100*32); // 53 } //sunrise for (i=0; i<8; i++) cube[frameNum++] = new Movie(85-i,100+50*(8-i)); // 85 to 54 for (i=8; i<32; i++) cube[frameNum++] = new Movie(85-i,100); // 85 to 54 //littlebounce for (i=0; i<4; i++) cube[frameNum++] = new Movie(i,f(4-i)); for (i=4; i>0 ; i--) cube[frameNum++] = new Movie(i,f(4-i)); cube[frameNum++] = new Movie(0,1000); //mediumbounce for (i=0; i<10; i++) cube[frameNum++] = new Movie(i,f(10-i)); for (i=10; i>0; i--) cube[frameNum++] = new Movie(i,f(10-i)); cube[frameNum++] = new Movie(0,1000); for (j=0; j<5; j++) { //bigbounce for (i=0; i<21; i++) cube[frameNum++] = new Movie(i,f(21-i)); for (i=21; i>0; i--) cube[frameNum++] = new Movie(i,f(21-i)); } cube[frameNum++] = new Movie(0,2000); //littlebounce for (i=0; i<4; i++) cube[frameNum++] = new Movie(i,f(4-i)); for (i=4; i>0 ; i--) cube[frameNum++] = new Movie(i,f(4-i)); //sunset, night for (i=0; i<10; i++) cube[frameNum++] = new Movie(22+i,100+50*(10-i)); // 22 to 52 for (i=10; i<26; i++) cube[frameNum++] = new Movie(22+i,100); // 22 to 52 for (i=26; i<31; i++) cube[frameNum++] = new Movie(22+i,100+20*(i-26)); // 22 to 52 cube[frameNum++] = new Movie(53,75*32); // 53 //sunrise, sunset, night for (i=0; i<8; i++) cube[frameNum++] = new Movie(85-i,100+50*(8-i)); // 85 to 54 for (i=8; i<32; i++) cube[frameNum++] = new Movie(85-i,100); // 85 to 54 for (i=0; i<26; i++) cube[frameNum++] = new Movie(22+i,100); // 22 to 52 for (i=26; i<31; i++) cube[frameNum++] = new Movie(22+i,100+20*(i-26)); // 22 to 52 cube[frameNum++] = new Movie(53,100); // 53 for (i=frameNum; i= cube.length) frameNum = 0; repaint(); try { Thread.sleep(cube[frameNum].time); } catch (InterruptedException e) { ; } } } }