home *** CD-ROM | disk | FTP | other *** search
/ 404 Jogos / CLJG.iso / Puzzle / blockix.swf / scripts / frame_1 / DoAction.as
Text File  |  2008-09-26  |  20KB  |  583 lines

  1. function start_game()
  2. {
  3.    if(actual_level == 0)
  4.    {
  5.       nr_of_foes = 2;
  6.    }
  7.    move_direction = -1;
  8.    next_move_direction = -1;
  9.    z = 0;
  10.    while(z < nr_of_foes)
  11.    {
  12.       toremove = _root[3023 + z];
  13.       toremove.removeMovieClip();
  14.       z++;
  15.    }
  16.    game_running = true;
  17.    map.clear();
  18.    fixed_map.clear();
  19.    z = 0;
  20.    while(z < 51)
  21.    {
  22.       map[z] = new Array(51);
  23.       fixed_map[z] = new Array(51);
  24.       z++;
  25.    }
  26.    dx = 0;
  27.    while(dx < 51)
  28.    {
  29.       dy = 0;
  30.       while(dy < 51)
  31.       {
  32.          map[dx][dy] = 0;
  33.          fixed_map[dx][dy] = 0;
  34.          dy++;
  35.       }
  36.       dx++;
  37.    }
  38.    plox = 51;
  39.    ploy = 51;
  40.    tx = 0;
  41.    while(tx < 12)
  42.    {
  43.       ty = 0;
  44.       while(ty < 12)
  45.       {
  46.          if(level_map[actual_level % max_level][tx][ty] == 2)
  47.          {
  48.             level_map[actual_level % max_level][tx][ty] = 1;
  49.          }
  50.          if(level_map[actual_level % max_level][tx][ty] == 1)
  51.          {
  52.             z = 0;
  53.             while(z < 5)
  54.             {
  55.                map[1 + tx * 4 + z][1 + ty * 4] = 3;
  56.                map[1 + tx * 4 + z][1 + ty * 4 + 4] = 3;
  57.                map[1 + tx * 4][1 + ty * 4 + z] = 3;
  58.                map[1 + tx * 4 + 4][1 + ty * 4 + z] = 3;
  59.                z++;
  60.             }
  61.          }
  62.          ty++;
  63.       }
  64.       tx++;
  65.    }
  66.    ehix = 0;
  67.    ehiy = 0;
  68.    total_blocks_to_go = 0;
  69.    dx = 1;
  70.    while(dx < 50)
  71.    {
  72.       dy = 1;
  73.       while(dy < 50)
  74.       {
  75.          if(map[dx][dy] != 0)
  76.          {
  77.             total_blocks_to_go++;
  78.             if(dx < plox)
  79.             {
  80.                plox = dx;
  81.             }
  82.             if(dy < ploy)
  83.             {
  84.                ploy = dy;
  85.             }
  86.             if(dx > ehix)
  87.             {
  88.                ehix = dx;
  89.             }
  90.             if(dy > ehiy)
  91.             {
  92.                ehiy = dy;
  93.             }
  94.             a = 0;
  95.             if(map[dx][dy - 1] != 0)
  96.             {
  97.                a += 1;
  98.             }
  99.             if(map[dx + 1][dy] != 0)
  100.             {
  101.                a += 2;
  102.             }
  103.             if(map[dx][dy + 1] != 0)
  104.             {
  105.                a += 4;
  106.             }
  107.             if(map[dx - 1][dy] != 0)
  108.             {
  109.                a += 8;
  110.             }
  111.             switch(a)
  112.             {
  113.                case 0:
  114.                   break;
  115.                case 1:
  116.                   break;
  117.                case 2:
  118.                   break;
  119.                case 3:
  120.                   map[dx][dy] = 7;
  121.                   break;
  122.                case 4:
  123.                   break;
  124.                case 5:
  125.                   map[dx][dy] = 2;
  126.                   break;
  127.                case 6:
  128.                   map[dx][dy] = 4;
  129.                   break;
  130.                case 7:
  131.                   map[dx][dy] = 9;
  132.                   break;
  133.                case 8:
  134.                   break;
  135.                case 9:
  136.                   map[dx][dy] = 6;
  137.                   break;
  138.                case 10:
  139.                   map[dx][dy] = 1;
  140.                   break;
  141.                case 11:
  142.                   map[dx][dy] = 8;
  143.                   break;
  144.                case 12:
  145.                   map[dx][dy] = 5;
  146.                   break;
  147.                case 13:
  148.                   map[dx][dy] = 11;
  149.                   break;
  150.                case 14:
  151.                   map[dx][dy] = 10;
  152.                   break;
  153.                case 15:
  154.                   map[dx][dy] = 3;
  155.             }
  156.          }
  157.          dy++;
  158.       }
  159.       dx++;
  160.    }
  161.    enemy_directions = new Array();
  162.    ego._x = -5 + plox * 10;
  163.    ego._y = -5 + ploy * 10;
  164.    ehix = -5 + ehix * 10;
  165.    ehiy = -5 + ehiy * 10;
  166.    z = 0;
  167.    while(z < nr_of_foes)
  168.    {
  169.       enemy_directions[z] = random(4);
  170.       z++;
  171.    }
  172.    dx = 0;
  173.    while(dx < 50)
  174.    {
  175.       dy = 0;
  176.       while(dy < 50)
  177.       {
  178.          show_map(dx,dy);
  179.          dy++;
  180.       }
  181.       dx++;
  182.    }
  183.    z = 0;
  184.    while(z < nr_of_foes)
  185.    {
  186.       _root.attachMovie("enemy",3023 + z,_root.getNextHighestDepth(),{_x:ehix,_y:ehiy});
  187.       z++;
  188.    }
  189. }
  190. function show_map(dx, dy)
  191. {
  192.    todel = _root[dx + dy * 50];
  193.    todel.removeMovieClip();
  194.    switch(map[dx][dy])
  195.    {
  196.       case 1:
  197.          _root.attachMovie("hz_line",dx + dy * 50,_root.getNextHighestDepth(),{_x:-5 + dx * 10,_y:-5 + dy * 10});
  198.          break;
  199.       case 2:
  200.          _root.attachMovie("vt_line",dx + dy * 50,_root.getNextHighestDepth(),{_x:-5 + dx * 10,_y:-5 + dy * 10});
  201.          break;
  202.       case 3:
  203.          _root.attachMovie("intersection",dx + dy * 50,_root.getNextHighestDepth(),{_x:-5 + dx * 10,_y:-5 + dy * 10});
  204.          break;
  205.       case 4:
  206.          _root.attachMovie("lo_corner",dx + dy * 50,_root.getNextHighestDepth(),{_x:-5 + dx * 10,_y:-5 + dy * 10});
  207.          break;
  208.       case 5:
  209.          _root.attachMovie("ro_corner",dx + dy * 50,_root.getNextHighestDepth(),{_x:-5 + dx * 10,_y:-5 + dy * 10});
  210.          break;
  211.       case 6:
  212.          _root.attachMovie("ru_corner",dx + dy * 50,_root.getNextHighestDepth(),{_x:-5 + dx * 10,_y:-5 + dy * 10});
  213.          break;
  214.       case 7:
  215.          _root.attachMovie("lu_corner",dx + dy * 50,_root.getNextHighestDepth(),{_x:-5 + dx * 10,_y:-5 + dy * 10});
  216.          break;
  217.       case 8:
  218.          _root.attachMovie("t_top",dx + dy * 50,_root.getNextHighestDepth(),{_x:-5 + dx * 10,_y:-5 + dy * 10});
  219.          break;
  220.       case 9:
  221.          _root.attachMovie("t_right",dx + dy * 50,_root.getNextHighestDepth(),{_x:-5 + dx * 10,_y:-5 + dy * 10});
  222.          break;
  223.       case 10:
  224.          _root.attachMovie("t_down",dx + dy * 50,_root.getNextHighestDepth(),{_x:-5 + dx * 10,_y:-5 + dy * 10});
  225.          break;
  226.       case 11:
  227.          _root.attachMovie("t_left",dx + dy * 50,_root.getNextHighestDepth(),{_x:-5 + dx * 10,_y:-5 + dy * 10});
  228.          break;
  229.       case 17:
  230.          _root.attachMovie("hz_double_line",dx + dy * 50,_root.getNextHighestDepth(),{_x:-5 + dx * 10,_y:-5 + dy * 10});
  231.          break;
  232.       case 18:
  233.          _root.attachMovie("vt_double_line",dx + dy * 50,_root.getNextHighestDepth(),{_x:-5 + dx * 10,_y:-5 + dy * 10});
  234.          break;
  235.       case 19:
  236.          _root.attachMovie("double_intersection",dx + dy * 50,_root.getNextHighestDepth(),{_x:-5 + dx * 10,_y:-5 + dy * 10});
  237.          break;
  238.       case 20:
  239.          _root.attachMovie("lo_double_corner",dx + dy * 50,_root.getNextHighestDepth(),{_x:-5 + dx * 10,_y:-5 + dy * 10});
  240.          break;
  241.       case 21:
  242.          _root.attachMovie("ro_double_corner",dx + dy * 50,_root.getNextHighestDepth(),{_x:-5 + dx * 10,_y:-5 + dy * 10});
  243.          break;
  244.       case 22:
  245.          _root.attachMovie("ru_double_corner",dx + dy * 50,_root.getNextHighestDepth(),{_x:-5 + dx * 10,_y:-5 + dy * 10});
  246.          break;
  247.       case 23:
  248.          _root.attachMovie("lu_double_corner",dx + dy * 50,_root.getNextHighestDepth(),{_x:-5 + dx * 10,_y:-5 + dy * 10});
  249.          break;
  250.       case 24:
  251.          _root.attachMovie("t_double_top",dx + dy * 50,_root.getNextHighestDepth(),{_x:-5 + dx * 10,_y:-5 + dy * 10});
  252.          break;
  253.       case 25:
  254.          _root.attachMovie("t_double_right",dx + dy * 50,_root.getNextHighestDepth(),{_x:-5 + dx * 10,_y:-5 + dy * 10});
  255.          break;
  256.       case 26:
  257.          _root.attachMovie("t_double_down",dx + dy * 50,_root.getNextHighestDepth(),{_x:-5 + dx * 10,_y:-5 + dy * 10});
  258.          break;
  259.       case 27:
  260.          _root.attachMovie("t_double_left",dx + dy * 50,_root.getNextHighestDepth(),{_x:-5 + dx * 10,_y:-5 + dy * 10});
  261.    }
  262. }
  263. map = new Array(51);
  264. score = 0;
  265. fixed_map = new Array(51);
  266. action_timer = 5;
  267. game_running = false;
  268. total_blocks_to_go = 0;
  269. actual_level = 0;
  270. max_level = 12;
  271. move_direction = -1;
  272. ehix = 0;
  273. ehiy = 0;
  274. lives = 3;
  275. nr_of_foes = 3;
  276. next_move_direction = -1;
  277. step = 4;
  278. muted = false;
  279. is_pause = false;
  280. level_map = [[[0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,1,0,1,1,0,1,0,0,0],[0,0,0,0,1,1,1,1,0,0,0,0],[0,0,0,1,1,0,0,1,1,0,0,0],[0,0,0,1,1,0,0,1,1,0,0,0],[0,0,0,0,1,1,1,1,0,0,0,0],[0,0,0,1,0,1,1,0,1,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0]],[[0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,1,1,1,1,1,1,0,0,0],[0,0,0,1,1,1,1,1,1,0,0,0],[0,0,0,1,1,0,0,1,1,0,0,0],[0,0,0,1,1,0,0,1,1,0,0,0],[0,0,0,1,1,1,1,1,1,0,0,0],[0,0,0,1,1,1,1,1,1,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0]],[[0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,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[0,0,0,0,1,0,1,0,0,0,0,0],[0,0,0,1,0,1,0,1,0,0,0,0],[0,0,0,0,1,0,1,0,0,0,0,0],[0,0,0,1,0,1,0,1,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0]],[[0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0],[0,0,1,1,1,1,1,1,1,1,0,0],[0,0,1,1,1,1,1,1,1,1,0,0],[0,0,1,1,0,0,0,0,1,1,0,0],[0,0,1,1,0,0,0,0,1,1,0,0],[0,0,1,1,0,0,0,0,1,1,0,0],[0,0,1,1,0,0,0,0,1,1,0,0],[0,0,1,1,1,1,1,1,1,1,0,0],[0,0,1,1,1,1,1,1,1,1,0,0],[0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0]]];
  281. _root.kongregateServices.connect();
  282. swush_sound = new Sound();
  283. swush_sound.attachSound("swush.wav");
  284. palim_sound = new Sound();
  285. palim_sound.attachSound("palim.wav");
  286. palim_sound.start(0,1);
  287. krck_sound = new Sound();
  288. krck_sound.attachSound("krck.wav");
  289. keyListener = new Object();
  290. keyListener.onKeyDown = function()
  291. {
  292.    var _loc1_ = Key.getCode();
  293.    switch(_loc1_)
  294.    {
  295.       case 77:
  296.       case 109:
  297.          muted = !muted;
  298.          break;
  299.       case 115:
  300.       case 83:
  301.          lives = 3;
  302.          start_game();
  303.          break;
  304.       case 113:
  305.       case 80:
  306.          if(is_pause == false && game_running)
  307.          {
  308.             is_pause = true;
  309.             game_running = false;
  310.          }
  311.          else if(is_pause)
  312.          {
  313.             is_pause = false;
  314.             game_running = true;
  315.          }
  316.    }
  317.    if(game_running == true)
  318.    {
  319.       switch(_loc1_)
  320.       {
  321.          case 39:
  322.             next_move_direction = 1;
  323.             if(move_direction == 3)
  324.             {
  325.                move_direction = 1;
  326.             }
  327.             break;
  328.          case 40:
  329.             next_move_direction = 2;
  330.             if(move_direction == 0)
  331.             {
  332.                move_direction = 2;
  333.             }
  334.             break;
  335.          case 37:
  336.             next_move_direction = 3;
  337.             if(move_direction == 1)
  338.             {
  339.                move_direction = 3;
  340.             }
  341.             break;
  342.          case 38:
  343.             next_move_direction = 0;
  344.             if(move_direction == 2)
  345.             {
  346.                move_direction = 0;
  347.             }
  348.       }
  349.    }
  350. };
  351. Key.addListener(keyListener);
  352. this.onEnterFrame = function()
  353. {
  354.    if(game_running)
  355.    {
  356.       step--;
  357.       if(step == 0)
  358.       {
  359.          z = 0;
  360.          while(z < nr_of_foes)
  361.          {
  362.             actual_enemy = _root[3023 + z];
  363.             ox = (actual_enemy._x + 5) / 10;
  364.             oy = (actual_enemy._y + 5) / 10;
  365.             step = 3;
  366.             if(map[ox][oy] != 1 && map[ox][oy] != 2 && random(4) == 0)
  367.             {
  368.                enemy_directions[z] = random(4);
  369.             }
  370.             switch(enemy_directions[z])
  371.             {
  372.                case 0:
  373.                   if(map[ox][oy - 1] != 0)
  374.                   {
  375.                      oy -= 1;
  376.                   }
  377.                   else
  378.                   {
  379.                      enemy_directions[z] = random(4);
  380.                   }
  381.                   break;
  382.                case 1:
  383.                   if(map[ox + 1][oy] != 0)
  384.                   {
  385.                      ox += 1;
  386.                   }
  387.                   else
  388.                   {
  389.                      enemy_directions[z] = random(4);
  390.                   }
  391.                   break;
  392.                case 2:
  393.                   if(map[ox][oy + 1] != 0)
  394.                   {
  395.                      oy += 1;
  396.                   }
  397.                   else
  398.                   {
  399.                      enemy_directions[z] = random(4);
  400.                   }
  401.                   break;
  402.                case 3:
  403.                   if(map[ox - 1][oy] != 0)
  404.                   {
  405.                      ox -= 1;
  406.                   }
  407.                   else
  408.                   {
  409.                      enemy_directions[z] = random(4);
  410.                   }
  411.             }
  412.             if(map[ox][oy] > 16 && fixed_map[ox][oy] == 0)
  413.             {
  414.                total_blocks_to_go++;
  415.                map[ox][oy] -= 16;
  416.             }
  417.             show_map(ox,oy);
  418.             actual_enemy._x = -5 + ox * 10;
  419.             actual_enemy._y = -5 + oy * 10;
  420.             z++;
  421.          }
  422.       }
  423.    }
  424.    if(game_running)
  425.    {
  426.       moved = false;
  427.       ox = (ego._x + 5) / 10;
  428.       oy = (ego._y + 5) / 10;
  429.       if(map[ox][oy] != 1 && map[ox][oy] != 2 && map[ox][oy] != 17 && map[ox][oy] != 18)
  430.       {
  431.          move_direction = next_move_direction;
  432.       }
  433.       switch(move_direction)
  434.       {
  435.          case 1:
  436.             if(map[ox + 1][oy] != 0)
  437.             {
  438.                ego._x += 10;
  439.                moved = true;
  440.             }
  441.             break;
  442.          case 2:
  443.             if(map[ox][oy + 1] != 0)
  444.             {
  445.                ego._y += 10;
  446.                moved = true;
  447.             }
  448.             break;
  449.          case 3:
  450.             if(map[ox - 1][oy] != 0)
  451.             {
  452.                ego._x -= 10;
  453.                moved = true;
  454.             }
  455.             break;
  456.          case 0:
  457.             if(map[ox][oy - 1] != 0)
  458.             {
  459.                ego._y -= 10;
  460.                moved = true;
  461.             }
  462.       }
  463.       if(moved)
  464.       {
  465.          if(map[ox][oy] < 16)
  466.          {
  467.             map[ox][oy] += 16;
  468.             total_blocks_to_go--;
  469.          }
  470.          show_map(ox,oy);
  471.          tx = 0;
  472.          while(tx < 12)
  473.          {
  474.             ty = 0;
  475.             while(ty < 12)
  476.             {
  477.                if(level_map[actual_level % max_level][tx][ty] == 1)
  478.                {
  479.                   a = 0;
  480.                   z = 0;
  481.                   while(z < 5)
  482.                   {
  483.                      if(map[1 + tx * 4 + z][1 + ty * 4] > 16)
  484.                      {
  485.                         a++;
  486.                      }
  487.                      if(map[1 + tx * 4 + z][1 + ty * 4 + 4] > 16)
  488.                      {
  489.                         a++;
  490.                      }
  491.                      if(map[1 + tx * 4][1 + ty * 4 + z] > 16)
  492.                      {
  493.                         a++;
  494.                      }
  495.                      if(map[1 + tx * 4 + 4][1 + ty * 4 + z] > 16)
  496.                      {
  497.                         a++;
  498.                      }
  499.                      z++;
  500.                   }
  501.                   if(a == 20)
  502.                   {
  503.                      level_map[actual_level % max_level][tx][ty] = 2;
  504.                      score += actual_level + 1;
  505.                      z = 0;
  506.                      while(z < 5)
  507.                      {
  508.                         fixed_map[1 + tx * 4 + z][1 + ty * 4] = 1;
  509.                         fixed_map[1 + tx * 4 + z][1 + ty * 4 + 4] = 1;
  510.                         fixed_map[1 + tx * 4][1 + ty * 4 + z] = 1;
  511.                         fixed_map[1 + tx * 4 + 4][1 + ty * 4 + z] = 1;
  512.                         z++;
  513.                      }
  514.                      if(!muted)
  515.                      {
  516.                         swush_sound.start(0,1);
  517.                      }
  518.                      dx = 1;
  519.                      while(dx < 4)
  520.                      {
  521.                         dy = 1;
  522.                         while(dy < 4)
  523.                         {
  524.                            _root.attachMovie("fixed_tile_bg",1 + tx * 4 + dx + (1 + dy + ty * 4) * 50,_root.getNextHighestDepth(),{_x:-5 + (1 + dx + tx * 4) * 10,_y:-5 + (1 + dy + ty * 4) * 10});
  525.                            dy++;
  526.                         }
  527.                         dx++;
  528.                      }
  529.                   }
  530.                }
  531.                ty++;
  532.             }
  533.             tx++;
  534.          }
  535.       }
  536.    }
  537.    if(total_blocks_to_go == 0 && game_running)
  538.    {
  539.       actual_level++;
  540.       if(actual_level % max_level == 0)
  541.       {
  542.          nr_of_foes++;
  543.       }
  544.       if((actual_level & 3) == 0)
  545.       {
  546.          lives++;
  547.       }
  548.       start_game();
  549.       _root.kongregateStats.submit("maxLevel",actual_level);
  550.       _root.kongregateStats.submit("maxScore",score);
  551.    }
  552.    if(game_running)
  553.    {
  554.       ox = (ego._x + 5) / 10;
  555.       oy = (ego._y + 5) / 10;
  556.       z = 0;
  557.       while(z < nr_of_foes)
  558.       {
  559.          actual_enemy = _root[3023 + z];
  560.          ex = (actual_enemy._x + 5) / 10;
  561.          ey = (actual_enemy._y + 5) / 10;
  562.          if(ex == ox && ey == oy && game_running)
  563.          {
  564.             lives--;
  565.             if(!muted)
  566.             {
  567.                krck_sound.start(0,1);
  568.             }
  569.             if(lives == 0)
  570.             {
  571.                game_running = false;
  572.                score = 0;
  573.             }
  574.             else
  575.             {
  576.                start_game();
  577.             }
  578.          }
  579.          z++;
  580.       }
  581.    }
  582. };
  583.