home *** CD-ROM | disk | FTP | other *** search
/ 600 Games / 600games.iso / Diversos / particles.swf / scripts / __Packages / tgame.as next >
Encoding:
Text File  |  2007-03-20  |  26.4 KB  |  711 lines

  1. class tgame
  2. {
  3.    var commenti;
  4.    var giudizi;
  5.    var i;
  6.    var maxgiudizio;
  7.    var musicmc;
  8.    var ballsoundmc;
  9.    var ballsound;
  10.    var bumpersoundmc;
  11.    var bumpersound;
  12.    var musicsound;
  13.    var mymusicvol;
  14.    var basecolortr;
  15.    var mycolortr;
  16.    var lastedtime;
  17.    var myformat;
  18.    var mymouse;
  19.    var volumer;
  20.    var gotoAndStop;
  21.    var scritte;
  22.    var balls;
  23.    var deltat;
  24.    var deltamult;
  25.    var scrittefinealpha = 100;
  26.    var olddeltatime = getTimer();
  27.    var continousmusic = false;
  28.    var realmaxballs = 15;
  29.    var stoppingsound = false;
  30.    var soundson = true;
  31.    var maxgravity = 0.3;
  32.    var maxspawntime = 50;
  33.    var gametime = 0;
  34.    var mousewasup = true;
  35.    var mouseisdown = false;
  36.    var screenw = 450;
  37.    var screenh = 450;
  38.    var currentballs = 0;
  39.    var maxballs = 20;
  40.    var fpstime = 0;
  41.    var oldmillisecs = getTimer();
  42.    var gamephase = 0;
  43.    var gravity = 0;
  44.    function tgame()
  45.    {
  46.    }
  47.    function init(startsound)
  48.    {
  49.       this.commenti = new Array();
  50.       this.commenti[3] = "EASY PEASY";
  51.       this.commenti[4] = "STILL QUITE EASY";
  52.       this.commenti[5] = "FUN BEGINS NOW";
  53.       this.commenti[6] = "QUITE CHALLENGING";
  54.       this.commenti[7] = "PRETTY TOUGH";
  55.       this.commenti[8] = "VERY TRICKY";
  56.       this.commenti[9] = "TERRIBLY HARD";
  57.       this.commenti[10] = "INSANELY DIFFICULT";
  58.       this.commenti[11] = "TOTALLY NUTS";
  59.       this.commenti[12] = "INCREDIBLY CHALLENGING";
  60.       this.commenti[13] = "ALMOST IMPOSSIBLE";
  61.       this.commenti[14] = "UTTLERLY INCREDIBLE";
  62.       this.commenti[15] = "TOTALLY IMPOSSIBLE";
  63.       this.giudizi = new Array();
  64.       this.i = 0;
  65.       this.giudizi[this.i] = "F: TERRIBLE TRY";
  66.       this.i = this.i + 1;
  67.       this.giudizi[this.i] = "E: BAD EFFORT";
  68.       this.i = this.i + 1;
  69.       this.giudizi[this.i] = "D: POOR PERFORMANCE";
  70.       this.i = this.i + 1;
  71.       this.giudizi[this.i] = "C-:NOT VERY IMPRESSIVE";
  72.       this.i = this.i + 1;
  73.       this.giudizi[this.i] = "C: SATISFACTORY";
  74.       this.i = this.i + 1;
  75.       this.giudizi[this.i] = "C+: NOT BAD";
  76.       this.i = this.i + 1;
  77.       this.giudizi[this.i] = "B-: QUITE GOOD";
  78.       this.i = this.i + 1;
  79.       this.giudizi[this.i] = "B: NICE ROUND!";
  80.       this.i = this.i + 1;
  81.       this.giudizi[this.i] = "B+: GREAT JOB! ";
  82.       this.i = this.i + 1;
  83.       this.giudizi[this.i] = "A-:SERIOUSLY IMPRESSIVE!";
  84.       this.i = this.i + 1;
  85.       this.giudizi[this.i] = "A: STUNNING REFLEXES!";
  86.       this.i = this.i + 1;
  87.       this.giudizi[this.i] = "A+: YOU\'RE THE MAN!";
  88.       this.maxgiudizio = this.i;
  89.       this.scrittefinealpha = 0;
  90.       this.olddeltatime = getTimer();
  91.       this.musicmc = _root.createEmptyMovieClip("musicmc",245);
  92.       this.ballsoundmc = _root.createEmptyMovieClip("ballsoundmc",246);
  93.       this.ballsound = new Sound(this.ballsoundmc);
  94.       this.ballsound.attachSound("ball.mp3");
  95.       this.ballsound.setVolume(250);
  96.       this.bumpersoundmc = _root.createEmptyMovieClip("bumpersoundmc",247);
  97.       this.bumpersound = new Sound(this.bumpersoundmc);
  98.       this.bumpersound.attachSound("bumper.mp3");
  99.       this.bumpersound.setVolume(800);
  100.       this.musicsound = new Sound(this.musicmc);
  101.       this.musicsound.attachSound("112.mp3");
  102.       this.mymusicvol = 100;
  103.       this.musicsound.setVolume(this.mymusicvol);
  104.       this.stoppingsound = false;
  105.       if(this.soundson and startsound)
  106.       {
  107.          this.musicsound.start(0,150);
  108.       }
  109.       this.basecolortr = new flash.geom.ColorTransform(1,1,1,1,0,0,0,0);
  110.       this.mycolortr = new flash.geom.ColorTransform(1,1,1,1,0,51,51,0);
  111.       this.lastedtime = 0;
  112.       this.gamephase = 0;
  113.       this.myformat = new TextFormat();
  114.       this.myformat.font = "verdana11";
  115.       this.myformat.size = 13;
  116.       this.myformat.bold = false;
  117.       this.gametime = 0;
  118.       this.gravity = 0;
  119.       this.currentballs = 0;
  120.       Mouse.hide();
  121.       this.mymouse = _root.attachMovie("ball4mc","mymouse",100);
  122.       this.mymouse.cacheAsBitmap = true;
  123.       this.mymouse.r = 12;
  124.       this.mymouse.x = 0;
  125.       this.mymouse.y = 0;
  126.       this.mymouse._x = -100;
  127.       this.mymouse._y = -100;
  128.       this.mymouse.xv = 0;
  129.       this.mymouse.yv = 0;
  130.       this.mymouse.mass = 1;
  131.       this.mymouse.actualmass = 1;
  132.       this.mymouse.hit = false;
  133.       this.mymouse.xshift = 0;
  134.       this.mymouse.yshift = 0;
  135.       this.mymouse.spawning = true;
  136.       this.mymouse.spawntime = this.maxspawntime;
  137.       this.mymouse._alpha = 0;
  138.       this.mymouse.colortr = new flash.geom.ColorTransform(0.2,0.2,0.9,1,0,0,25.5,0);
  139.       this.mymouse.transform.colorTransform = this.mymouse.colortr;
  140.       var _loc4_ = new flash.filters.DropShadowFilter(2,135,0,1,4,4,0.7,1,false,false,false);
  141.       var _loc3_ = this.mymouse.filters;
  142.       _loc3_.push(_loc4_);
  143.       this.mymouse.filters = _loc3_;
  144.       this.volumer = _root.attachMovie("volumermc","volumer",152);
  145.       this.volumer.onRelease = function()
  146.       {
  147.          _root.game.soundson = !_root.game.soundson;
  148.          if(_root.game.soundson)
  149.          {
  150.             _root.game.musicsound.start(0,150);
  151.             this.gotoAndStop(1);
  152.          }
  153.          if(!_root.game.soundson)
  154.          {
  155.             _root.game.musicsound.stop();
  156.             this.gotoAndStop(2);
  157.          }
  158.       };
  159.       this.volumer._xscale = 16;
  160.       this.volumer._yscale = 16;
  161.       this.volumer._x = 229;
  162.       this.volumer._y = 410;
  163.       _loc3_ = this.volumer.filters;
  164.       _loc3_.push(_loc4_);
  165.       this.volumer.filters = _loc3_;
  166.       if(this.soundson)
  167.       {
  168.          this.volumer.gotoAndStop(1);
  169.       }
  170.       if(!this.soundson)
  171.       {
  172.          this.volumer.gotoAndStop(2);
  173.       }
  174.       this.volumer._visible = false;
  175.       this.scritte = new Array();
  176.       this.i = 0;
  177.       while(this.i < 8)
  178.       {
  179.          if(this.i <= 4 or this.i >= 7)
  180.          {
  181.             this.scritte[this.i] = _root.createEmptyMovieClip("scritte" + this.i,11100 + this.i);
  182.          }
  183.          else
  184.          {
  185.             this.scritte[this.i] = _root.createEmptyMovieClip("scritte" + this.i,this.i);
  186.          }
  187.          this.scritte[this.i].createTextField("scritta",0,0,0,0,0);
  188.          this.scritte[this.i].scritta.textColor = 0;
  189.          this.scritte[this.i].scritta.setNewTextFormat(this.myformat);
  190.          this.scritte[this.i]._xscale = 100;
  191.          this.scritte[this.i]._yscale = 100;
  192.          this.scritte[this.i].scritta.autoSize = true;
  193.          this.scritte[this.i].scritta.selectable = false;
  194.          this.scritte[this.i]._visible = false;
  195.          _loc3_ = this.scritte[this.i].filters;
  196.          _loc3_.push(_loc4_);
  197.          this.scritte[this.i].filters = _loc3_;
  198.          this.scritte[this.i].scritta.embedFonts = true;
  199.          this.i = this.i + 1;
  200.       }
  201.       this.scritte[5].scritta.text = "3 BALLS";
  202.       this.scritte[5].stoptime = 0;
  203.       this.scritte[5]._xscale = 120;
  204.       this.scritte[5]._xscale = 120;
  205.       this.scritte[5]._x = this.screenw / 2 - this.scritte[5]._width / 2;
  206.       this.scritte[5]._y = 190;
  207.       this.scritte[5].phase = 0;
  208.       this.scritte[1].onRelease = function()
  209.       {
  210.          _root.game.gamephase = 2;
  211.          Mouse.hide();
  212.       };
  213.       this.scritte[2].onRelease = function()
  214.       {
  215.          _root.game.gamephase = 3;
  216.       };
  217.       this.scritte[3].onRelease = function()
  218.       {
  219.          getUrl("http://www.ragdollsoft.com", "blank");
  220.       };
  221.       this.balls = new Array();
  222.       this.i = 0;
  223.       while(this.i < this.maxballs)
  224.       {
  225.          this.balls[this.i] = _root.attachMovie("ball4mc","ball" + this.i,this.i + 10);
  226.          this.balls[this.i].mass = 1;
  227.          this.balls[this.i].actualmass = 1;
  228.          this.balls[this.i].r = 12;
  229.          this.balls[this.i].x = Math.random() * (this.screenw - 2 * this.balls[this.i].r) + this.balls[this.i].r;
  230.          this.balls[this.i].y = Math.random() * (this.screenh - 2 * this.balls[this.i].r) + this.balls[this.i].r;
  231.          this.balls[this.i].colored = false;
  232.          this.balls[this.i].oldx = this.balls[this.i].x;
  233.          this.balls[this.i].oldy = this.balls[this.i].y;
  234.          this.balls[this.i].xv = (Math.random() - 0.5) * 10 * 1.5;
  235.          this.balls[this.i].yv = (Math.random() - 0.5) * 10 * 1.5;
  236.          this.balls[this.i].angle = Math.random() * 3.141592653589793 * 2;
  237.          this.balls[this.i].xv = Math.sin(this.balls[this.i].angle) * 6.5;
  238.          this.balls[this.i].yv = Math.cos(this.balls[this.i].angle) * 6.5;
  239.          this.balls[this.i].xshift = 0;
  240.          this.balls[this.i].yshift = 0;
  241.          this.balls[this.i]._visible = false;
  242.          this.balls[this.i].cacheAsBitmap = true;
  243.          this.balls[this.i].spawning = true;
  244.          this.balls[this.i].spawntime = this.maxspawntime;
  245.          this.balls[this.i].colortr = new flash.geom.ColorTransform(0.9,0.2,0.2,1,25.5,0,0,0);
  246.          this.balls[this.i].transform.colorTransform = this.balls[this.i].colortr;
  247.          _loc3_ = this.balls[this.i].filters;
  248.          _loc3_.push(_loc4_);
  249.          this.balls[this.i].filters = _loc3_;
  250.          this.i = this.i + 1;
  251.       }
  252.       this.balls[0].colored = true;
  253.       this.i = 0;
  254.       while(this.i < this.currentballs)
  255.       {
  256.          this.balls[this.i]._visible = true;
  257.          this.i = this.i + 1;
  258.       }
  259.    }
  260.    function mainloop()
  261.    {
  262.       this.deltat = getTimer() - this.olddeltatime;
  263.       this.deltamult = Math.min(this.deltat,40) / 28.571428571428573;
  264.       this.olddeltatime = getTimer();
  265.       var _loc3_ = undefined;
  266.       var _loc4_ = undefined;
  267.       this.fpstime += 1;
  268.       if(!this.continousmusic and this.stoppingsound)
  269.       {
  270.          this.mymusicvol -= 1 * this.deltamult;
  271.          this.musicsound.setVolume(this.mymusicvol);
  272.          if(this.mymusicvol < 0)
  273.          {
  274.             this.musicsound.stop();
  275.             this.stoppingsound = false;
  276.          }
  277.       }
  278.       this.handlescritta();
  279.       if(this.gamephase == 0)
  280.       {
  281.          if(!this.mymouse.hit)
  282.          {
  283.             this.lastedtime += 1 * this.deltamult;
  284.          }
  285.          if(getTimer() - this.oldmillisecs > 1000)
  286.          {
  287.             this.fpstime = 0;
  288.             this.oldmillisecs = getTimer();
  289.          }
  290.          if(!this.mymouse.hit and !this.mymouse.spawning)
  291.          {
  292.             if(this.currentballs < this.realmaxballs)
  293.             {
  294.                this.gametime += 1 * this.deltamult;
  295.             }
  296.             if(this.gametime > 35 * (this.currentballs - 1) * 7)
  297.             {
  298.                this.gametime = 0;
  299.                this.currentballs += 1;
  300.                this.balls[this.currentballs - 1]._visible = true;
  301.                this.scritte[5].scritta.text = this.currentballs + " BALLS";
  302.                this.scritte[5].phase = 1;
  303.                this.scritte[5]._alpha = 0;
  304.                this.scritte[5]._visible = true;
  305.                this.scritte[5].stoptime = 0;
  306.                this.scritte[6].scritta.text = this.commenti[this.currentballs];
  307.                this.scritte[6]._alpha = 0;
  308.                this.scritte[6]._visible = true;
  309.                this.scritte[6]._x = this.screenw / 2 - this.scritte[6]._width / 2;
  310.                this.scritte[6]._y = 220;
  311.             }
  312.          }
  313.          if(this.mymouse.spawning)
  314.          {
  315.             this.mymouse._alpha = (this.maxspawntime - this.mymouse.spawntime) / this.maxspawntime * 100;
  316.             this.mymouse.spawntime -= 1 * this.deltamult;
  317.             if(this.mymouse.spawntime < 0)
  318.             {
  319.                this.mymouse.spawning = false;
  320.                this.mymouse._alpha = 100;
  321.                this.currentballs = 3;
  322.                this.scritte[5].scritta.text = this.currentballs + " BALLS";
  323.                this.scritte[5].phase = 1;
  324.                this.scritte[5]._alpha = 0;
  325.                this.scritte[5]._visible = true;
  326.                this.scritte[5].stoptime = 0;
  327.                this.scritte[6].scritta.text = this.commenti[this.currentballs];
  328.                this.scritte[6]._alpha = 0;
  329.                this.scritte[6]._visible = true;
  330.                this.scritte[6]._x = this.screenw / 2 - this.scritte[6]._width / 2;
  331.                this.scritte[6]._y = 220;
  332.                this.gametime = 0;
  333.                _loc3_ = 0;
  334.                while(_loc3_ < 3)
  335.                {
  336.                   this.balls[_loc3_]._visible = true;
  337.                   _loc3_ = _loc3_ + 1;
  338.                }
  339.             }
  340.          }
  341.          _loc3_ = 0;
  342.          while(_loc3_ < this.currentballs)
  343.          {
  344.             if(this.balls[_loc3_].spawning)
  345.             {
  346.                this.balls[_loc3_]._alpha = (this.maxspawntime - this.balls[_loc3_].spawntime) / this.maxspawntime * 100;
  347.                this.balls[_loc3_].spawntime -= 1 * this.deltamult;
  348.                if(this.balls[_loc3_].spawntime < 0)
  349.                {
  350.                   this.balls[_loc3_].spawning = false;
  351.                   this.balls[_loc3_]._alpha = 100;
  352.                }
  353.             }
  354.             _loc3_ = _loc3_ + 1;
  355.          }
  356.          if(this.mymouse.hit)
  357.          {
  358.             this.mymouse.yv += this.gravity * this.deltamult;
  359.             this.mymouse.x += this.mymouse.xv * this.deltamult;
  360.             this.mymouse.y += this.mymouse.yv * this.deltamult;
  361.          }
  362.          _loc3_ = 0;
  363.          while(_loc3_ < this.currentballs)
  364.          {
  365.             if(!this.balls[_loc3_].spawning)
  366.             {
  367.                this.balls[_loc3_].yv += this.gravity * this.deltamult;
  368.                this.balls[_loc3_].x += this.balls[_loc3_].xv * this.deltamult;
  369.                this.balls[_loc3_].y += this.balls[_loc3_].yv * this.deltamult;
  370.             }
  371.             _loc3_ = _loc3_ + 1;
  372.          }
  373.          this.mymouse.xshift = 0;
  374.          this.mymouse.yshift = 0;
  375.          _loc3_ = 0;
  376.          while(_loc3_ < this.currentballs)
  377.          {
  378.             this.balls[_loc3_].xshift = 0;
  379.             this.balls[_loc3_].yshift = 0;
  380.             _loc3_ = _loc3_ + 1;
  381.          }
  382.          _loc3_ = 0;
  383.          while(_loc3_ < this.currentballs)
  384.          {
  385.             _loc4_ = _loc3_ + 1;
  386.             while(_loc4_ < this.currentballs)
  387.             {
  388.                if((this.balls[_loc3_].x - this.balls[_loc4_].x) * (this.balls[_loc3_].x - this.balls[_loc4_].x) + (this.balls[_loc3_].y - this.balls[_loc4_].y) * (this.balls[_loc3_].y - this.balls[_loc4_].y) < (this.balls[_loc3_].r + this.balls[_loc4_].r) * (this.balls[_loc3_].r + this.balls[_loc4_].r) and !this.balls[_loc3_].spawning and !this.balls[_loc4_].spawning)
  389.                {
  390.                   this.collision(this.balls[_loc3_],this.balls[_loc4_]);
  391.                }
  392.                _loc4_ = _loc4_ + 1;
  393.             }
  394.             _loc3_ = _loc3_ + 1;
  395.          }
  396.          _loc4_ = 0;
  397.          while(_loc4_ < this.currentballs)
  398.          {
  399.             if(!this.balls[_loc4_].spawning)
  400.             {
  401.                if((this.mymouse.x - this.balls[_loc4_].x) * (this.mymouse.x - this.balls[_loc4_].x) + (this.mymouse.y - this.balls[_loc4_].y) * (this.mymouse.y - this.balls[_loc4_].y) < (this.mymouse.r + this.balls[_loc4_].r) * (this.mymouse.r + this.balls[_loc4_].r))
  402.                {
  403.                   this.collision(this.mymouse,this.balls[_loc4_]);
  404.                   this.mymouse.hit = true;
  405.                   this.gravity = this.maxgravity;
  406.                   if(!this.continousmusic)
  407.                   {
  408.                      this.stoppingsound = true;
  409.                   }
  410.                }
  411.             }
  412.             _loc4_ = _loc4_ + 1;
  413.          }
  414.          _loc3_ = 0;
  415.          while(_loc3_ < this.currentballs)
  416.          {
  417.             this.balls[_loc3_].x += this.balls[_loc3_].xshift;
  418.             this.balls[_loc3_].y += this.balls[_loc3_].yshift;
  419.             _loc3_ = _loc3_ + 1;
  420.          }
  421.          this.mymouse.x += this.mymouse.xshift;
  422.          this.mymouse.y += this.mymouse.yshift;
  423.          if(!this.mymouse.hit)
  424.          {
  425.             this.mymouse.x = _root._xmouse;
  426.             this.mymouse.y = _root._ymouse;
  427.             this.mymouse.xv = 0;
  428.             this.mymouse.yv = 0;
  429.          }
  430.          this.bordercollision();
  431.          _loc3_ = 0;
  432.          while(_loc3_ < this.currentballs)
  433.          {
  434.             this.balls[_loc3_]._x = this.balls[_loc3_].x;
  435.             this.balls[_loc3_]._y = this.balls[_loc3_].y;
  436.             _loc3_ = _loc3_ + 1;
  437.          }
  438.          this.mymouse._x = this.mymouse.x;
  439.          this.mymouse._y = this.mymouse.y;
  440.       }
  441.       if(this.mymouse.hit and this.gamephase == 0)
  442.       {
  443.          var _loc6_ = 1;
  444.          _loc3_ = 0;
  445.          while(_loc3_ < this.currentballs)
  446.          {
  447.             if(this.balls[_loc3_].y < this.screenh + 100)
  448.             {
  449.                _loc6_ = 0;
  450.             }
  451.             _loc3_ = _loc3_ + 1;
  452.          }
  453.          if(this.mymouse.y < this.screenh + 100)
  454.          {
  455.             _loc6_ = 0;
  456.          }
  457.          if(_loc6_)
  458.          {
  459.             Mouse.show();
  460.             this.gamephase = 1;
  461.             var _loc5_ = 1;
  462.             var _loc9_ = 1;
  463.             var _loc7_ = 40;
  464.             var _loc8_ = 30;
  465.             this.scritte[4].scritta.text = "YOU REACHED " + this.currentballs + " BALLS";
  466.             this.scritte[4]._xscale = _loc9_ * 100;
  467.             this.scritte[4]._yscale = _loc9_ * 100;
  468.             this.scritte[4]._x = this.screenw / 2 - this.scritte[4]._width / 2;
  469.             this.scritte[4]._y = 70 + _loc8_;
  470.             this.scritte[4]._visible = true;
  471.             this.scritte[0].scritta.text = "YOU LASTED " + Math.floor(this.lastedtime / 35) + " SECONDS";
  472.             this.scritte[0]._xscale = _loc5_ * 100;
  473.             this.scritte[0]._yscale = _loc5_ * 100;
  474.             this.scritte[0]._x = this.screenw / 2 - this.scritte[0]._width / 2;
  475.             this.scritte[0]._y = 110 + _loc8_;
  476.             this.scritte[0]._visible = true;
  477.             this.scritte[7].scritta.text = "GRADE " + this.giudizi[Math.min(Math.floor(this.lastedtime / 35 / 15),this.maxgiudizio)];
  478.             this.scritte[7]._xscale = _loc5_ * 100;
  479.             this.scritte[7]._yscale = _loc5_ * 100;
  480.             this.scritte[7]._x = this.screenw / 2 - this.scritte[7]._width / 2;
  481.             this.scritte[7]._y = 150 + _loc8_;
  482.             this.scritte[7]._visible = true;
  483.             this.scritte[1].scritta.text = "PLAY AGAIN";
  484.             this.scritte[1]._xscale = 100 * _loc5_;
  485.             this.scritte[1]._yscale = 100 * _loc5_;
  486.             this.scritte[1]._x = this.screenw / 2 - this.scritte[1]._width / 2;
  487.             this.scritte[1]._y = 200 + _loc7_;
  488.             this.scritte[1]._visible = true;
  489.             this.scritte[2].scritta.text = "BACK TO MENU";
  490.             this.scritte[2]._xscale = 100 * _loc5_;
  491.             this.scritte[2]._yscale = 100 * _loc5_;
  492.             this.scritte[2]._x = this.screenw / 2 - this.scritte[2]._width / 2;
  493.             this.scritte[2]._y = 240 + _loc7_;
  494.             this.scritte[2]._visible = true;
  495.             this.scritte[3].scritta.text = "MORE GAMES BY ME";
  496.             this.scritte[3]._xscale = 100 * _loc5_;
  497.             this.scritte[3]._yscale = 100 * _loc5_;
  498.             this.scritte[3]._x = this.screenw / 2 - this.scritte[3]._width / 2;
  499.             this.scritte[3]._y = 280 + _loc7_;
  500.             this.scritte[3]._visible = true;
  501.             this.mymouse._alpha = 0;
  502.             this.volumer._visible = true;
  503.          }
  504.       }
  505.       if(this.gamephase == 1)
  506.       {
  507.          if(this.scrittefinealpha < 100)
  508.          {
  509.             this.scrittefinealpha += 3 * this.deltamult;
  510.          }
  511.       }
  512.       if(this.gamephase == 2)
  513.       {
  514.          this.scrittefinealpha -= 3 * this.deltamult;
  515.          if(this.scrittefinealpha <= 0)
  516.          {
  517.             if(!_root.game.continousmusic)
  518.             {
  519.                _root.game.musicsound.stop();
  520.             }
  521.             _root.game.init(!_root.game.continousmusic);
  522.          }
  523.       }
  524.       if(this.gamephase == 3)
  525.       {
  526.          this.scrittefinealpha -= 3 * this.deltamult;
  527.          if(this.scrittefinealpha <= 0)
  528.          {
  529.             _root.game.musicsound.stop();
  530.             _root.gotoAndPlay("mainmenu");
  531.          }
  532.       }
  533.       if(this.gamephase > 0)
  534.       {
  535.          _loc3_ = 0;
  536.          while(_loc3_ < 5)
  537.          {
  538.             this.scritte[_loc3_]._alpha = this.scrittefinealpha;
  539.             _loc3_ = _loc3_ + 1;
  540.          }
  541.          _loc3_ = 7;
  542.          while(_loc3_ < 8)
  543.          {
  544.             this.scritte[_loc3_]._alpha = this.scrittefinealpha;
  545.             _loc3_ = _loc3_ + 1;
  546.          }
  547.          this.volumer._alpha = this.scrittefinealpha;
  548.       }
  549.    }
  550.    function handlescritta()
  551.    {
  552.       if(this.scritte[5].phase == 1)
  553.       {
  554.          this.scritte[5]._alpha += 2 * this.deltamult;
  555.          this.scritte[6]._alpha = this.scritte[5]._alpha;
  556.          if(this.scritte[5]._alpha > 100)
  557.          {
  558.             this.scritte[5].phase = 2;
  559.          }
  560.       }
  561.       if(this.scritte[5].phase == 2)
  562.       {
  563.          this.scritte[5].stoptime += 1 * this.deltamult;
  564.          if(this.scritte[5].stoptime > 10)
  565.          {
  566.             this.scritte[5].phase = 3;
  567.          }
  568.       }
  569.       if(this.scritte[5].phase == 3)
  570.       {
  571.          this.scritte[5]._alpha -= 2 * this.deltamult;
  572.          this.scritte[6]._alpha = this.scritte[5]._alpha;
  573.          if(this.scritte[5]._alpha <= 0)
  574.          {
  575.             this.scritte[6]._visible = false;
  576.             this.scritte[5]._visible = false;
  577.             this.scritte[5].phase = 0;
  578.          }
  579.       }
  580.    }
  581.    function bordercollision()
  582.    {
  583.       var _loc2_ = 0.01;
  584.       var _loc3_ = 1;
  585.       var _loc4_ = 40 * this.mymusicvol / 100;
  586.       this.i = 0;
  587.       while(this.i < this.currentballs)
  588.       {
  589.          if(this.balls[this.i].x < 0 + this.balls[this.i].r)
  590.          {
  591.             this.bumpersound.setVolume(Math.abs(this.balls[this.i].xv) * _loc4_);
  592.             if(this.soundson)
  593.             {
  594.                this.bumpersound.start();
  595.             }
  596.             this.balls[this.i].x = 0 + _loc2_ + this.balls[this.i].r;
  597.             this.balls[this.i].xv = (- this.balls[this.i].xv) * _loc3_;
  598.          }
  599.          if(this.balls[this.i].x > this.screenw - this.balls[this.i].r)
  600.          {
  601.             this.bumpersound.setVolume(Math.abs(this.balls[this.i].xv) * _loc4_);
  602.             if(this.soundson)
  603.             {
  604.                this.bumpersound.start();
  605.             }
  606.             this.balls[this.i].x = this.screenw - _loc2_ - this.balls[this.i].r;
  607.             this.balls[this.i].xv = (- this.balls[this.i].xv) * _loc3_;
  608.          }
  609.          if(this.balls[this.i].y > this.screenh - this.balls[this.i].r and !this.mymouse.hit)
  610.          {
  611.             this.bumpersound.setVolume(Math.abs(this.balls[this.i].yv) * _loc4_);
  612.             if(this.soundson)
  613.             {
  614.                this.bumpersound.start();
  615.             }
  616.             this.balls[this.i].y = this.screenh - _loc2_ - this.balls[this.i].r;
  617.             this.balls[this.i].yv = (- this.balls[this.i].yv) * _loc3_;
  618.          }
  619.          if(this.balls[this.i].y < 0 + this.balls[this.i].r)
  620.          {
  621.             this.bumpersound.setVolume(Math.abs(this.balls[this.i].yv) * _loc4_);
  622.             if(this.soundson)
  623.             {
  624.                this.bumpersound.start();
  625.             }
  626.             this.balls[this.i].y = 0 + _loc2_ + this.balls[this.i].r;
  627.             this.balls[this.i].yv = (- this.balls[this.i].yv) * _loc3_;
  628.          }
  629.          this.i = this.i + 1;
  630.       }
  631.       if(this.mymouse.x < 0 + this.mymouse.r)
  632.       {
  633.          this.mymouse.x = 0 + _loc2_ + this.mymouse.r;
  634.          this.mymouse.xv = (- this.mymouse.xv) * _loc3_;
  635.       }
  636.       if(this.mymouse.x > this.screenw - this.mymouse.r)
  637.       {
  638.          this.mymouse.x = this.screenw - _loc2_ - this.mymouse.r;
  639.          this.mymouse.xv = (- this.mymouse.xv) * _loc3_;
  640.       }
  641.       if(this.mymouse.y > this.screenh - this.mymouse.r and !this.mymouse.hit)
  642.       {
  643.          this.mymouse.y = this.screenh - _loc2_ - this.mymouse.r;
  644.          this.mymouse.yv = (- this.mymouse.yv) * _loc3_;
  645.       }
  646.       if(this.mymouse.y < 0 + this.mymouse.r)
  647.       {
  648.          this.mymouse.y = 0 + _loc2_ + this.mymouse.r;
  649.          this.mymouse.yv = (- this.mymouse.yv) * _loc3_;
  650.       }
  651.    }
  652.    function collision(ball1, ball2)
  653.    {
  654.       var _loc5_ = 1.0000000000000001e-7;
  655.       var _loc15_ = 3000;
  656.       var _loc14_ = 50 * this.mymusicvol / 100;
  657.       var _loc7_ = ball2.x - ball1.x;
  658.       var _loc6_ = ball2.y - ball1.y;
  659.       var _loc4_ = Math.sqrt(_loc7_ * _loc7_ + _loc6_ * _loc6_);
  660.       var _loc9_ = ball1.r + ball2.r;
  661.       if(_loc4_ < _loc9_)
  662.       {
  663.          var _loc13_ = ball2.xv - ball1.xv;
  664.          var _loc12_ = ball2.yv - ball1.yv;
  665.          if(Math.abs(_loc4_) < _loc5_)
  666.          {
  667.             _loc4_ = _loc5_;
  668.          }
  669.          if(Math.abs(_loc7_) < _loc5_)
  670.          {
  671.             _loc7_ = _loc5_;
  672.          }
  673.          if(Math.abs(_loc6_) < _loc5_)
  674.          {
  675.             _loc6_ = _loc5_;
  676.          }
  677.          var _loc8_ = _loc6_ / _loc7_;
  678.          if(Math.abs(_loc8_) < _loc5_)
  679.          {
  680.             _loc8_ = _loc5_;
  681.          }
  682.          var _loc10_ = -1 * (_loc12_ + 1 / _loc8_ * _loc13_) / (_loc8_ + 1 / _loc8_);
  683.          var _loc11_ = _loc10_ * _loc8_;
  684.          ball1.xshift -= (_loc9_ + 0.01 - _loc4_) * _loc7_ / _loc4_ * ball1.actualmass / (ball1.actualmass + ball2.actualmass);
  685.          ball1.yshift -= (_loc9_ + 0.01 - _loc4_) * _loc6_ / _loc4_ * ball1.actualmass / (ball1.actualmass + ball2.actualmass);
  686.          ball2.xshift += (_loc9_ + 0.01 - _loc4_) * _loc7_ / _loc4_ * ball2.actualmass / (ball1.actualmass + ball2.actualmass);
  687.          ball2.yshift += (_loc9_ + 0.01 - _loc4_) * _loc6_ / _loc4_ * ball2.actualmass / (ball1.actualmass + ball2.actualmass);
  688.          ball1.xv -= _loc10_ * 2 * ball1.actualmass / (ball1.actualmass + ball2.actualmass);
  689.          ball1.yv -= _loc11_ * 2 * ball1.actualmass / (ball1.actualmass + ball2.actualmass);
  690.          ball2.xv += _loc10_ * 2 * ball2.actualmass / (ball1.actualmass + ball2.actualmass);
  691.          ball2.yv += _loc11_ * 2 * ball2.actualmass / (ball1.actualmass + ball2.actualmass);
  692.          this.ballsound.setVolume(Math.sqrt(_loc10_ * _loc10_ + _loc11_ * _loc11_) * _loc14_);
  693.          if(this.soundson)
  694.          {
  695.             this.ballsound.start();
  696.          }
  697.       }
  698.    }
  699.    function repulse(ball1, ball2)
  700.    {
  701.       var _loc4_ = 3000;
  702.       var _loc3_ = ball2.x - ball1.x;
  703.       var _loc2_ = ball2.y - ball1.y;
  704.       var _loc1_ = Math.sqrt(_loc3_ * _loc3_ + _loc2_ * _loc2_);
  705.       ball1.xshift += (- _loc4_) * _loc3_ / _loc1_ / _loc1_ / _loc1_;
  706.       ball2.xshift += _loc4_ * _loc3_ / _loc1_ / _loc1_ / _loc1_;
  707.       ball1.yshift += (- _loc4_) * _loc2_ / _loc1_ / _loc1_ / _loc1_;
  708.       ball2.yshift += _loc4_ * _loc2_ / _loc1_ / _loc1_ / _loc1_;
  709.    }
  710. }
  711.