home *** CD-ROM | disk | FTP | other *** search
/ 600 Games / 600games.iso / Nave / squadron_angel.swf / scripts / frame_3 / DoAction.as < prev   
Encoding:
Text File  |  2007-03-20  |  7.7 KB  |  304 lines

  1. scrollDecor = function()
  2. {
  3.    malus1._x -= vitesseScroll / 1.5;
  4.    bonus1._x -= vitesseScroll / 1.5;
  5.    nuageMotor._x -= vitesseScroll;
  6.    nuage._x -= vitesseScroll * 1.2;
  7.    if(gagne == 1)
  8.    {
  9.       if(decor1._x >= consigneDecor)
  10.       {
  11.          decor1._x -= vitesseScroll / 2;
  12.          decor2._x -= vitesseScroll / 4;
  13.       }
  14.    }
  15.    else
  16.    {
  17.       decor1._x -= vitesseScroll / 2;
  18.       decor2._x -= vitesseScroll / 4;
  19.    }
  20. };
  21. numPlane = numPlane != undefined ? numPlane : 1;
  22. stop();
  23. initPlane = function(plane)
  24. {
  25.    var _loc1_ = plane;
  26.    if(_loc1_ == 1)
  27.    {
  28.       fuelMax = 25000;
  29.       numPlane = 1;
  30.       speedScroll = 1.1;
  31.       speedPlane = 1.5;
  32.    }
  33.    else if(_loc1_ == 2)
  34.    {
  35.       fuelMax = 15000;
  36.       numPlane = 2;
  37.       speedScroll = 1.8;
  38.       speedPlane = 1.5;
  39.    }
  40.    else if(_loc1_ == 3)
  41.    {
  42.       fuelMax = 45000;
  43.       numPlane = 3;
  44.       speedScroll = 1;
  45.       speedPlane = 0.5;
  46.    }
  47. };
  48. makeFuel = function(leTime)
  49. {
  50.    var _loc1_ = leTime;
  51.    _loc1_ = Math.min(fuelMax,_loc1_);
  52.    fuel_gauge._xscale = 100 - Math.max(0,_loc1_ / fuelMax * 100);
  53.    fuelMC.jauge._yscale = Math.max(0,_loc1_ / fuelMax * 100);
  54.    fuelMC.aiguille._rotation = Math.max(0,100 - Math.max(0,_loc1_ / Max * 100));
  55.    if(_loc1_ / fuelMax * 100 <= 30)
  56.    {
  57.       fuelAlarma.gotoAndStop(2);
  58.    }
  59.    else
  60.    {
  61.       fuelAlarma.gotoAndStop(1);
  62.    }
  63.    return Math.max(0,Math.round(_loc1_ / fuelMax * 100));
  64. };
  65. startGame = function()
  66. {
  67.    heart1.gotoAndStop(1);
  68.    heart2.gotoAndStop(1);
  69.    heart3.gotoAndStop(1);
  70.    heart4.gotoAndStop(1);
  71.    plane.plane.gotoAndStop(numPlane);
  72.    hauteurJeu = 280;
  73.    nombreTablo = 20;
  74.    fuel = fuelMax;
  75.    motorSND.stop();
  76.    motorSND.start(0,99999);
  77.    motorSND.setVolume(0);
  78.    plane._x = 40;
  79.    decor1._x = 0;
  80.    decor2._x = 0;
  81.    indiceFond = 0;
  82.    decor1.fond1.gotoAndStop(1);
  83.    decor1.fond2.gotoAndStop(2);
  84.    decor1.fond1._x = 0;
  85.    decor1.fond2._x = decor1.fond1._x + decor1.fond1._width - 2;
  86.    decor2.fond1._x = 0;
  87.    decor2.fond2._x = decor2.fond1._x + decor2.fond1._width - 2;
  88.    positionneBonus(bonus1);
  89.    positionneMalus(malus1);
  90.    positionneNuage();
  91.    plane.gotoAndStop(1);
  92.    plane._y = hauteurJeu;
  93.    casse = 0;
  94.    panne = 0;
  95.    dejaDecol = 0;
  96.    starter = 0;
  97.    bonus = 0;
  98.    pressed = 0;
  99.    malus = 0;
  100.    casse = 0;
  101.    firstKey = 0;
  102.    noKey = 0;
  103.    debGame = Math.round(new Date().getTime());
  104.    fuel = makeFuel(fuelMax);
  105.    plane.gaz = 0;
  106.    plane.angle = 0;
  107.    this.onEnterFrame = function()
  108.    {
  109.       if(plane._y < hauteurJeu - 20)
  110.       {
  111.          dejaDecol = 1;
  112.       }
  113.       volumeVal = Math.max(0,plane.gaz * 2);
  114.       motorSND.setVolume(volumeVal / 3);
  115.       trace("volumeVal " + volumeVal);
  116.       if(starter == 1 && !panne && !casse)
  117.       {
  118.          fuel = makeFuel(fuelMax - (Math.round(new Date().getTime()) - debGame - bonus * 4500));
  119.          if(fuel <= 0 && panne == 0)
  120.          {
  121.             panneSND.start(0,1);
  122.          }
  123.          if(fuel <= 0)
  124.          {
  125.             fuel = 0;
  126.             panne = 1;
  127.          }
  128.          else
  129.          {
  130.             panne = 0;
  131.          }
  132.       }
  133.       noKey = 1;
  134.       if(!casse && !panne && firstKey == 1)
  135.       {
  136.          if(Math.round(Math.random() * 10) == 2)
  137.          {
  138.             this.attachMovie("nuage","nuageMotor",10,{_y:plane._y,_x:plane._x});
  139.          }
  140.       }
  141.       if(Key.isDown(32))
  142.       {
  143.          if(starter != 1)
  144.          {
  145.             debGame = Math.round(new Date().getTime());
  146.             firstKey = 1;
  147.          }
  148.          starter = 1;
  149.          if(!casse && !panne)
  150.          {
  151.             plane.angle -= 0.001 * plane.gaz * 1.3 * speedPlane;
  152.             plane.gaz += 0.6;
  153.             pressed = 1;
  154.             noKey = 0;
  155.          }
  156.       }
  157.       if(plane.plane.hitAreaMC.hitTest(bonus1))
  158.       {
  159.          bonus += 1;
  160.          positionneBonus(bonus1);
  161.          bonusSND.start();
  162.       }
  163.       if(plane.plane.hitAreaMC.hitTest(malus1))
  164.       {
  165.          malus += 1;
  166.          plane.plane.plane.gotoAndStop(malus);
  167.          eval("heart" + malus).gotoAndPlay(2);
  168.          positionneMalus(malus1);
  169.          malusSND.start();
  170.          if(malus >= 5)
  171.          {
  172.             casse = 1;
  173.             plane.gotoAndStop(2);
  174.          }
  175.       }
  176.       if(noKey == 1)
  177.       {
  178.          if(pressed == 1)
  179.          {
  180.             if(plane._y <= hauteurJeu)
  181.             {
  182.                plane.gaz -= 0.3;
  183.                if(decor1._x < -300 || dejaDecol)
  184.                {
  185.                   plane.angle += 0.03 * speedPlane;
  186.                }
  187.             }
  188.          }
  189.       }
  190.       plane.gaz = Math.max(plane.gaz,0);
  191.       plane.gaz = Math.min(plane.gaz,20);
  192.       if(plane._y < 80)
  193.       {
  194.          plane.angle *= plane._y / 80;
  195.       }
  196.       vitesseScroll = Math.max(0,plane.gaz * Math.cos(plane.angle) * speedScroll);
  197.       scrollDecor();
  198.       if(nuage._x < - nuage._width)
  199.       {
  200.          positionneNuage();
  201.       }
  202.       if(decor1._x + decor1.fond1._x < - decor1.fond1._width - 2)
  203.       {
  204.          indiceFond++;
  205.          decor1.fond1._x = decor1.fond2._x + decor1.fond1._width - 2;
  206.          if(indiceFond == nombreTablo)
  207.          {
  208.             gotoAndStop("gagne");
  209.             decor1.fond1.gotoAndStop(3);
  210.             lastDecor = decor1.fond1;
  211.          }
  212.          else
  213.          {
  214.             decor1.fond1.gotoAndStop(2);
  215.          }
  216.       }
  217.       if(decor1._x + decor1.fond2._x < - decor1.fond1._width - 2)
  218.       {
  219.          indiceFond++;
  220.          decor1.fond2._x = decor1.fond1._x + decor1.fond1._width - 2;
  221.          if(indiceFond == nombreTablo)
  222.          {
  223.             gotoAndStop("gagne");
  224.             lastDecor = decor1.fond2;
  225.             decor1.fond2.gotoAndStop(3);
  226.          }
  227.          else
  228.          {
  229.             decor1.fond2.gotoAndStop(2);
  230.          }
  231.       }
  232.       distanceLeft = Math.round((decor1.fond1._width - 2) * nombreTablo + decor1._x);
  233.       distanceLeft = Math.max(0,distanceLeft);
  234.       if(decor2._x + decor2.fond1._x < - decor2.fond1._width - 2)
  235.       {
  236.          decor2.fond1._x = decor2.fond2._x + decor2.fond1._width - 2;
  237.       }
  238.       if(decor2._x + decor2.fond2._x < - decor2.fond1._width - 2)
  239.       {
  240.          decor2.fond2._x = decor2.fond1._x + decor2.fond1._width - 2;
  241.       }
  242.       plane._y += plane.gaz * Math.sin(plane.angle) + 30 / (plane.gaz + 0.1);
  243.       if(plane._x < 150)
  244.       {
  245.          plane._x += plane.gaz / 4;
  246.       }
  247.       if(plane._y > hauteurJeu && plane.angle > 0.1)
  248.       {
  249.          plane._y = hauteurJeu;
  250.          trace(decor1._x);
  251.          if(decor1._x < -300 || dejaDecol)
  252.          {
  253.             casse = 1;
  254.             plane.gotoAndStop(2);
  255.             gotoAndStop("PERDU");
  256.             motorSND.stop();
  257.          }
  258.          else
  259.          {
  260.             plane.angle = 0;
  261.             plane.gaz = 0;
  262.          }
  263.       }
  264.       if(bonus1._x < -200)
  265.       {
  266.          positionneBonus(bonus1);
  267.       }
  268.       if(malus1._x < -200)
  269.       {
  270.          positionneMalus(malus1);
  271.       }
  272.       plane._y = Math.min(plane._y,hauteurJeu);
  273.       if(!casse)
  274.       {
  275.          plane._rotation = plane.angle * 180 / 3.141592653589793;
  276.       }
  277.    };
  278. };
  279. positionneBonus = function(leBonus)
  280. {
  281.    var _loc1_ = leBonus;
  282.    _loc1_._x = 600 + Math.random() * 1900;
  283.    _loc1_._y = 60 + Math.random() * (hauteurJeu - 80);
  284.    if(_loc1_ == malus1)
  285.    {
  286.       _loc1_.gotoAndStop(Math.ceil(Math.random() * 3));
  287.    }
  288. };
  289. positionneMalus = function(leBonus)
  290. {
  291.    var _loc1_ = leBonus;
  292.    _loc1_._x = 600 + Math.random() * 500;
  293.    _loc1_._y = 0 + Math.random() * (hauteurJeu - 50);
  294.    if(_loc1_ == malus1)
  295.    {
  296.       _loc1_.gotoAndStop(Math.ceil(Math.random() * 3));
  297.    }
  298. };
  299. positionneNuage = function()
  300. {
  301.    nuage._x = 600 + Math.random() * 2900;
  302.    nuage._y = Math.random() * (hauteurJeu - 100);
  303. };
  304.