home *** CD-ROM | disk | FTP | other *** search
- radius = 50;
- allstillc = 0;
- balls = stone_in_use;
- ii = 1;
- while(balls >= ii)
- {
- if(vx[ii] == 0 and vy[ii] == 0)
- {
- allstillc++;
- }
- jj = ii + 1;
- while(balls >= jj)
- {
- white = eval("_level0.stone" + ii);
- red = eval("_level0.stone" + jj);
- why = zoom_origin_y - white._y;
- rey = zoom_origin_y - red._y;
- dby = - why + rey;
- dbx = - white._x + red._x;
- delta = Math.sqrt(dby * dby + dbx * dbx);
- if(delta < radius)
- {
- white._x -= vx[ii] / 2;
- white._y += vy[ii] / 2;
- realx[ii] -= vx[ii] / 2;
- realy[ii] -= vy[ii] / 2;
- red._x -= vx[jj] / 2;
- red._y += vy[jj] / 2;
- realx[jj] -= vx[jj] / 2;
- realy[jj] -= vy[jj] / 2;
- x1 = white._x;
- y1 = zoom_origin_y - white._y;
- x2 = red._x;
- y2 = zoom_origin_y - red._y;
- angle = Math.atan2(y2 - y1,x2 - x1);
- x1 = vx[ii];
- y1 = vy[ii];
- x2 = vx[jj];
- y2 = vy[jj];
- if(1 < Math.abs(x1) + Math.abs(x2) + Math.abs(y1) + Math.abs(y2))
- {
- collide.gotoandplay("play");
- }
- cma = Math.cos(- angle);
- sma = Math.sin(- angle);
- sa = Math.sin(angle);
- ca = Math.cos(angle);
- nx1 = x1 * cma - y1 * sma;
- ny1 = x1 * sma + y1 * cma;
- nx2 = x2 * cma - y2 * sma;
- ny2 = x2 * sma + y2 * cma;
- nx1 = nx2;
- x1 = nx1 * ca - ny1 * sa;
- y1 = nx1 * sa + ny1 * ca;
- next1x = x1;
- next1y = y1;
- x2 = white._x;
- y2 = zoom_origin_y - white._y;
- x1 = red._x;
- y1 = zoom_origin_y - red._y;
- angle = Math.atan2(y2 - y1,x2 - x1);
- x2 = vx[ii];
- y2 = vy[ii];
- x1 = vx[jj];
- y1 = vy[jj];
- nx1 = x1 * Math.cos(- angle) - y1 * Math.sin(- angle);
- ny1 = x1 * Math.sin(- angle) + y1 * Math.cos(- angle);
- nx2 = x2 * Math.cos(- angle) - y2 * Math.sin(- angle);
- ny2 = x2 * Math.sin(- angle) + y2 * Math.cos(- angle);
- nx1 = nx2;
- x1 = nx1 * Math.cos(angle) - ny1 * Math.sin(angle);
- y1 = nx1 * Math.sin(angle) + ny1 * Math.cos(angle);
- next2x = x1;
- next2y = y1;
- vx[ii] = next1x;
- vy[ii] = next1y;
- vx[jj] = next2x;
- vy[jj] = next2y;
- }
- jj++;
- }
- ii++;
- }
-