import java.awt.*; import java.applet.*; public class dla extends Applet implements Runnable { int dots=0; int highest=2; boolean place[][]= new boolean[600][600]; int dot[] = new int[2]; boolean baddot=true; int move; boolean stillgood=true; public void init(){ setBackground(Color.black); for(int a=0;a<=599;a++){place[1][a]=true;} } public void start(){ Thread t = new Thread(this); t.start(); } public void paint(Graphics g){ g.setColor(Color.white); for(int a=0;a<=599;a++){ for(int b=0;b<=599;b++){ if(place[a][b]){ g.fillRect(b,600-a,1,1); } } } } public void run() { while(stillgood){ baddot=true; dot[0]=(int)(highest); dot[1]=(int)(Math.random()*595)+3; while(baddot){ move=(int)(Math.random()*4); if(move==0 && dot[0]>1){dot[0]-=1;} if(move==1 && dot[0]<598){dot[0]+=1;} if(move==2 && dot[1]>1){dot[1]-=1;} if(move==3 && dot[1]<598){dot[1]+=1;} if(dot[0]>(highest+5)){baddot=false;} if(place[dot[0]-1][dot[1]] ^ place[dot[0]+1][dot[1]] ^ place[dot[0]][dot[1]-1] ^ place[dot[0]][dot[1]+1]){ baddot=false; place[dot[0]][dot[1]]=true; if(dot[0]>highest){highest=dot[0];} dots++; if(dot[0]==597){stillgood=false;} } } if((dots%1000)==0){ repaint(); try{Thread.sleep(50);} catch(InterruptedException e){} } } } }