do{ boolean goOnMakeDirection; do { makeDirection(); //System.out.println("direction="+direction);
int j=0; for(j=0;j<4;j++){ if(direction==text[j]) break;} if(j==4) goOnMakeDirection=false; else goOnMakeDirection=true;
} while(goOnMakeDirection);
switch(direction) { case 0:rightDir=rightDirection(x,y-1,x,y-2);text[0]=0;break; case 1:rightDir=rightDirection(x,y+1,x,y+2);text[1]=1;break; case 2:rightDir=rightDirection(x-1,y,x-2,y);text[2]=2;break; case 3:rightDir=rightDirection(x+1,y,x+2,y);text[3]=3;break; }
//************************************ private void addNewDotCom(){//根据给定的坐标和方向,添加3个连续的坐标 locations[x][y]=-1; switch(direction) { case 0:locations[x][y-1]=-1;locations[x][y-2]=-1;break; case 1:locations[x][y+1]=-1;locations[x][y+2]=-1;break; case 2:locations[x-1][y]=-1;locations[x-2][y]=-1;break; case 3:locations[x+1][y]=-1;locations[x+2][y]=-1;break; }