if (x ==-1) return; y = popy(); if (!inParticle(x,y,level1,level2)) continue; int x1 = x; int x2 = x; while (inParticle(x1,y,level1,level2) && x1>=0) x1--; // find start of scan-line x1++; while (inParticle(x2,y,level1,level2) && x2<width) x2++; // find end of scan-line x2--; if (x1>0) x1--; if (x2<width-1) x2++; for (int i=x1; i<=x2; i++) { // find scan-lines above this one if (!inScanLine && y>0 && inParticle(i,y-1,level1,level2)) {push(i, y-1); inScanLine = true;} else if (inScanLine && y>0 && !inParticle(i,y-1,level1,level2)) inScanLine = false; if (!inScanLine && y<height-1 && inParticle(i,y+1,level1,level2)) {push(i, y+1); inScanLine = true;} else if (inScanLine && y<height-1 && !inParticle(i,y+1,level1,level2)) inScanLine = false;
if (x ==-1) return; y = popy(); if (!inParticle(x,y,level1,level2)) continue; int x1 = x; int x2 = x; while (inParticle(x1,y,level1,level2) && x1>=0) x1--; // find start of scan-line x1++; while (inParticle(x2,y,level1,level2) && x2<width) x2++; // find end of scan-line x2--; if (x1>0) x1--; if (x2<width-1) x2++; for (int i=x1; i<=x2; i++) { // find scan-lines above this one if (!inScanLine && y>0 && inParticle(i,y-1,level1,level2)) {push(i, y-1); inScanLine = true;} else if (inScanLine && y>0 && !inParticle(i,y-1,level1,level2)) inScanLine = false; if (!inScanLine && y<height-1 && inParticle(i,y+1,level1,level2)) {push(i, y+1); inScanLine = true;} else if (inScanLine && y<height-1 && !inParticle(i,y+1,level1,level2)) inScanLine = false;