import java.applet.*; import java.awt.*; public class blocks extends Applet { int width,height; Graphics bg; Image buf; Font font=new Font("TimesRoman",Font.BOLD,56); FontMetrics fm; Color[] clr={new Color(224,0,0),new Color(0,224,0),new Color(0,0,224), new Color(255,224,0),new Color(224,0,224),new Color(0,224,224), new Color(0,00,128),new Color(255,120,0)}; Color bgclr=new Color(255,224,160); Color faceclr=new Color(224,160,92); Color topclr=new Color(180,120,92); Color sideclr=new Color(160,100,60); int[] xi,yi,t; int n=24,ii,xold,yold,xoff,yoff; int bw=60,xleft=60,ytop=60; String letters ="ABCDEFGHIJKLMNOPQRSTVWXY"; public blocks() { } public String getAppletInfo() { return "Name: blocks\r\n" + "Author: Bob Roesser\r\n"; } public void init() { width=Integer.parseInt(getParameter("width")); height=Integer.parseInt(getParameter("height")); xi=new int[n]; yi=new int[n]; t=new int[n]; buf=createImage(width,height); bg=buf.getGraphics(); bg.setFont(font); fm=bg.getFontMetrics(); for(int i=0;ixi[t[i]])){ if(xi[t[i-1]]-yi[t[i-1]]>xi[t[i]]-yi[t[i]]){ int j=t[i]; t[i]=t[i-1]; t[i-1]=j; mark=true;}}} bg.setColor(bgclr); bg.fillRect(0,0,width,height/3); bg.setColor(bgclr.darker()); bg.fillRect(0,height/3,width,2*height/3); for(i=0;ixi[i]-bw/2&&xyi[i]-bw/2&&y=0){ xoff=x-xi[ii]; yoff=y-yi[ii]; xold=x; yold=y;} return true; } public boolean mouseUp(Event evt, int x, int y){ if(ii>=0){ xi[ii]=x-xoff; yi[ii]=y-yoff; repaint(); xold=x; yold=y;} return true; } public boolean mouseDrag(Event evt, int x, int y){ if(ii>=0){ int xx=x-xoff,yy=y-yoff,i,iii=ii; boolean mark=true; // while(mark){ mark=false; for(i=0;ixi[i]-bw&&xxyi[i]-bw&&yy