home *** CD-ROM | disk | FTP | other *** search
/ 404 Jogos / CLJG.iso / Diversos / bubblerumble.swf / scripts / frame_136 / DoAction.as
Encoding:
Text File  |  2008-09-12  |  15.0 KB  |  431 lines

  1. stop();
  2. var bubble_timer = 2000;
  3. var last_timer = getTimer();
  4. var depth = 50000;
  5. var green_pool = new Array(10);
  6. var blue_pool = new Array(10);
  7. var lvl = 10;
  8. var nbB = 1;
  9. var vit = 6;
  10. var vitx = 0;
  11. var vity = 1;
  12. var green_char = "";
  13. var blue_char = "";
  14. var l = 100000;
  15. var lastGreen = green_pool.length;
  16. var lastBlue = blue_pool.length;
  17. var lastGreenT = _root.lastGreen;
  18. var lastBlueT = _root.lastBlue;
  19. var mort = false;
  20. var mort2 = false;
  21. var mortBlue = false;
  22. var mortGreen = false;
  23. var music = true;
  24. _root.createEmptyMovieClip("dummy1",50001);
  25. _root.createEmptyMovieClip("dummy2",50002);
  26. _root.createEmptyMovieClip("dummy3",50003);
  27. aqua1.swapDepths(dummy1);
  28. aqua2.swapDepths(dummy2);
  29. keyEvent = new Object();
  30. Key.addListener(keyEvent);
  31. keyEvent.onKeyDown = function()
  32. {
  33.    if(Key.isDown(27))
  34.    {
  35.       if(_root.music)
  36.       {
  37.          stopAllSounds();
  38.          _root.music = false;
  39.       }
  40.       else
  41.       {
  42.          _root.music = true;
  43.          _root.musicz.play();
  44.       }
  45.    }
  46.    if(green_char != "")
  47.    {
  48.       if(String.fromCharCode(Key.getAscii()).toUpperCase() == green_char)
  49.       {
  50.          green_char = "";
  51.          j = 0;
  52.          while(j < green_pool.length)
  53.          {
  54.             green_pool[j].onEnterFrame = function()
  55.             {
  56.                this._alpha -= Math.random() * 6;
  57.                if(this._alpha < 50 && !this.lol)
  58.                {
  59.                   var _loc3_ = _root.attachMovie("score_plus","s" + l++,l);
  60.                   _loc3_._x = this._x;
  61.                   _loc3_._y = this._y - 20;
  62.                   if(Math.round(Math.random() * 2) == 1)
  63.                   {
  64.                      var _loc4_ = new Sound(_root);
  65.                      _loc4_.attachSound("score");
  66.                      _loc4_.start(0,1);
  67.                   }
  68.                   this.lol = true;
  69.                }
  70.                if(this._alpha < 20)
  71.                {
  72.                   score++;
  73.                   this.removeMovieClip();
  74.                }
  75.             };
  76.             j++;
  77.          }
  78.          green_pool = new Array(green_pool.length);
  79.          aqua2.lettre.gotoAndStop(1);
  80.       }
  81.    }
  82.    if(blue_char != "")
  83.    {
  84.       if(String.fromCharCode(Key.getAscii()).toUpperCase() == blue_char)
  85.       {
  86.          blue_char = "";
  87.          j = 0;
  88.          while(j < blue_pool.length)
  89.          {
  90.             blue_pool[j].onEnterFrame = function()
  91.             {
  92.                this._alpha -= Math.random() * 6;
  93.                if(this._alpha < 50 && !this.lol)
  94.                {
  95.                   var _loc3_ = _root.attachMovie("score_plus","s" + l++,l);
  96.                   _loc3_._x = this._x;
  97.                   _loc3_._y = this._y - 20;
  98.                   if(Math.round(Math.random() * 2) == 1)
  99.                   {
  100.                      var _loc4_ = new Sound(_root);
  101.                      _loc4_.attachSound("score");
  102.                      _loc4_.start(0,1);
  103.                   }
  104.                   this.lol = true;
  105.                }
  106.                if(this._alpha < 20)
  107.                {
  108.                   score++;
  109.                   this.onEnterFrame = null;
  110.                   this.removeMovieClip();
  111.                }
  112.             };
  113.             j++;
  114.          }
  115.          blue_pool = new Array(blue_pool.length);
  116.          aqua1.lettre.gotoAndStop(1);
  117.       }
  118.    }
  119. };
  120. _root.onEnterFrame = function()
  121. {
  122.    var _loc9_ = getTimer();
  123.    if(mort)
  124.    {
  125.       if(mort2)
  126.       {
  127.          section = "gameover";
  128.          play();
  129.          _root.onEnterFrame = null;
  130.       }
  131.    }
  132.    else if(_loc9_ - last_timer > bubble_timer)
  133.    {
  134.       if(lvl-- == 0)
  135.       {
  136.          if(bubble_timer < 1400)
  137.          {
  138.             bubble_timer -= 80;
  139.          }
  140.          else
  141.          {
  142.             bubble_timer -= 100;
  143.          }
  144.          lvl = 10;
  145.       }
  146.       if(bubble_timer < 1600)
  147.       {
  148.          nbB = Math.round(Math.random() * 2);
  149.       }
  150.       if(bubble_timer < 1400)
  151.       {
  152.          nbB = Math.round(Math.random() * 2);
  153.       }
  154.       if(bubble_timer < 1000)
  155.       {
  156.          lvl = -1;
  157.       }
  158.       var _loc7_ = undefined;
  159.       last_timer = _loc9_;
  160.       _loc7_ = 0;
  161.       while(_loc7_ < nbB)
  162.       {
  163.          var _loc4_ = Math.ceil(Math.random() * 2);
  164.          var bubble_n = Math.ceil(Math.random() * 2);
  165.          var bubble = _root.attachMovie("bubble_" + bubble_n,"bubble_" + depth,depth--);
  166.          var _loc5_ = _root["bubble_exit_" + _loc4_];
  167.          bubble._x = _loc5_._x;
  168.          bubble._y = _loc5_._y;
  169.          bubble.exit_n = _loc4_;
  170.          bubble.bubble_n = bubble_n;
  171.          bubble.yspeed = 1 * Math.random();
  172.          if(Math.ceil(Math.random() * 2) == 1)
  173.          {
  174.             bubble.xspeed = -1 * Math.random() - vitx;
  175.          }
  176.          else
  177.          {
  178.             bubble.xspeed = 1 * Math.random() + vitx;
  179.          }
  180.          bubble.onPress = function()
  181.          {
  182.             if(!this.prisonnier)
  183.             {
  184.                this.bubble.gotoAndStop(1);
  185.                this.down = true;
  186.             }
  187.          };
  188.          bubble.onRelease = function()
  189.          {
  190.             this.down = false;
  191.             this.bubble.play();
  192.          };
  193.          bubble.onReleaseOutside = function()
  194.          {
  195.             this.down = false;
  196.             this.bubble.play();
  197.          };
  198.          bubble.onEnterFrame = function()
  199.          {
  200.             if(_root.mort)
  201.             {
  202.                if(!this.mort)
  203.                {
  204.                   this.mort = true;
  205.                   if(_root.mortBlue && this.prisonnier && this.bubble_n == 1)
  206.                   {
  207.                      this.gotoAndPlay("mort");
  208.                      _root.last_timer = getTimer();
  209.                   }
  210.                   else if(_root.mortGreen && this.prisonnier && this.bubble_n == 2)
  211.                   {
  212.                      this.gotoAndPlay("mort");
  213.                      _root.last_timer = getTimer();
  214.                   }
  215.                   else if(this.prisonnier)
  216.                   {
  217.                      this.onEnterFrame = function()
  218.                      {
  219.                         this._alpha -= Math.random() * 6;
  220.                         if(this._alpha < 50 && !this.lol)
  221.                         {
  222.                            var _loc3_ = _root.attachMovie("score_plus","s" + l++,l);
  223.                            _loc3_._x = this._x;
  224.                            _loc3_._y = this._y - 20;
  225.                            if(Math.round(Math.random() * 2) == 1)
  226.                            {
  227.                               var _loc4_ = new Sound(_root);
  228.                               _loc4_.attachSound("score");
  229.                               _loc4_.start(0,1);
  230.                            }
  231.                            this.lol = true;
  232.                         }
  233.                         if(this._alpha < 20)
  234.                         {
  235.                            score++;
  236.                            this.onEnterFrame = null;
  237.                            this.removeMovieClip();
  238.                         }
  239.                      };
  240.                   }
  241.                   else
  242.                   {
  243.                      this.gotoAndPlay("mort");
  244.                      _root.last_timer = getTimer();
  245.                   }
  246.                }
  247.             }
  248.             else
  249.             {
  250.                this.lastY = this._y;
  251.                this.lastX = this._x;
  252.                if(!this.down)
  253.                {
  254.                   this._y += this.yspeed;
  255.                   this._x += this.xspeed;
  256.                   if(this.hitTest(_root.bubble_enter1_contourd) || this.hitTest(_root.bubble_enter2_contourd))
  257.                   {
  258.                      if(!this.prisonnier)
  259.                      {
  260.                         this.xspeed = 1 * Math.random() + vitx;
  261.                         this._x += vit;
  262.                      }
  263.                      else
  264.                      {
  265.                         this.xspeed = -1 * Math.random() - vitx;
  266.                      }
  267.                   }
  268.                   if(this.hitTest(_root.contour2))
  269.                   {
  270.                      this.xspeed = 1 * Math.random() + vitx;
  271.                      this._y = this.lastY;
  272.                      this._x = this.lastX + vit;
  273.                   }
  274.                   if(this.hitTest(_root.bubble_enter2_contourg) || this.hitTest(_root.bubble_enter1_contourg))
  275.                   {
  276.                      if(!this.prisonnier)
  277.                      {
  278.                         this.xspeed = -1 * Math.random() - vitx;
  279.                         this._x -= vit;
  280.                      }
  281.                      else
  282.                      {
  283.                         this.xspeed = 1 * Math.random() + vitx;
  284.                      }
  285.                   }
  286.                   if(this.hitTest(_root.contour4))
  287.                   {
  288.                      this.xspeed = -1 * Math.random() - vitx;
  289.                      this._y = this.lastY;
  290.                      this._x = this.lastX - vit;
  291.                   }
  292.                   if(this.hitTest(_root.bubble_enter1_contourb) || this.hitTest(_root.bubble_enter2_contourb))
  293.                   {
  294.                      if(!this.prisonnier)
  295.                      {
  296.                         this.yspeed = 1 * Math.random() + vity;
  297.                      }
  298.                      else
  299.                      {
  300.                         this.yspeed = -1 * Math.random() - vity;
  301.                      }
  302.                   }
  303.                   if(this.hitTest(contour3))
  304.                   {
  305.                      this.yspeed = 1 * Math.random();
  306.                      this._y = this.lastY + vit;
  307.                      this._x = this.lastX;
  308.                   }
  309.                   if(this.hitTest(_root.bubble_enter1_contourh) || this.hitTest(_root.bubble_enter2_contourh))
  310.                   {
  311.                      if(!this.prisonnier)
  312.                      {
  313.                         this.yspeed = -1 * Math.random() - vity;
  314.                      }
  315.                      else
  316.                      {
  317.                         this.yspeed = 1 * Math.random() + vity;
  318.                      }
  319.                   }
  320.                   if(this.hitTest(contour1))
  321.                   {
  322.                      this.yspeed = -1 * Math.random() - vity;
  323.                      this._y = this.lastY - vit;
  324.                      this._x = this.lastX;
  325.                   }
  326.                }
  327.                else
  328.                {
  329.                   this._x = _root._xmouse;
  330.                   this._y = _root._ymouse;
  331.                   if(this.hitTest(_root.bubble_enter1_contourh) && blue_char != "" || this.hitTest(_root.bubble_enter2_contourh) && green_char != "")
  332.                   {
  333.                      this.down = false;
  334.                      this.bubble.play();
  335.                      this._y = this.lastY - vit;
  336.                      this._x = this.lastX;
  337.                      this.yspeed = -1 * Math.random() - vity;
  338.                   }
  339.                   else if(this.hitTest(_root.contour1) || this.hitTest(_root.contour3) || this.hitTest(_root.bubble_enter1_contourb) || this.hitTest(_root.bubble_enter2_contourb))
  340.                   {
  341.                      this.down = false;
  342.                      this.bubble.play();
  343.                      this._y = this.lastY - vit;
  344.                      this._x = this.lastX;
  345.                   }
  346.                   else if(this.hitTest(_root.contour2) || this.hitTest(_root.bubble_enter1_contourd))
  347.                   {
  348.                      this.down = false;
  349.                      this.bubble.gotoAndPlay("right");
  350.                      this._y = this.lastY - vit;
  351.                      this._x = this.lastX;
  352.                   }
  353.                   else if(this.hitTest(_root.contour4) || this.hitTest(_root.bubble_enter2_contourg))
  354.                   {
  355.                      this.down = false;
  356.                      this.bubble.gotoAndPlay("left");
  357.                      this._y = this.lastY - vit;
  358.                      this._x = this.lastX;
  359.                   }
  360.                   else
  361.                   {
  362.                      var _loc5_ = undefined;
  363.                      if(this.hitTest(_root.bubble_enter1))
  364.                      {
  365.                         if(this.bubble_n == 1)
  366.                         {
  367.                            var _loc4_ = new Sound(_root);
  368.                            _loc4_.attachSound("score");
  369.                            _loc4_.start(0,1);
  370.                            _root.lastBlue = _root.lastBlue - 1;
  371.                            _root.lastBlueT = _root.lastBlue;
  372.                            _root.aqua1.score.gotoAndPlay(2);
  373.                            this.down = false;
  374.                            this.prisonnier = true;
  375.                            this.bubble.play();
  376.                            this.gotoAndStop("normal");
  377.                            blue_pool[blue_score++] = this;
  378.                            if(blue_score == blue_pool.length)
  379.                            {
  380.                               blue_score = 0;
  381.                               _root.lastBlue = blue_pool.length;
  382.                               blue_char = String.fromCharCode(Math.round(Math.random() * 25) + 65);
  383.                               aqua1.lettre.play();
  384.                               aqua1.lettre.lettre.lettre.text = "PRESS \"" + blue_char + "\"";
  385.                            }
  386.                         }
  387.                         else
  388.                         {
  389.                            _root.mort = true;
  390.                            _root.mortBlue = true;
  391.                         }
  392.                      }
  393.                      if(this.hitTest(_root.bubble_enter2))
  394.                      {
  395.                         if(this.bubble_n == 2)
  396.                         {
  397.                            _loc4_ = new Sound(_root);
  398.                            _loc4_.attachSound("score");
  399.                            _loc4_.start(0,1);
  400.                            _root.lastGreen = _root.lastGreen - 1;
  401.                            _root.lastGreenT = _root.lastGreen;
  402.                            _root.aqua2.score.gotoAndPlay(2);
  403.                            this.down = false;
  404.                            this.prisonnier = true;
  405.                            this.bubble.play();
  406.                            this.gotoAndStop("normal");
  407.                            green_pool[green_score++] = this;
  408.                            if(green_score == green_pool.length)
  409.                            {
  410.                               green_score = 0;
  411.                               _root.lastGreen = green_pool.length;
  412.                               green_char = String.fromCharCode(Math.round(Math.random() * 25) + 65);
  413.                               aqua2.lettre.play();
  414.                               aqua2.lettre.lettre.lettre.text = "PRESS \"" + green_char + "\"";
  415.                            }
  416.                         }
  417.                         else
  418.                         {
  419.                            _root.mortGreen = true;
  420.                            _root.mort = true;
  421.                         }
  422.                      }
  423.                   }
  424.                }
  425.             }
  426.          };
  427.          _loc7_ = _loc7_ + 1;
  428.       }
  429.    }
  430. };
  431.