home *** CD-ROM | disk | FTP | other *** search
/ 600 Games / 600games.iso / Esportes / VirtualCurling.swf / scripts / frame_135 / DoAction.as
Encoding:
Text File  |  2005-08-08  |  2.4 KB  |  84 lines

  1. radius = 50;
  2. allstillc = 0;
  3. balls = stone_in_use;
  4. ii = 1;
  5. while(balls >= ii)
  6. {
  7.    if(vx[ii] == 0 and vy[ii] == 0)
  8.    {
  9.       allstillc++;
  10.    }
  11.    jj = ii + 1;
  12.    while(balls >= jj)
  13.    {
  14.       white = eval("_level0.stone" + ii);
  15.       red = eval("_level0.stone" + jj);
  16.       why = zoom_origin_y - white._y;
  17.       rey = zoom_origin_y - red._y;
  18.       dby = - why + rey;
  19.       dbx = - white._x + red._x;
  20.       delta = Math.sqrt(dby * dby + dbx * dbx);
  21.       if(delta < radius)
  22.       {
  23.          white._x -= vx[ii] / 2;
  24.          white._y += vy[ii] / 2;
  25.          realx[ii] -= vx[ii] / 2;
  26.          realy[ii] -= vy[ii] / 2;
  27.          red._x -= vx[jj] / 2;
  28.          red._y += vy[jj] / 2;
  29.          realx[jj] -= vx[jj] / 2;
  30.          realy[jj] -= vy[jj] / 2;
  31.          x1 = white._x;
  32.          y1 = zoom_origin_y - white._y;
  33.          x2 = red._x;
  34.          y2 = zoom_origin_y - red._y;
  35.          angle = Math.atan2(y2 - y1,x2 - x1);
  36.          x1 = vx[ii];
  37.          y1 = vy[ii];
  38.          x2 = vx[jj];
  39.          y2 = vy[jj];
  40.          if(1 < Math.abs(x1) + Math.abs(x2) + Math.abs(y1) + Math.abs(y2))
  41.          {
  42.             collide.gotoandplay("play");
  43.          }
  44.          cma = Math.cos(- angle);
  45.          sma = Math.sin(- angle);
  46.          sa = Math.sin(angle);
  47.          ca = Math.cos(angle);
  48.          nx1 = x1 * cma - y1 * sma;
  49.          ny1 = x1 * sma + y1 * cma;
  50.          nx2 = x2 * cma - y2 * sma;
  51.          ny2 = x2 * sma + y2 * cma;
  52.          nx1 = nx2;
  53.          x1 = nx1 * ca - ny1 * sa;
  54.          y1 = nx1 * sa + ny1 * ca;
  55.          next1x = x1;
  56.          next1y = y1;
  57.          x2 = white._x;
  58.          y2 = zoom_origin_y - white._y;
  59.          x1 = red._x;
  60.          y1 = zoom_origin_y - red._y;
  61.          angle = Math.atan2(y2 - y1,x2 - x1);
  62.          x2 = vx[ii];
  63.          y2 = vy[ii];
  64.          x1 = vx[jj];
  65.          y1 = vy[jj];
  66.          nx1 = x1 * Math.cos(- angle) - y1 * Math.sin(- angle);
  67.          ny1 = x1 * Math.sin(- angle) + y1 * Math.cos(- angle);
  68.          nx2 = x2 * Math.cos(- angle) - y2 * Math.sin(- angle);
  69.          ny2 = x2 * Math.sin(- angle) + y2 * Math.cos(- angle);
  70.          nx1 = nx2;
  71.          x1 = nx1 * Math.cos(angle) - ny1 * Math.sin(angle);
  72.          y1 = nx1 * Math.sin(angle) + ny1 * Math.cos(angle);
  73.          next2x = x1;
  74.          next2y = y1;
  75.          vx[ii] = next1x;
  76.          vy[ii] = next1y;
  77.          vx[jj] = next2x;
  78.          vy[jj] = next2y;
  79.       }
  80.       jj++;
  81.    }
  82.    ii++;
  83. }
  84.