home *** CD-ROM | disk | FTP | other *** search
/ 404 Jogos / CLJG.iso / Diversos / PrettyBang.swf / scripts / DefineSprite_128 / frame_1 / DoAction.as
Encoding:
Text File  |  2007-09-27  |  7.5 KB  |  364 lines

  1. function new_ball(x, y, r, s, t)
  2. {
  3.    var _loc3_ = max_balls;
  4.    var _loc2_ = 0;
  5.    while(_loc2_ < max_balls)
  6.    {
  7.       if(!b_array[_loc2_])
  8.       {
  9.          _loc3_ = _loc2_;
  10.          break;
  11.       }
  12.       _loc2_ = _loc2_ + 1;
  13.    }
  14.    if(_loc3_ == max_balls)
  15.    {
  16.       return undefined;
  17.    }
  18.    player.duplicateMovieClip("b" + _loc3_,_loc3_);
  19.    this["b" + _loc3_].gotoAndStop(t + 2);
  20.    this["b" + _loc3_].ghost = t;
  21.    this["b" + _loc3_].number = _loc3_;
  22.    this["b" + _loc3_]._x = x;
  23.    this["b" + _loc3_]._y = y;
  24.    this["b" + _loc3_]._xscale = 100;
  25.    this["b" + _loc3_]._yscale = 100;
  26.    this["b" + _loc3_]._rotation = r;
  27.    if(s > max_speed)
  28.    {
  29.       this["b" + _loc3_].target._y = - speed_step;
  30.    }
  31.    else
  32.    {
  33.       this["b" + _loc3_].target._y = - s;
  34.    }
  35.    cur_balls++;
  36.    b_array[_loc3_] = 1;
  37. }
  38. function get_rotation(ba, bb)
  39. {
  40.    dx = ba._x - bb._x;
  41.    dy = ba._y - bb._y;
  42.    return (- Math.atan2(dx,dy)) / 0.017453292519943295;
  43. }
  44. function pop_check(b0)
  45. {
  46.    if(game_over)
  47.    {
  48.       return undefined;
  49.    }
  50.    var _loc3_ = 0;
  51.    while(_loc3_ < max_balls)
  52.    {
  53.       if(b_array[_loc3_] && b0.number != _loc3_ && !this["b" + _loc3_].ghost)
  54.       {
  55.          x = _root.absloc(this["b" + _loc3_]).x;
  56.          y = _root.absloc(this["b" + _loc3_]).y;
  57.          if(b0.hitTest(x,y,true))
  58.          {
  59.             if(boss_fight)
  60.             {
  61.                r = get_rotation(boss,this["b" + _loc3_]);
  62.                new_ball(this["b" + _loc3_]._x,this["b" + _loc3_]._y,r + 180,max_speed,1);
  63.             }
  64.             else if(cur_balls < max_balls / 2)
  65.             {
  66.                r = get_rotation(b0,this["b" + _loc3_]);
  67.                new_ball(this["b" + _loc3_]._x,this["b" + _loc3_]._y,r + 10,- (this["b" + _loc3_].target._y - 4),1);
  68.                new_ball(this["b" + _loc3_]._x,this["b" + _loc3_]._y,r - 10,- (this["b" + _loc3_].target._y - 4),1);
  69.             }
  70.             explode(this["b" + _loc3_],0);
  71.          }
  72.       }
  73.       _loc3_ = _loc3_ + 1;
  74.    }
  75. }
  76. function boss_hit_check(b0)
  77. {
  78.    if(boss.ghost || game_over)
  79.    {
  80.       return undefined;
  81.    }
  82.    x = _root.absloc(b0).x;
  83.    y = _root.absloc(b0).y;
  84.    if(boss.hitTest(x,y,true))
  85.    {
  86.       if(boss.polarity)
  87.       {
  88.          boss.hp = boss.hp + 1;
  89.       }
  90.       else
  91.       {
  92.          boss.hp--;
  93.       }
  94.       explode(b0,2);
  95.    }
  96. }
  97. function death_check()
  98. {
  99.    var _loc5_ = _root.absloc(player).x;
  100.    var _loc4_ = _root.absloc(player).y;
  101.    var _loc3_ = 0;
  102.    while(_loc3_ < max_balls)
  103.    {
  104.       if(b_array[_loc3_] && this["b" + _loc3_].ghost != 1)
  105.       {
  106.          if(this["b" + _loc3_].hitTest(_loc5_,_loc4_,true))
  107.          {
  108.             die();
  109.          }
  110.       }
  111.       _loc3_ = _loc3_ + 1;
  112.    }
  113.    if(boss_fight)
  114.    {
  115.       if(boss.hitTest(_loc5_,_loc4_,true))
  116.       {
  117.          die();
  118.       }
  119.       if(boss_helper.active && boss_helper.hitTest(_loc5_,_loc4_,true))
  120.       {
  121.          die();
  122.       }
  123.    }
  124. }
  125. function continue_popping(b0)
  126. {
  127.    if(b0._xscale < 100)
  128.    {
  129.       if(b0 == player)
  130.       {
  131.          if(time && !game_over)
  132.          {
  133.             b0._xscale = 100;
  134.             b0._yscale = 100;
  135.             b0.popping = 0;
  136.             b0.gotoAndStop(1);
  137.          }
  138.          else if(!time && game_over)
  139.          {
  140.             b0._visible = 0;
  141.          }
  142.       }
  143.       else
  144.       {
  145.          b_array[b0.number] = 0;
  146.          removeMovieClip(b0);
  147.          cur_balls--;
  148.       }
  149.       combo_reset_check();
  150.    }
  151.    else
  152.    {
  153.       b0._xscale += b0.dp * 10;
  154.       b0._yscale += b0.dp * 10;
  155.       b0.dp = b0.dp - 1;
  156.       pop_check(b0);
  157.    }
  158. }
  159. function move_player()
  160. {
  161.    if(player.popping)
  162.    {
  163.       continue_popping(player);
  164.    }
  165.    else if(Math.abs(_xmouse) < frame._width / 2 && Math.abs(_ymouse) < frame._height / 2)
  166.    {
  167.       if(Math.abs(player._x - _xmouse) < player_speed)
  168.       {
  169.          player._x = _xmouse;
  170.       }
  171.       else if(player._x < _xmouse)
  172.       {
  173.          player._x += player_speed;
  174.       }
  175.       else
  176.       {
  177.          player._x -= player_speed;
  178.       }
  179.       if(Math.abs(player._y - _ymouse) < player_speed)
  180.       {
  181.          player._y = _ymouse;
  182.       }
  183.       else if(player._y < _ymouse)
  184.       {
  185.          player._y += player_speed;
  186.       }
  187.       else
  188.       {
  189.          player._y -= player_speed;
  190.       }
  191.       death_check();
  192.    }
  193. }
  194. function res_ball(b0)
  195. {
  196.    b0.ghost = 0;
  197.    b0.gotoAndStop(2);
  198. }
  199. function move_ball(b0)
  200. {
  201.    b0._x = (_root.absloc(b0.target).x - this._x) * 100 / this._xscale;
  202.    b0._y = (_root.absloc(b0.target).y - this._y) * 100 / this._yscale;
  203.    if(Math.abs(b0._x) > frame._width / 2)
  204.    {
  205.       res_ball(b0);
  206.       b0._x += b0._x >= 0 ? - frame._width : frame._width;
  207.    }
  208.    if(Math.abs(b0._y) > frame._height / 2)
  209.    {
  210.       res_ball(b0);
  211.       b0._y += b0._y >= 0 ? - frame._height : frame._height;
  212.    }
  213.    if(b0.ghost == 1 && boss_fight)
  214.    {
  215.       boss_hit_check(b0);
  216.    }
  217. }
  218. function move_all_balls()
  219. {
  220.    var _loc2_ = 0;
  221.    while(_loc2_ < max_balls)
  222.    {
  223.       if(b_array[_loc2_])
  224.       {
  225.          if(this["b" + _loc2_].popping)
  226.          {
  227.             continue_popping(this["b" + _loc2_]);
  228.          }
  229.          else
  230.          {
  231.             move_ball(this["b" + _loc2_]);
  232.          }
  233.       }
  234.       _loc2_ = _loc2_ + 1;
  235.    }
  236. }
  237. function start_boss_fight()
  238. {
  239.    var _loc2_ = 0;
  240.    while(_loc2_ < max_balls)
  241.    {
  242.       if(b_array[_loc2_] && !this["b" + _loc2_].popping)
  243.       {
  244.          explode(this["b" + _loc2_],3);
  245.       }
  246.       _loc2_ = _loc2_ + 1;
  247.    }
  248.    boss_fight = 1;
  249. }
  250. function combo_reset_check()
  251. {
  252.    var _loc3_ = 0;
  253.    var _loc2_ = 0;
  254.    while(_loc2_ < max_balls)
  255.    {
  256.       if(b_array[_loc2_] && this["b" + _loc2_].popping)
  257.       {
  258.          _loc3_ = 1;
  259.          _loc2_ = max_balls;
  260.       }
  261.       _loc2_ = _loc2_ + 1;
  262.    }
  263.    if(!_loc3_)
  264.    {
  265.       combo = 0;
  266.       boss_fight_check();
  267.    }
  268. }
  269. function boss_fight_check()
  270. {
  271.    if(boss_fight)
  272.    {
  273.       return undefined;
  274.    }
  275.    if(score > level * 1000)
  276.    {
  277.       start_boss_fight();
  278.    }
  279.    else if(score > next_star * 1000)
  280.    {
  281.       drop_star = 1;
  282.       time += 300;
  283.       next_star++;
  284.    }
  285. }
  286. function die()
  287. {
  288.    player.popping = 1;
  289.    player.dp = 10;
  290.    player.ghost = 1;
  291.    player.gotoAndStop("pop");
  292.    player.aura.gotoAndStop(2);
  293.    _root.die_sfx.start();
  294.    time -= 300;
  295.    combo++;
  296. }
  297. function explode(b0, c)
  298. {
  299.    if(b0.popping)
  300.    {
  301.       return undefined;
  302.    }
  303.    b0.popping = 1;
  304.    b0.dp = 10;
  305.    b0.ghost = 1;
  306.    b0.gotoAndStop("pop");
  307.    b0.aura.gotoAndStop(c + 1);
  308.    if(c != 3)
  309.    {
  310.       combo++;
  311.       score += combo + level;
  312.       total_score += combo + level;
  313.       if(score > total_stock * total_stock * total_stock)
  314.       {
  315.          time += 150;
  316.          total_stock++;
  317.          _root.bling_sfx.start();
  318.       }
  319.    }
  320.    _root.explode_sfx.start();
  321. }
  322. function format_time()
  323. {
  324.    if(boss_fight != 1)
  325.    {
  326.       time--;
  327.    }
  328.    if(time < 0)
  329.    {
  330.       time = 0;
  331.       if(!player.popping)
  332.       {
  333.          die();
  334.       }
  335.    }
  336.    timef = int(time / 30) + "." + time % 30;
  337. }
  338. function level_up()
  339. {
  340.    score = 0;
  341.    time += 1500;
  342.    level++;
  343.    total_stock = level;
  344.    next_star = 1;
  345. }
  346. max_balls = 64;
  347. cur_balls = 0;
  348. speed_step = 4;
  349. max_speed = 16;
  350. player_speed = 16;
  351. boss_fight = 0;
  352. level = 0;
  353. total_score = 0;
  354. time = 1500;
  355. cheatstick = 0;
  356. drop_star = 0;
  357. game_over = 0;
  358. next_star = 1;
  359. b_array = new Array(max_balls);
  360. player.stop();
  361. createEmptyMovieClip("blank",300);
  362. player.swapDepths("blank");
  363. removeMovieClip("blank");
  364.