home *** CD-ROM | disk | FTP | other *** search
/ 600 Games / 600games.iso / Nave / StarWar.swf / scripts / frame_1 / DoAction.as
Encoding:
Text File  |  2005-08-05  |  3.6 KB  |  160 lines

  1. function shipparent()
  2. {
  3.    this.rotation = 0;
  4.    this.xpos = 100;
  5.    this.ypos = 300;
  6.    this.xlration = 0;
  7.    this.rockets = 1;
  8.    this.xspeed = 0;
  9.    this.yspeed = 0;
  10.    this.hitstatus = 0;
  11. }
  12. function rocketparent()
  13. {
  14.    this.rotation = 0;
  15.    this.xpos = -50;
  16.    this.ypos = -50;
  17.    this.xlration = 0;
  18.    this.distancetravelled = 0;
  19.    this.xspeedship = 0;
  20.    this.yspeedship = 0;
  21.    this.xspeed = 0;
  22.    this.yspeed = 0;
  23. }
  24. function rightturn()
  25. {
  26.    ship.rotation += 5;
  27. }
  28. function leftturn()
  29. {
  30.    ship.rotation -= 5;
  31. }
  32. function forward()
  33. {
  34.    tellTarget(car)
  35.    {
  36.       gotoAndPlay(5);
  37.    }
  38.    if(8 >= ship.xlration)
  39.    {
  40.       ship.xlration += 0.3;
  41.    }
  42. }
  43. function slowdown()
  44. {
  45.    if(0 < ship.xlration)
  46.    {
  47.       ship.xlration -= 0.1;
  48.    }
  49. }
  50. function fire()
  51. {
  52.    if(counter >= 30)
  53.    {
  54.       counter = 0;
  55.       if(ship.rockets < 50)
  56.       {
  57.          rocketarray.unshift(ship.rockets);
  58.          rocket[ship.rockets].xspeedship = ship.xspeed;
  59.          rocket[ship.rockets].yspeedship = ship.yspeed;
  60.          setProperty(rocket add ship.rockets, _rotation, ship.rotation);
  61.          setProperty(rocket add ship.rockets, _X, ship.xpos);
  62.          setProperty(rocket add ship.rockets, _Y, ship.ypos);
  63.          rocket[ship.rockets].rotation = ship.rotation;
  64.          ship.rockets += 1;
  65.          rocketsleft -= 1;
  66.          if(rocketsleft == 0)
  67.          {
  68.             gotoAndStop(10);
  69.          }
  70.       }
  71.    }
  72. }
  73. function moverockets()
  74. {
  75.    x = 0;
  76.    while(rocketarray.length >= x)
  77.    {
  78.       i = rocketarray[x];
  79.       if(eval(rocket add i).hitTest(_root.enemy))
  80.       {
  81.          ship.hitstatus += 1;
  82.          shipscore = ship.hitstatus;
  83.          blah = rocketarray.pop();
  84.          tellTarget(rocket add i)
  85.          {
  86.             play();
  87.          }
  88.       }
  89.       rocket[i].xpos = getProperty(rocket add i, _X);
  90.       rocket[i].ypos = getProperty(rocket add i, _Y);
  91.       rocket[i].xlration += 0.5;
  92.       rocket[i].xspeed = Math.sin(0.017453292519943295 * rocket[i].rotation) + rocket[i].xspeedship;
  93.       rocket[i].yspeed = - Math.cos(0.017453292519943295 * rocket[i].rotation) + rocket[i].yspeedship;
  94.       rocket[i].xpos += rocket[i].xspeed * rocket[i].xlration;
  95.       rocket[i].ypos += rocket[i].yspeed * rocket[i].xlration;
  96.       setProperty(rocket add i, _X, rocket[i].xpos);
  97.       setProperty(rocket add i, _Y, rocket[i].ypos);
  98.       rocket[i].distancetravelled += 1;
  99.       if(140 < rocket[i].distancetravelled)
  100.       {
  101.          blah = rocketarray.pop();
  102.          tellTarget(rocket add i)
  103.          {
  104.             play();
  105.          }
  106.       }
  107.       x++;
  108.    }
  109. }
  110. function moveship()
  111. {
  112.    dir = car._rotation + 180;
  113.    ship.xspeed = newsin[dir] * (- ship.xlration);
  114.    ship.yspeed = newcos[dir] * ship.xlration;
  115.    ship.xpos += ship.xspeed;
  116.    ship.ypos += ship.yspeed;
  117.    if(ship.xpos >= 650)
  118.    {
  119.       ship.xpos = -40;
  120.    }
  121.    else if(-40 >= ship.xpos)
  122.    {
  123.       ship.xpos = 650;
  124.    }
  125.    if(ship.ypos >= 400)
  126.    {
  127.       ship.ypos = -40;
  128.    }
  129.    else if(-40 >= ship.ypos)
  130.    {
  131.       ship.ypos = 400;
  132.    }
  133.    setProperty(car, _rotation, ship.rotation);
  134.    setProperty(car, _X, ship.xpos);
  135.    setProperty(car, _Y, ship.ypos);
  136. }
  137. ship = new shipparent();
  138. i = 1;
  139. while(50 >= i)
  140. {
  141.    rocket[i] = new rocketparent();
  142.    duplicateMovieClip(rocket,"rocket" add i,16384 + i);
  143.    i++;
  144. }
  145. shipscore = 0;
  146. rocketsleft = 49;
  147. rocketarray = [];
  148. counter = 0;
  149. statecounter = 0;
  150. statelength = 0;
  151. newsin = [];
  152. newcos = [];
  153. i = 1;
  154. while(360 >= i)
  155. {
  156.    newsin[i] = Math.sin(0.017453292519943295 * i);
  157.    newcos[i] = Math.cos(0.017453292519943295 * i);
  158.    i++;
  159. }
  160.