import java.applet.*; import java.awt.*; import java.awt.image.*; public class HW extends Applet implements Runnable { int i,j,k; int bw, bh; int piex, piey; int numBirds, numCrowds, delay; int bellsh, beadsh, crowdh, piew, pieh, candlew, candleh, gobletw, gobleth, candley, goblety; int[] fArr, fbArr; int[][] bArr; Image[] birds, frosts, crowds; Image beads, bells, crowd, pie, goblet, candle; Image bigImg; Graphics ag,bg; Thread anim = null; MediaTracker mt; Applet thisApplet; MemoryImageSource mis; public void init() { thisApplet = this; numBirds = Integer.parseInt(this.getParameter("numBirds"),10); numCrowds = Integer.parseInt(this.getParameter("numCrowds"),10); mt = new MediaTracker(this); birds = new Image[numBirds]; for(k = 0; k < numBirds; k++) { birds[k]=getImage(getDocumentBase(),"birds/b"+k+".jpeg"); mt.addImage(birds[k], k); } crowds = new Image[numCrowds]; for(k = 0; k < numCrowds; k++) { crowds[k]=getImage(getDocumentBase(),"crowds/c"+k+".gif"); mt.addImage(crowds[k], numBirds+k); } frosts = new Image[numBirds]; for(k = 0; k < numBirds; k++) { frosts[k]=getImage(getDocumentBase(), "frosts/b"+ (k<10?"0":"") +k+".jpeg"); mt.addImage(frosts[k], numBirds+numBirds+k); } beads = getImage(getDocumentBase(), "borders/beads.gif"); mt.addImage(beads, 2*numBirds+numCrowds); bells = getImage(getDocumentBase(), "borders/bells.gif"); mt.addImage(bells, 2*numBirds+numCrowds+1); crowd = getImage(getDocumentBase(), "borders/crowd.gif"); mt.addImage(crowd, 2*numBirds+numCrowds+2); pie = getImage(getDocumentBase(), "borders/pie.gif"); mt.addImage(pie, 2*numBirds+numCrowds+3); candle = getImage(getDocumentBase(), "borders/candle.gif"); mt.addImage(candle, 2*numBirds+numCrowds+4); goblet = getImage(getDocumentBase(), "borders/goblet.gif"); mt.addImage(goblet, 2*numBirds+numCrowds+5); piex = Integer.parseInt(this.getParameter("piex"),10); piey = Integer.parseInt(this.getParameter("piey"),10); candley = Integer.parseInt(this.getParameter("candley"),10); goblety = Integer.parseInt(this.getParameter("goblety"),10); delay = Integer.parseInt(this.getParameter("delay"),10); bigImg = this.createImage(240,320); bw = bigImg.getWidth(this); bh = bigImg.getHeight(this); bArr = new int[numBirds][bw*bh]; fArr = new int[bw*bh]; fbArr = new int[bw*bh]; ag = this.getGraphics(); bg = bigImg.getGraphics(); } public void paint(Graphics g) { g.drawImage(bigImg, 0,0, this); } public void update(Graphics g) { paint(g); } public void start() { if(anim==null) { anim = new Thread(this); anim.start(); } } public void stop() { if ((anim!=null) && anim.isAlive()) anim.stop(); anim = null; } public void run() { for (int k = 1; k <= 2*numBirds + numCrowds + 6; k++) { this.showStatus("Loading image " + k + " of " + Integer.toString(2*numBirds+numCrowds+6)); try { mt.waitForID(k-1); } catch (InterruptedException e) {;} if (mt.isErrorID(k-1)) { this.showStatus("Barfed on image " + k + "; quitting."); return; } } this.showStatus("Images loaded."); bellsh = bells.getHeight(thisApplet); beadsh = beads.getHeight(thisApplet); crowdh = crowd.getHeight(thisApplet); // those widths =240 pieh = pie.getHeight(thisApplet); piew = pie.getWidth(thisApplet); candlew = candle.getWidth(thisApplet); candleh= candle.getHeight(thisApplet); gobletw = goblet.getWidth(thisApplet); gobleth = goblet.getHeight(thisApplet); while(true) { frostf(); bbccpgc(); } } void birdsf() { for (int b=0; b