home *** CD-ROM | disk | FTP | other *** search
/ 600 Games / 600games.iso / Acao / pearlharbour.swf / scripts / frame_112 / DoAction.as
Encoding:
Text File  |  2005-09-29  |  7.3 KB  |  298 lines

  1. if(watertouch eq true)
  2. {
  3.    if(Key.isDown(Key.LEFT))
  4.    {
  5.       modThrust = 0.15;
  6.    }
  7.    else if(Key.isDown(Key.RIGHT))
  8.    {
  9.       modThrust = -0.25;
  10.    }
  11.    else
  12.    {
  13.       modThrust = -0.1;
  14.    }
  15. }
  16. else
  17. {
  18.    modThrust = -0.06;
  19. }
  20. shootX = _root.clickX;
  21. shootY = _root.clickY;
  22. gunX = boatX + _root.boat.unit._X;
  23. gunY = boatY + _root.boat.unit._Y;
  24. aimX = _root._xmouse;
  25. aimY = _root._ymouse;
  26. shootHyp = Math.sqrt((gunX - aimX) * (gunX - aimX) + (gunY - aimY) * (gunY - aimY));
  27. shootRad = Math.acos((gunX - aimX) / shootHyp);
  28. shootAng = shootRad * 57.29577951308232;
  29. _root.boat.unit.unitGun._rotation = shootAng - 90 - boatSlope;
  30. if(_root.fire and NrOfShots < 2)
  31. {
  32.    NrOfShots++;
  33.    if(shootNr eq 3)
  34.    {
  35.       shootNr = 0;
  36.    }
  37.    else
  38.    {
  39.       shootNr++;
  40.    }
  41.    shootSpeed = shootHyp / 20;
  42.    shot[shootNr].shootSpeedX = - shootSpeed * Math.cos(shootRad);
  43.    shot[shootNr].shootSpeedY = - shootSpeed * Math.sin(shootRad);
  44.    shot[shootNr].shootX = gunX;
  45.    shot[shootNr].shootY = gunY;
  46.    shot[shootNr].timer = 20;
  47.    bullet = eval("_root.bullet" + shootNr);
  48.    _root.bullet._x = shot[shootNr].shootX;
  49.    _root.bullet._y = shot[shootNr].shootY;
  50.    _root.bullet._rotation = shootAng - 90;
  51.    _root.bullet.gotoAndStop(1);
  52.    _root.fire = false;
  53. }
  54. i = 0;
  55. while(i < 4)
  56. {
  57.    bullet = eval("_root.bullet" + i);
  58.    shot[i].shootY += shot[i].shootSpeedY;
  59.    shot[i].shootX += shot[i].shootSpeedX + boatXspeed;
  60.    bullet._x = shot[i].shootX;
  61.    bullet._y = shot[i].shootY;
  62.    if(-1 < shot[i].timer)
  63.    {
  64.       shot[i].timer--;
  65.       if(0 >= shot[i].timer)
  66.       {
  67.          shot[i].shootSpeedX = 0;
  68.          shot[i].shootSpeedY = 0;
  69.          grenadeexp.start();
  70.          bullet.play();
  71.          shot[i].timer = -1;
  72.          NrOfShots--;
  73.          t = 0;
  74.          while(t < FooTotal.length)
  75.          {
  76.             planeObj = FooTotal[t];
  77.             if(planeObj.planeX < 600 and -80 < planeObj.planeX and 0 < planeObj.health)
  78.             {
  79.                foX = planeObj.planeX;
  80.                foY = planeObj.planeY;
  81.                ppX = shot[i].shootX;
  82.                ppY = shot[i].shootY;
  83.                damageHyp = Math.sqrt((ppX - foX) * (ppX - foX) + (ppY - foY) * (ppY - foY));
  84.                if(damageHyp < 20)
  85.                {
  86.                   planeClip = eval("_root." + planeObj.name);
  87.                   planeClip.gotoAndPlay("HIT");
  88.                   planeObj.health -= 1;
  89.                   if(planeObj.health < 1)
  90.                   {
  91.                      planeClip.gotoAndPlay("ROLL");
  92.                      planeObj.fallspeed = 0.1;
  93.                      planeObj.tilt = -1;
  94.                   }
  95.                }
  96.             }
  97.             t++;
  98.          }
  99.       }
  100.    }
  101.    i++;
  102. }
  103. waveXspeed = curentXspeed + boatXspeed;
  104. tmpWaveX = waveX + waveXspeed;
  105. if(tmpWaveX < newWaveValue)
  106. {
  107.    waveX += waveXspeed;
  108. }
  109. else
  110. {
  111.    newWaveValue += waveLength;
  112.    newx = (- waveLength) * wavesPast;
  113.    wavechange = eval("_root.waveGrid.wave" + w);
  114.    wavechange._x = newx;
  115.    wavechange._yscale = waveArray[w].size * 14;
  116.    if(w eq 0)
  117.    {
  118.       w = 4;
  119.    }
  120.    else
  121.    {
  122.       w--;
  123.    }
  124.    wavesPast++;
  125.    if(w < 2)
  126.    {
  127.       currentWave = w + 3;
  128.    }
  129.    else
  130.    {
  131.       currentWave = w - 2;
  132.    }
  133.    waveSize = waveArray[currentWave].size;
  134.    waveCurve = waveSize * 2.5;
  135.    waveJumpPoint = - (waveSize * 2 - 1);
  136.    waveX += waveXspeed;
  137. }
  138. waveOldHeight = waveHeight;
  139. waveHeight = waveSize * Math.sin(6.283185307179586 / waveLength * (waveX + waveLength * 0.25));
  140. waveHeight -= waveSize;
  141. waveSlope = waveCurve * Math.sin(6.283185307179586 / waveLength * waveX);
  142. waveYforce = waveHeight - waveOldHeight;
  143. waveY = waveHeight + waterYline;
  144. if(waveHeight < waveJumpPoint and 3 < boatXspeed and watertouch eq true and 10 < nextJump)
  145. {
  146.    nextjump = 0;
  147.    jumpHeight = 0;
  148.    watertouch = false;
  149.    jump = true;
  150.    tmpAccSlope = AccSlope;
  151.    if(tmpAccSlope < 0)
  152.    {
  153.       tmpAccSlope = 0;
  154.    }
  155.    upForce = - boatXspeed * (waveSize / 15) * (1 + tmpAccSlope / 8);
  156. }
  157. if(jump eq true)
  158. {
  159.    if(jumpHeight < waterYline - boatY)
  160.    {
  161.       jumpHeight = waterYline - boatY;
  162.       jumpHeighttxt = Math.round(jumpHeight * 100) / 100;
  163.       recordlineY = boatY;
  164.    }
  165.    boatY += upForce;
  166.    upForce += grav;
  167.    boatSlope -= 0.5;
  168.    if(waveY < boatY)
  169.    {
  170.       if(jumpRecord < jumpHeight)
  171.       {
  172.          jumpRecord = jumpHeight;
  173.          jumpRecordtxt = Math.round(jumpRecord * 100) / 100;
  174.          _root.recordline._y = recordlineY;
  175.       }
  176.       if(s eq 1)
  177.       {
  178.          s = 0;
  179.       }
  180.       else
  181.       {
  182.          s = 1;
  183.       }
  184.       splash = eval("_root.splash" + s);
  185.       _root.splash._yscale = upForce * 5;
  186.       _root.splash._x = boatX;
  187.       _root.splash._y = waveY;
  188.       _root.splash._visible = true;
  189.       _root.splash.play();
  190.       jump = false;
  191.       watertouch = true;
  192.       BoatAcc -= waveSlope / 10;
  193.       boatY = waveY;
  194.       boatSlope = waveSlope;
  195.    }
  196. }
  197. else
  198. {
  199.    boatY = waveY;
  200.    boatSlope = waveSlope;
  201. }
  202. boatAcc += modThrust;
  203. if(boatAcc < 0)
  204. {
  205.    boatAcc = 0;
  206. }
  207. if(10 < boatAcc)
  208. {
  209.    boatAcc = 10;
  210. }
  211. boatOldSpeed = boatXspeed;
  212. boatXspeed = boatTopSpeed * Math.sin(0.3141592653589793 * (boatAcc - 5));
  213. boatXspeed += boatTopSpeed;
  214. boatXspeed /= 2;
  215. if(boatXspeed < 0)
  216. {
  217.    boatXspeed = 0;
  218. }
  219. BoatAccelerate = (boatXspeed - boatOldSpeed) * 50;
  220. if(AccSlope < BoatAccelerate)
  221. {
  222.    AccSlope += 0.5;
  223. }
  224. else if(BoatAccelerate < AccSlope - 1)
  225. {
  226.    AccSlope -= 0.5;
  227. }
  228. nextjump += 1;
  229. levelplacement += boatXspeed;
  230. mapfooX = FooTotal[0].planeX / 10;
  231. mapunitX = - levelplacement / 10;
  232. _root.map.mapunit._x = mapunitX;
  233. _root.map.mapfoo._x = mapfooX;
  234. i = 0;
  235. while(i < FooTotal.length)
  236. {
  237.    planeObj = FooTotal[i];
  238.    planeObj.planeX -= planeObj.speed - boatXspeed;
  239.    planeObj.elevation += planeObj.fallspeed;
  240.    planeObj.planeY += planeObj.elevation;
  241.    planeObj.rotation += planeObj.tilt;
  242.    if(planeObj.planeX < 600 and -80 < planeObj.planeX)
  243.    {
  244.       if(typeof eval(planeObj.name) ne "movieclip")
  245.       {
  246.          planedepth++;
  247.          plane.duplicateMovieClip(planeObj.name,planedepth);
  248.       }
  249.       planeClip = eval("_root." + planeObj.name);
  250.       planeClip._x = planeObj.planeX;
  251.       planeClip._Y = planeObj.planeY;
  252.       planeClip._rotation = planeObj.rotation;
  253.       if(waterYline < planeObj.planeY)
  254.       {
  255.          _root.splash10._yscale = 50;
  256.          _root.splash10._x = planeObj.planeX;
  257.          _root.splash10._y = waterYline;
  258.          trace("SPLASH");
  259.          _root.splash10.gotoAndPlay(2);
  260.          planeObj.planeX = 600;
  261.          planeObj.planeY = 100;
  262.          planeObj.speed = 0;
  263.          planeObj.fallspeed = 0;
  264.          planeObj.elevation = 0;
  265.       }
  266.    }
  267.    else
  268.    {
  269.       planeClip = eval("_root." + planeObj.name);
  270.       planeClip.removeMovieClip();
  271.    }
  272.    i++;
  273. }
  274. _root.splash10._x += waveXspeed;
  275. _root.bubbles._x += waveXspeed;
  276. _root.splash0._x += waveXspeed;
  277. _root.splash1._x += waveXspeed;
  278. _root.waveGrid._x = waveX;
  279. _root.boat._y = boatY;
  280. _root.boat._x = boatX;
  281. _root.boat._rotation = boatSlope + AccSlope * 2;
  282. if(-4 < _root.background._x)
  283. {
  284.    _root.background._x = -530;
  285. }
  286. else
  287. {
  288.    _root.background._x += boatXspeed / 5;
  289. }
  290. if(560 < _root.island._x)
  291. {
  292.    _root.island._x = -20;
  293. }
  294. else
  295. {
  296.    _root.island._x += boatXspeed / 2;
  297. }
  298.