home *** CD-ROM | disk | FTP | other *** search
/ 600 Games / 600games.iso / Aventura / tall-ships.swf / scripts / frame_7 / DoAction.as < prev   
Encoding:
Text File  |  2005-09-29  |  7.1 KB  |  275 lines

  1. function restartLeg()
  2. {
  3.    if(Key.isDown(32))
  4.    {
  5.       gotoAndStop("restartSlideShow2");
  6.    }
  7. }
  8. function moveBG(target, bg)
  9. {
  10.    bg._x -= Math.cos(target.radians) * target.speed + Math.cos(target.momentumRad) * target.momentumSpeed;
  11.    bg._y -= Math.sin(target.radians) * target.speed + Math.sin(target.momentumRad) * target.momentumSpeed;
  12. }
  13. function moveClouds(target, bg)
  14. {
  15.    bg._x -= (Math.cos(target.radians) * target.speed + Math.cos(target.momentumRad) * target.momentumSpeed) * 2;
  16.    bg._y -= (Math.sin(target.radians) * target.speed + Math.sin(target.momentumRad) * target.momentumSpeed) * 2;
  17. }
  18. function hitIceBergs(target)
  19. {
  20.    if(tutorialMap_mc.tutorialIceBergs_mc.hitTest(target._x,target._y,true))
  21.    {
  22.       target.hitIceBerg = true;
  23.    }
  24.    else
  25.    {
  26.       target.hitIceBerg = false;
  27.    }
  28. }
  29. function hitRocks(target)
  30. {
  31.    if(tutorialMap_mc.tutorialRocks_mc.hitTest(target._x,target._y,true))
  32.    {
  33.       target.hitRock = true;
  34.    }
  35.    else
  36.    {
  37.       target.hitRock = false;
  38.    }
  39. }
  40. function hitStorms(target)
  41. {
  42.    if(tutorialStormLayer_mc.hitTest(target._x,target._y,true))
  43.    {
  44.       target.hitStorm = true;
  45.    }
  46.    else
  47.    {
  48.       target.hitStorm = false;
  49.    }
  50. }
  51. function hitWhales(target)
  52. {
  53.    if(tutorialMap_mc.tutorialWhales_mc.hitTest(target._x,target._y,true))
  54.    {
  55.       target.hitWhale = true;
  56.    }
  57.    else
  58.    {
  59.       target.hitWhale = false;
  60.    }
  61. }
  62. function turnIt(target)
  63. {
  64.    if(Key.isDown(37))
  65.    {
  66.       target._rotation -= target.turning;
  67.       target.degrees -= target.turning;
  68.       if(target.degrees < 0)
  69.       {
  70.          target.degrees += 360;
  71.       }
  72.       tutorialShipLayer_mc.ship3d_mc.gotoAndStop(Math.floor(target.degrees / 12));
  73.    }
  74.    if(Key.isDown(39))
  75.    {
  76.       target._rotation += target.turning;
  77.       target.degrees += target.turning;
  78.       if(target.degrees > 360)
  79.       {
  80.          target.degrees -= 360;
  81.       }
  82.       tutorialShipLayer_mc.ship3d_mc.gotoAndStop(Math.floor(target.degrees / 12));
  83.    }
  84.    if(target.hitStorm)
  85.    {
  86.       target._rotation += target.turning * 2;
  87.       target.degrees += target.turning * 2;
  88.       if(target.degrees > 360)
  89.       {
  90.          target.degrees -= 360;
  91.       }
  92.       tutorialShipLayer_mc.ship3d_mc.gotoAndStop(Math.floor(target.degrees / 12));
  93.    }
  94.    target.radians = (target._rotation + 30) * 3.141592653589793 / 180;
  95. }
  96. function changeSpeed(target)
  97. {
  98.    target.momentumSpeed *= 0.97;
  99.    if(target.momentumSpeed < 0.05)
  100.    {
  101.       target.momentumSpeed = 0;
  102.    }
  103.    if(Key.isDown(38) && target.speed < target.maxSpeed)
  104.    {
  105.       target.speed += target.acceleration;
  106.       if(target.speed > target.maxSpeed)
  107.       {
  108.          target.speed = target.maxSpeed;
  109.       }
  110.       if(target.momentumSpeed < target.speed)
  111.       {
  112.          target.momentumSpeed = target.speed;
  113.       }
  114.       target.momentumRad = target.radians;
  115.    }
  116.    else
  117.    {
  118.       target.speed *= 0.96;
  119.    }
  120.    if(Key.isDown(40) && target.speed > 0)
  121.    {
  122.       target.speed -= target.braking;
  123.       if(target.speed < 0.05)
  124.       {
  125.          target.speed = 0;
  126.       }
  127.    }
  128.    if(target.speed < 0.05)
  129.    {
  130.       target.speed = 0;
  131.    }
  132.    if(target.hitLand)
  133.    {
  134.       target.speed = 0.5;
  135.       target.momentumSpeed = 0;
  136.       if(pointsMinus_mc._currentframe == 1)
  137.       {
  138.          pointsMinus_mc.displayText = "4";
  139.          pointsMinus_mc.gotoAndPlay("start");
  140.          if(timer.seconds >= 4)
  141.          {
  142.             timer.seconds -= 4;
  143.          }
  144.          else
  145.          {
  146.             timer.seconds = 0;
  147.          }
  148.       }
  149.    }
  150.    else if(target.hitIceBerg)
  151.    {
  152.       target.speed = 0.5;
  153.       target.momentumSpeed = 0;
  154.       if(pointsMinus_mc._currentframe == 1)
  155.       {
  156.          pointsMinus_mc.displayText = "3";
  157.          pointsMinus_mc.gotoAndPlay("start");
  158.          if(timer.seconds >= 3)
  159.          {
  160.             timer.seconds -= 3;
  161.          }
  162.          else
  163.          {
  164.             timer.seconds = 0;
  165.          }
  166.       }
  167.    }
  168.    else if(target.hitRock)
  169.    {
  170.       target.speed = 0.5;
  171.       target.momentumSpeed = 0;
  172.       if(pointsMinus_mc._currentframe == 1)
  173.       {
  174.          pointsMinus_mc.displayText = "2";
  175.          pointsMinus_mc.gotoAndPlay("start");
  176.          if(timer.seconds >= 2)
  177.          {
  178.             timer.seconds -= 2;
  179.          }
  180.          else
  181.          {
  182.             timer.seconds = 0;
  183.          }
  184.       }
  185.    }
  186.    else if(target.hitWhale)
  187.    {
  188.       target.speed = 0.5;
  189.       target.momentumSpeed = 0;
  190.       if(pointsMinus_mc._currentframe == 1)
  191.       {
  192.          pointsMinus_mc.displayText = "3";
  193.          pointsMinus_mc.gotoAndPlay("start");
  194.          if(timer.seconds >= 3)
  195.          {
  196.             timer.seconds -= 3;
  197.          }
  198.          else
  199.          {
  200.             timer.seconds = 0;
  201.          }
  202.       }
  203.    }
  204. }
  205. stop();
  206. _quality = "HIGH";
  207. detailToggle_mc._visible = false;
  208. soundToggle_mc._visible = false;
  209. tutorialShip_mc._rotation = _global.shipRotation;
  210. switch(_global.shipClass)
  211. {
  212.    case "A":
  213.       tutorialShipLayer_mc.attachMovie("shipA","ship3d_mc",1);
  214.       tutorialShipLayer_mc.ship3d_mc._x = 231;
  215.       tutorialShipLayer_mc.ship3d_mc._y = 178;
  216.       tutorialShip_mc.radians = (tutorialShip_mc._rotation + 30) * 3.141592653589793 / 180;
  217.       tutorialShip_mc.maxSpeed = 6;
  218.       tutorialShip_mc.acceleration = 0.1;
  219.       tutorialShip_mc.braking = 2;
  220.       tutorialShip_mc.turning = 12;
  221.       break;
  222.    case "B":
  223.       tutorialShipLayer_mc.attachMovie("shipB","ship3d_mc",1);
  224.       tutorialShipLayer_mc.ship3d_mc._x = 231;
  225.       tutorialShipLayer_mc.ship3d_mc._y = 178;
  226.       tutorialShip_mc.radians = (tutorialShip_mc._rotation + 30) * 3.141592653589793 / 180;
  227.       tutorialShip_mc.maxSpeed = 5.5;
  228.       tutorialShip_mc.acceleration = 0.2;
  229.       tutorialShip_mc.braking = 2;
  230.       tutorialShip_mc.turning = 12;
  231.       break;
  232.    case "C":
  233.       tutorialShipLayer_mc.attachMovie("shipC","ship3d_mc",1);
  234.       tutorialShipLayer_mc.ship3d_mc._x = 231;
  235.       tutorialShipLayer_mc.ship3d_mc._y = 178;
  236.       tutorialShip_mc.radians = (tutorialShip_mc._rotation + 30) * 3.141592653589793 / 180;
  237.       tutorialShip_mc.maxSpeed = 5;
  238.       tutorialShip_mc.acceleration = 0.5;
  239.       tutorialShip_mc.braking = 2;
  240.       tutorialShip_mc.turning = 12;
  241. }
  242. tutorialShip_mc.degrees = _global.shipRotation;
  243. tutorialShipLayer_mc.ship3d_mc.gotoAndStop(Math.floor(tutorialShip_mc.degrees / 12));
  244. tutorialShip_mc.momentumRad = tutorialShip_mc.radians;
  245. tutorialShip_mc.momentumSpeed = 0;
  246. tutorialShip_mc.speed = 0;
  247. tutorialShip_mc.waterTrail = 0;
  248. tutorialShip_mc.orangeBuoys = 0;
  249. tutorialShip_mc.hitLand = false;
  250. tutorialShip_mc.hitIceBerg = false;
  251. tutorialShip_mc.hitRock = false;
  252. tutorialShip_mc.hitStorm = false;
  253. tutorialShip_mc.finished = false;
  254. tutorialShip_mc.onEnterFrame = function()
  255. {
  256.    moveBG(this,tutorialMap_mc);
  257.    changeSpeed(this);
  258.    turnIt(this);
  259.    hitIceBergs(this);
  260.    hitRocks(this);
  261.    hitStorms(this);
  262.    hitWhales(this);
  263.    restartLeg();
  264. };
  265. btnNext_mc.onRelease = function()
  266. {
  267.    gotoAndStop("slideShow3");
  268.    play();
  269. };
  270. btnBack_mc.onRelease = function()
  271. {
  272.    gotoAndStop("slideShow1");
  273.    play();
  274. };
  275.