home *** CD-ROM | disk | FTP | other *** search
/ GameStar 2003 December (Special) / Gamestar-Special_2003-12_cd.bin / Arkady / arcanoid_gy.exe / scripts / frame_6 / DoAction.as
Text File  |  2002-11-22  |  13KB  |  535 lines

  1. function AddString()
  2. {
  3.    i = 0;
  4.    while(i < 12)
  5.    {
  6.       j = 14;
  7.       while(j >= 0)
  8.       {
  9.          field[(j + 1) * 12 + i] = field[j * 12 + i];
  10.          field[j * 12 + i] = 0;
  11.          if(field[(j + 1) * 12 + i] != 0)
  12.          {
  13.             removeMovieClip("x" + i + "y" + j);
  14.             attachMovie(word + field[(j + 1) * 12 + i],"x" + i + "y" + (j + 1),(j + 1) * 12 + i);
  15.             tellTarget("x" + i + "y" + (j + 1))
  16.             {
  17.                _X = 22 + _parent.i * 38 + _width / 2;
  18.                _Y = 20 + (_parent.j + 1) * 20 + _height / 2;
  19.             }
  20.          }
  21.          j--;
  22.       }
  23.       i++;
  24.    }
  25.    j = 0;
  26.    i = 0;
  27.    while(i < 6)
  28.    {
  29.       field[j * 12 + i] = GenerateBlock();
  30.       field[j * 12 + 11 - i] = field[j * 12 + i];
  31.       if(0 < field[j * 12 + i])
  32.       {
  33.          brickname = word + field[j * 12 + i];
  34.          attachMovie(brickname,"x" + i + "y" + j,j * 12 + i);
  35.          attachMovie(brickname,"x" + (11 - i) + "y" + j,j * 12 + 11 - i);
  36.          tellTarget("x" + i + "y" + j)
  37.          {
  38.             _X = 22 + _parent.i * 38 + _width / 2;
  39.             _Y = 20 + _parent.j * 20 + _height / 2;
  40.          }
  41.          tellTarget("x" + (11 - i) + "y" + j)
  42.          {
  43.             _X = 22 + (11 - _parent.i) * 38 + _width / 2;
  44.             _Y = 20 + _parent.j * 20 + _height / 2;
  45.          }
  46.       }
  47.       i++;
  48.    }
  49.    parity_flag = !parity_flag;
  50.    last_string++;
  51.    if(last_string >= 13)
  52.    {
  53.       gotoAndPlay(10);
  54.    }
  55. }
  56. br = 0;
  57. Platform._width = plat_width;
  58. i = 0;
  59. while(i < 12)
  60. {
  61.    if(field[last_string * 12 + i] != 0)
  62.    {
  63.       br++;
  64.    }
  65.    i++;
  66. }
  67. if(br == 0)
  68. {
  69.    last_string--;
  70. }
  71. Date2 = new Date();
  72. if(Aseconds < Math.abs(Date2 - Date1))
  73. {
  74.    platform_vh = 0;
  75. }
  76. if(begin_flag)
  77. {
  78.    Ball._x = Platform._x;
  79.    Ball._y = Platform._y - Ball._Height;
  80. }
  81. else
  82. {
  83.    Ball._x += vx;
  84.    Ball._y += vy;
  85.    if(Ball._x < left)
  86.    {
  87.       was_beat_flag = false;
  88.       if(sound_flag)
  89.       {
  90.          Sound2.start();
  91.       }
  92.       push_flag = false;
  93.       if(abs_vx < Math.abs(vx))
  94.       {
  95.          vx += 1;
  96.       }
  97.       if(vy < - abs_vy - 1)
  98.       {
  99.          vy += 1;
  100.       }
  101.       else if(abs_vy + 1 < vy)
  102.       {
  103.          vy -= 1;
  104.       }
  105.       vx = Math.abs(vx);
  106.       Ball._x = left;
  107.    }
  108.    else if(right < Ball._x)
  109.    {
  110.       was_beat_flag = false;
  111.       if(sound_flag)
  112.       {
  113.          Sound2.start();
  114.       }
  115.       push_flag = false;
  116.       if(abs_vx < vx)
  117.       {
  118.          vx -= 1;
  119.       }
  120.       if(vy < - abs_vy - 1)
  121.       {
  122.          vy += 1;
  123.       }
  124.       else if(abs_vy + 1 < vy)
  125.       {
  126.          vy -= 1;
  127.       }
  128.       vx = - Math.abs(vx);
  129.       Ball._x = right;
  130.    }
  131.    if(Ball._y < top + Ball._width / 2)
  132.    {
  133.       was_beat_flag = false;
  134.       if(sound_flag)
  135.       {
  136.          Sound2.start();
  137.       }
  138.       push_flag = false;
  139.       vy = Math.abs(vy);
  140.       if(abs_vy + 1 < vy)
  141.       {
  142.          vy -= 1;
  143.       }
  144.       Ball._y = top + Ball._width / 2;
  145.    }
  146.    else if(bottom < Ball._y)
  147.    {
  148.       if(max_series < series_)
  149.       {
  150.          max_series = series_;
  151.       }
  152.       series_ = 0;
  153.       if(max_hit < hits)
  154.       {
  155.          max_hit = hits;
  156.       }
  157.       hits = 0;
  158.       vx = abs_vx;
  159.       vy = - abs_vy;
  160.       begin_flag = true;
  161.       Ball._x = Platform._x;
  162.       Ball._y = Platform._y - Ball._Height;
  163.       vx = abs_vx;
  164.       if(random(2) == 1)
  165.       {
  166.          vx = - vx;
  167.       }
  168.       AddString();
  169.       wasfall_flag = true;
  170.       if(sound_flag)
  171.       {
  172.          Sound4.start();
  173.       }
  174.    }
  175.    if(wasvertical_flag || Platform._x - Platform._width / 2 < Ball._x && Ball._x < Platform._x + Platform._width / 2 && Platform._y - 8 < Ball._y && Ball._y < Platform._y + Platform._height / 2 + 10)
  176.    {
  177.       BeatDate2 = new Date();
  178.       Ball._y = Platform._y - Platform._height / 2 - Ball._Height - 5;
  179.       if(BeatDate2 - BeatDate >= BeatSeconds)
  180.       {
  181.          tmptmp = Platform._y;
  182.          BeatDate = BeatDate2;
  183.          wasvertical_flag = false;
  184.          if(stick_flag && !push_flag)
  185.          {
  186.             begin_flag = true;
  187.          }
  188.          if(sound_flag)
  189.          {
  190.             Sound2.start();
  191.          }
  192.          Date2 = new Date();
  193.          if(platform_vh < 0)
  194.          {
  195.             vy = - Math.abs(vy) - Math.abs(platform_vh);
  196.             if(vy >= 0)
  197.             {
  198.                vy = - abs_vy;
  199.             }
  200.          }
  201.          else
  202.          {
  203.             vy = - Math.abs(vy) + 2 * Math.abs(platform_vh);
  204.             if(vy >= -1)
  205.             {
  206.                vy = - abs_vy;
  207.             }
  208.          }
  209.          if(Aseconds < Math.abs(Date2 - Date1))
  210.          {
  211.             platform_vh = 0;
  212.          }
  213.          else if(max_hit < hits)
  214.          {
  215.             max_hit = hits;
  216.          }
  217.          vx += platform_v;
  218.          if(vy < -8)
  219.          {
  220.             vy = -8;
  221.          }
  222.          if(vx < -6)
  223.          {
  224.             vx = -6;
  225.          }
  226.          if(6 < vx)
  227.          {
  228.             vx = 6;
  229.          }
  230.          if(vx == 0)
  231.          {
  232.             vx = random(2 * abs_vx) - 3;
  233.          }
  234.          platform_v = 0;
  235.          platform_vh = 0;
  236.          if(hits == 0 && !push_flag && !wasfall_flag)
  237.          {
  238.             AddString();
  239.             if(sound_flag && !wasvertical_flag)
  240.             {
  241.                Sound4.start();
  242.             }
  243.          }
  244.          wasfall_flag = false;
  245.          push_flag = true;
  246.          hits = 0;
  247.          Ball._y = Platform._y - Platform._height / 2 - Ball._Height - 5;
  248.       }
  249.    }
  250. }
  251. bally = int((Ball._y - 28) / 20);
  252. ballx = int((Ball._x - 22) / 38);
  253. if(11 < ballx)
  254. {
  255.    ballx = 11;
  256. }
  257. if(bally < 0)
  258. {
  259.    bally = 0;
  260. }
  261. if(last_string >= bally && field[bally * 12 + ballx] != 0)
  262. {
  263.    was_beat_flag = false;
  264.    push_flag = false;
  265.    field[bally * 12 + ballx]--;
  266.    if(field[bally * 12 + ballx] == 0)
  267.    {
  268.       if(sound_flag)
  269.       {
  270.          Sound3.start();
  271.       }
  272.       tellTarget("x" + ballx + "y" + bally)
  273.       {
  274.          gotoAndPlay(2);
  275.       }
  276.       scores += 10 * (last_string - bally + 5);
  277.       series_ += 10 * (last_string - bally + 5);
  278.       hits += 10 * (last_string - bally + 5);
  279.       minus += 10 * (last_string - bally + 5);
  280.    }
  281.    else
  282.    {
  283.       if(sound_flag)
  284.       {
  285.          Sound1.start();
  286.       }
  287.       clipname = "x" + ballx + "y" + bally;
  288.       removeMovieClip(clipname);
  289.       attachMovie(word + field[bally * 12 + ballx],clipname,bally * 12 + ballx);
  290.       tellTarget(clipname)
  291.       {
  292.          _X = 22 + _parent.ballx * 38 + _width / 2;
  293.          _Y = 20 + _parent.bally * 20 + _height / 2;
  294.       }
  295.       scores += 10;
  296.       series_ += 10;
  297.       hits += 10;
  298.       minus += 10;
  299.    }
  300.    vy = - vy;
  301. }
  302. else
  303. {
  304.    tempx = ballx * 38 + 22;
  305.    if(last_string >= bally && 0 < ballx && vx < 0 && field[bally * 12 + ballx - 1] != 0 && Math.abs(tempx - Ball._x) < 10)
  306.    {
  307.       was_beat_flag = false;
  308.       push_flag = false;
  309.       field[bally * 12 + ballx - 1]--;
  310.       if(field[bally * 12 + ballx - 1] == 0)
  311.       {
  312.          if(sound_flag)
  313.          {
  314.             Sound3.start();
  315.          }
  316.          tellTarget("x" + (ballx - 1) + "y" + bally)
  317.          {
  318.             gotoAndPlay(2);
  319.          }
  320.          scores += 10 * (last_string - bally + 5);
  321.          series_ += 10 * (last_string - bally + 5);
  322.          hits += 10 * (last_string - bally + 5);
  323.          minus += 10 * (last_string - bally + 5);
  324.       }
  325.       else
  326.       {
  327.          if(sound_flag)
  328.          {
  329.             Sound1.start();
  330.          }
  331.          clipname = "x" + (ballx - 1) + "y" + bally;
  332.          removeMovieClip(clipname);
  333.          attachMovie(word + field[bally * 12 + ballx - 1],clipname,bally * 12 + ballx - 1);
  334.          tellTarget(clipname)
  335.          {
  336.             _X = 22 + (_parent.ballx - 1) * 38 + _width / 2;
  337.             _Y = 20 + _parent.bally * 20 + _height / 2;
  338.          }
  339.          scores += 10;
  340.          series_ += 10;
  341.          hits += 10;
  342.          minus += 10;
  343.       }
  344.       vx = - vx;
  345.    }
  346.    tempx = (ballx + 1) * 38 + 22;
  347.    if(last_string >= bally && ballx < 11 && 0 < vx && field[bally * 12 + ballx + 1] != 0 && Math.abs(tempx - Ball._x) < 10)
  348.    {
  349.       was_beat_flag = false;
  350.       push_flag = false;
  351.       field[bally * 12 + ballx + 1]--;
  352.       if(field[bally * 12 + ballx + 1] == 0)
  353.       {
  354.          if(sound_flag)
  355.          {
  356.             Sound3.start();
  357.          }
  358.          tellTarget("x" + (ballx + 1) + "y" + bally)
  359.          {
  360.             gotoAndPlay(2);
  361.          }
  362.          scores += 10 * (last_string - bally + 5);
  363.          series_ += 10 * (last_string - bally + 5);
  364.          hits += 10 * (last_string - bally + 5);
  365.          minus += 10 * (last_string - bally + 5);
  366.       }
  367.       else
  368.       {
  369.          if(sound_flag)
  370.          {
  371.             Sound1.start();
  372.          }
  373.          clipname = "x" + (ballx + 1) + "y" + bally;
  374.          removeMovieClip(clipname);
  375.          attachMovie(word + field[bally * 12 + ballx + 1],clipname,bally * 12 + ballx + 1);
  376.          tellTarget(clipname)
  377.          {
  378.             _X = 22 + (_parent.ballx + 1) * 38 + _width / 2;
  379.             _Y = 20 + _parent.bally * 20 + _height / 2;
  380.          }
  381.          scores += 10;
  382.          series_ += 10;
  383.          hits += 10;
  384.          minus += 10;
  385.       }
  386.       vx = - vx;
  387.    }
  388. }
  389. bally = int((Ball._y - 16) / 20);
  390. if(bally < 0)
  391. {
  392.    bally = 0;
  393. }
  394. if(last_string >= bally && field[bally * 12 + ballx] != 0)
  395. {
  396.    was_beat_flag = false;
  397.    push_flag = false;
  398.    field[bally * 12 + ballx]--;
  399.    if(field[bally * 12 + ballx] == 0)
  400.    {
  401.       if(sound_flag)
  402.       {
  403.          Sound3.start();
  404.       }
  405.       tellTarget("x" + ballx + "y" + bally)
  406.       {
  407.          gotoAndPlay(2);
  408.       }
  409.       scores += 10 * (last_string - bally + 5);
  410.       series_ += 10 * (last_string - bally + 5);
  411.       hits += 10 * (last_string - bally + 5);
  412.       minus += 10 * (last_string - bally + 5);
  413.    }
  414.    else
  415.    {
  416.       if(sound_flag)
  417.       {
  418.          Sound1.start();
  419.       }
  420.       clipname = "x" + ballx + "y" + bally;
  421.       removeMovieClip(clipname);
  422.       attachMovie(word + field[bally * 12 + ballx],clipname,bally * 12 + ballx);
  423.       tellTarget(clipname)
  424.       {
  425.          _X = 22 + _parent.ballx * 38 + _width / 2;
  426.          _Y = 20 + _parent.bally * 20 + _height / 2;
  427.       }
  428.       scores += 10;
  429.       series_ += 10;
  430.       hits += 10;
  431.       minus += 10;
  432.    }
  433.    vy = - vy;
  434. }
  435. else
  436. {
  437.    tempx = ballx * 38 + 22;
  438.    if(last_string >= bally && 0 < ballx && vx < 0 && field[bally * 12 + ballx - 1] != 0 && Math.abs(tempx - Ball._x) < 10)
  439.    {
  440.       was_beat_flag = false;
  441.       push_flag = false;
  442.       field[bally * 12 + ballx - 1]--;
  443.       if(field[bally * 12 + ballx - 1] == 0)
  444.       {
  445.          if(sound_flag)
  446.          {
  447.             Sound3.start();
  448.          }
  449.          tellTarget("x" + (ballx - 1) + "y" + bally)
  450.          {
  451.             gotoAndPlay(2);
  452.          }
  453.          scores += 10 * (last_string - bally + 5);
  454.          series_ += 10 * (last_string - bally + 5);
  455.          hits += 10 * (last_string - bally + 5);
  456.          minus += 10 * (last_string - bally + 5);
  457.       }
  458.       else
  459.       {
  460.          if(sound_flag)
  461.          {
  462.             Sound1.start();
  463.          }
  464.          clipname = "x" + (ballx - 1) + "y" + bally;
  465.          removeMovieClip(clipname);
  466.          attachMovie(word + field[bally * 12 + ballx - 1],clipname,bally * 12 + ballx - 1);
  467.          tellTarget(clipname)
  468.          {
  469.             _X = 22 + (_parent.ballx - 1) * 38 + _width / 2;
  470.             _Y = 20 + _parent.bally * 20 + _height / 2;
  471.          }
  472.          scores += 10;
  473.          series_ += 10;
  474.          hits += 10;
  475.          minus += 10;
  476.       }
  477.       vx = - vx;
  478.    }
  479.    tempx = (ballx + 1) * 38 + 22;
  480.    if(last_string >= bally && ballx < 11 && 0 < vx && field[bally * 12 + ballx + 1] != 0 && Math.abs(tempx - Ball._x) < 10)
  481.    {
  482.       was_beat_flag = false;
  483.       push_flag = false;
  484.       field[bally * 12 + ballx + 1]--;
  485.       if(field[bally * 12 + ballx + 1] == 0)
  486.       {
  487.          if(sound_flag)
  488.          {
  489.             Sound3.start();
  490.          }
  491.          tellTarget("x" + (ballx + 1) + "y" + bally)
  492.          {
  493.             gotoAndPlay(2);
  494.          }
  495.          scores += 10 * (last_string - bally + 5);
  496.          series_ += 10 * (last_string - bally + 5);
  497.          hits += 10 * (last_string - bally + 5);
  498.          minus += 10 * (last_string - bally + 5);
  499.       }
  500.       else
  501.       {
  502.          if(sound_flag)
  503.          {
  504.             Sound1.start();
  505.          }
  506.          clipname = "x" + (ballx + 1) + "y" + bally;
  507.          removeMovieClip(clipname);
  508.          attachMovie(word + field[bally * 12 + ballx + 1],clipname,bally * 12 + ballx + 1);
  509.          tellTarget(clipname)
  510.          {
  511.             _X = 22 + (_parent.ballx + 1) * 38 + _width / 2;
  512.             _Y = 20 + _parent.bally * 20 + _height / 2;
  513.          }
  514.          scores += 10;
  515.          series_ += 10;
  516.          hits += 10;
  517.          minus += 10;
  518.       }
  519.       vx = - vx;
  520.    }
  521. }
  522. if(minus >= 50)
  523. {
  524.    if(20 < Platform._width)
  525.    {
  526.       Platform._width--;
  527.       plat_width = Platform._width;
  528.    }
  529.    minus = 0;
  530. }
  531. Score = scores;
  532. Series = series_;
  533. Hit = hits;
  534. gotoAndPlay(5);
  535.