home *** CD-ROM | disk | FTP | other *** search
/ 600 Games / 600games.iso / Nave / 30k_starfighter.swf / scripts / frame_2 / DoAction.as
Encoding:
Text File  |  2006-07-26  |  9.6 KB  |  418 lines

  1. function spawnShip()
  2. {
  3.    layer++;
  4.    _root.attachMovie("ship","ship",layer);
  5.    layer++;
  6. }
  7. function makeStats()
  8. {
  9.    textFormat = new TextFormat();
  10.    textFormat.color = 16777215;
  11.    textFormat.font = "Verdana";
  12.    textFormat.size = 18;
  13.    _root.createTextField("scoreText",MAX_LAYER,scoreTextX,scoreTextY,600,50);
  14.    _root.createTextField("bonusText",MAX_LAYER + 1,bonusTextX,bonusTextY,600,50);
  15.    _root.createTextField("livesText",MAX_LAYER + 2,livesTextX,livesTextY,300,50);
  16.    _root.createTextField("multiText",MAX_LAYER + 3,multiTextX,multiTextY,300,50);
  17. }
  18. function randomizeWaves()
  19. {
  20.    i = 1;
  21.    while(i <= 6)
  22.    {
  23.       _root["waveO" + i].species = "ufo" + Math.floor(Math.random() * 3.99 + 1);
  24.       _root["waveO" + i].funct = "wave" + Math.floor(Math.random() * 5.99 + 1);
  25.       _root["waveO" + i].population = Math.floor(Math.random() * 4) + 7;
  26.       _root["waveO" + i].shotProb = Math.random() * 0.015;
  27.       i++;
  28.    }
  29. }
  30. function powerUpDrop(pux, puy)
  31. {
  32.    layer++;
  33.    randomNum = Math.floor(Math.random() * 100);
  34.    if(randomNum < 15)
  35.    {
  36.       PUtype = "rapidFire";
  37.    }
  38.    else if(randomNum < 30)
  39.    {
  40.       PUtype = "upgrade";
  41.    }
  42.    else if(randomNum < 40)
  43.    {
  44.       PUtype = "helper";
  45.    }
  46.    else if(randomNum < 50)
  47.    {
  48.       PUtype = "speedUp";
  49.    }
  50.    else if(randomNum < 58)
  51.    {
  52.       PUtype = "multiplierUp";
  53.    }
  54.    else if(randomNum < 65)
  55.    {
  56.       PUtype = "lifeUp";
  57.    }
  58.    else if(randomNum < 70)
  59.    {
  60.       PUtype = "death";
  61.    }
  62.    else if(randomNum < 80)
  63.    {
  64.       PUtype = "bankrupt";
  65.    }
  66.    else if(randomNum < 90)
  67.    {
  68.       PUtype = "slowDown";
  69.    }
  70.    else
  71.    {
  72.       PUtype = "scoreUp";
  73.    }
  74.    attachMovie(PUtype,PUtype + layer,layer);
  75.    _root[PUtype + _root.layer]._x = pux;
  76.    _root[PUtype + _root.layer]._y = puy;
  77. }
  78. function firstWave()
  79. {
  80.    clearInterval(newWaveInterval);
  81.    currentWave = waveO1;
  82.    intervalFunct = "createEnemy";
  83.    intervalTime = currentWave.freq;
  84.    intervalID = "waves";
  85.    waves = setInterval(createEnemy,currentWave.freq);
  86. }
  87. function newWave()
  88. {
  89.    clearInterval(newWaveInterval);
  90.    currentWave = currentWave.nextWave;
  91.    if(currentWave == null)
  92.    {
  93.       currentWave = waveOne;
  94.    }
  95.    intervalFunct = "createEnemy";
  96.    intervalTime = currentWave.freq;
  97.    intervalID = "waves";
  98.    waves = setInterval(createEnemy,currentWave.freq);
  99. }
  100. function createEnemy()
  101. {
  102.    waveCount++;
  103.    layer++;
  104.    if(fullRandom == true && currentWave != waveO6)
  105.    {
  106.       randomizeWaves();
  107.       fullRandom = false;
  108.    }
  109.    else if(currentWave.randomWaves == true)
  110.    {
  111.       fullRandom = true;
  112.       randomInt = Math.floor(Math.random() * 5.99 + 1);
  113.       currentWave.funct = "wave" + randomInt;
  114.    }
  115.    if(currentWave.funct == "wave2" || currentWave.funct == "wave4" || currentWave.funct == "wave6")
  116.    {
  117.       currentWave.startPoint = upperRight;
  118.    }
  119.    else
  120.    {
  121.       currentWave.startPoint = upperLeft;
  122.    }
  123.    _root.attachMovie(currentWave.species,currentWave.species + layer,layer,currentWave.startPoint);
  124.    _root[currentWave.species + layer].goFunct = _root[currentWave.funct];
  125.    _root[currentWave.species + layer].onEnterFrame = _root[currentWave.species + layer].goFunct;
  126.    if(currentWave.altFunct != null)
  127.    {
  128.       tempFunctHolder = currentWave.funct;
  129.       currentWave.funct = currentWave.altFunct;
  130.       currentWave.altFunct = tempFunctHolder;
  131.    }
  132.    enemyArray[waveCount].destroy();
  133.    enemyArray[waveCount] = _root[currentWave.species + layer];
  134.    layer++;
  135.    if(waveCount >= currentWave.population)
  136.    {
  137.       if(layer > MAX_LAYER / 30)
  138.       {
  139.          layer = 5;
  140.       }
  141.       waveCount = 0;
  142.       clearInterval(waves);
  143.       intervalFunct = "newWave";
  144.       intervalTime = currentWave.nextWave.pause;
  145.       intervalID = "newWaveInterval";
  146.       newWaveInterval = setInterval(newWave,currentWave.nextWave.pause);
  147.    }
  148. }
  149. function pause()
  150. {
  151.    _quality = "HIGH";
  152.    clearInterval(waves);
  153.    clearInterval(newWaveInterval);
  154.    clearInterval(_root[intervalID]);
  155.    for(name in _root)
  156.    {
  157.       _root[name]._alpha = 50;
  158.       _root[name].onEnterFrame = null();
  159.    }
  160.    showList._alpha = 100;
  161.    starBG.stop();
  162.    starBG2.stop();
  163.    starBG3.stop();
  164.    starBG4.stop();
  165.    _root.onEnterFrame = unpause;
  166. }
  167. function unpause()
  168. {
  169.    if(Key.isDown(32))
  170.    {
  171.       _quality = "LOW";
  172.       _root[intervalID] = setInterval(_root[intervalFunct],intervalTime);
  173.       for(name in _root)
  174.       {
  175.          _root[name]._alpha = 100;
  176.          _root[name].onEnterFrame = _root[name]._root[name][_root[name].process];
  177.       }
  178.       showList._alpha = 0;
  179.       starBG.play();
  180.       starBG2.play();
  181.       starBG3.play();
  182.       starBG4.play();
  183.       _root.onEnterFrame = null;
  184.    }
  185. }
  186. function wave1()
  187. {
  188.    this.hitCheck();
  189.    this.fire();
  190.    if(this._x < 200)
  191.    {
  192.       this.count = this.count + 1;
  193.       this._x += this.Hspeed;
  194.       this._y += this.Vspeed;
  195.       this.Vspeed--;
  196.       this.Hspeed = this.Hspeed + 1;
  197.    }
  198.    else if(this._x < 650)
  199.    {
  200.       this.count = this.count + 1;
  201.       this._x += this.Hspeed;
  202.       this._y += this.Vspeed;
  203.       this.Vspeed += 2;
  204.       this.Hspeed -= 1;
  205.    }
  206.    if(this._y >= 600 || this._y <= -50 || _X > 650 || _X < -50)
  207.    {
  208.       this.destroy();
  209.    }
  210. }
  211. function wave2()
  212. {
  213.    this.hitCheck();
  214.    this.fire();
  215.    if(this._x > 300)
  216.    {
  217.       this.count = this.count + 1;
  218.       this._x -= this.Hspeed;
  219.       this._y += this.Vspeed;
  220.       this.Vspeed--;
  221.       this.Hspeed = this.Hspeed + 1;
  222.    }
  223.    else if(this._x > -50)
  224.    {
  225.       this.count = this.count + 1;
  226.       this._x -= this.Hspeed;
  227.       this._y += this.Vspeed;
  228.       this.Vspeed += 2;
  229.       this.Hspeed -= 1;
  230.    }
  231.    if(this._y >= 600 || this._y <= -50 || this._x <= -50)
  232.    {
  233.       this.destroy();
  234.    }
  235. }
  236. function wave3()
  237. {
  238.    this.hitCheck();
  239.    this.fire();
  240.    if(this._x < 300)
  241.    {
  242.       this.count = 1;
  243.       this._x += this.Hspeed;
  244.       this._y += this.Vspeed;
  245.       this.Vspeed--;
  246.       this.Hspeed += 2;
  247.    }
  248.    else if(this._x < 650)
  249.    {
  250.       this.count = 2;
  251.       this._x += this.Hspeed;
  252.       this._y += this.Vspeed;
  253.       this.Vspeed -= 1;
  254.       this.Hspeed -= 2.5;
  255.    }
  256.    if(this._y >= 600 || this._y <= -50 || this._x >= 650)
  257.    {
  258.       this.destroy();
  259.    }
  260. }
  261. function wave4()
  262. {
  263.    this.hitCheck();
  264.    this.fire();
  265.    if(this._x > 300)
  266.    {
  267.       this.count = 1;
  268.       this._x -= this.Hspeed;
  269.       this._y += this.Vspeed;
  270.       this.Vspeed--;
  271.       this.Hspeed += 2;
  272.    }
  273.    else if(this._x > -50)
  274.    {
  275.       this.count = 2;
  276.       this._x -= this.Hspeed;
  277.       this._y += this.Vspeed;
  278.       this.Vspeed -= 1;
  279.       this.Hspeed -= 2.5;
  280.    }
  281.    if(this._y >= 600 || this._y <= -50 || this._x >= 650)
  282.    {
  283.       this.destroy();
  284.    }
  285. }
  286. function wave5()
  287. {
  288.    this.hitCheck();
  289.    this.fire();
  290.    if(this._x < 300)
  291.    {
  292.       this.count = 1;
  293.       this._x += this.Hspeed;
  294.       this._y += this.Vspeed;
  295.       this.Vspeed--;
  296.       this.Hspeed += 2;
  297.    }
  298.    else if(this._x < 650)
  299.    {
  300.       this.count = 2;
  301.       this._x += this.Hspeed;
  302.       this._y += this.Vspeed;
  303.       this.Vspeed -= 1;
  304.       this.Hspeed -= 2.5;
  305.    }
  306.    if(this._y >= 600 || this._y <= -50 || this._x >= 650)
  307.    {
  308.       this.destroy();
  309.    }
  310. }
  311. function wave6()
  312. {
  313.    this.hitCheck();
  314.    this.fire();
  315.    if(this._x > 400)
  316.    {
  317.       this.count = this.count + 1;
  318.       this._x -= this.Hspeed;
  319.       this._y += this.Vspeed;
  320.       this.Vspeed--;
  321.       this.Hspeed = this.Hspeed + 1;
  322.    }
  323.    else if(this._x > -50)
  324.    {
  325.       this.count = this.count + 1;
  326.       this._x -= this.Hspeed;
  327.       this._y += this.Vspeed;
  328.       this.Vspeed += 2;
  329.       this.Hspeed -= 1;
  330.    }
  331.    if(this._y >= 600 || this._y <= -50 || _X > 650 || _X < -50)
  332.    {
  333.       this.destroy();
  334.    }
  335. }
  336. _quality = "LOW";
  337. showList._alpha = 0;
  338. MAX_LAYER = 3000;
  339. layer = 0;
  340. score = 0;
  341. lives = 5;
  342. fullrandom = false;
  343. scoreTextX = 0;
  344. scoreTextY = 0;
  345. bonusTextX = 0;
  346. bonusTextY = 25;
  347. livesTextX = 0;
  348. livesTextY = 545;
  349. multiTextX = 0;
  350. multiTextY = 570;
  351. _global.MAX_Y = 550;
  352. _global.MAX_X = 550;
  353. _global.MIN_Y = 150;
  354. _global.MIN_X = 50;
  355. upperLeft = new Object();
  356. upperLeft._x = 0;
  357. upperLeft._y = 0;
  358. upperRight = new Object();
  359. upperRight._x = 650;
  360. upperRight._y = 0;
  361. waveO1 = new Object();
  362. waveO2 = new Object();
  363. waveO3 = new Object();
  364. waveO4 = new Object();
  365. waveO5 = new Object();
  366. waveO6 = new Object();
  367. waveO1.pause = 1500;
  368. waveO1.nextWave = waveO2;
  369. waveO1.funct = "wave1";
  370. waveO1.population = 7;
  371. waveO1.species = "ufo1";
  372. waveO1.freq = 200;
  373. waveO1.shotProb = 0.005;
  374. waveO2.pause = 2000;
  375. waveO2.nextWave = waveO3;
  376. waveO2.funct = "wave2";
  377. waveO2.population = 5;
  378. waveO2.species = "ufo2";
  379. waveO2.freq = 200;
  380. waveO2.shotProb = 0.015;
  381. waveO3.pause = 800;
  382. waveO3.nextWave = waveO4;
  383. waveO3.funct = "wave3";
  384. waveO3.population = 7;
  385. waveO3.species = "ufo1";
  386. waveO3.freq = 150;
  387. waveO3.shotProb = 0.01;
  388. waveO4.pause = 1500;
  389. waveO4.nextWave = waveO5;
  390. waveO4.funct = "wave4";
  391. waveO4.population = 7;
  392. waveO4.species = "ufo3";
  393. waveO4.freq = 150;
  394. waveO4.shotProb = 0.01;
  395. waveO5.pause = 1000;
  396. waveO5.nextWave = waveO6;
  397. waveO5.funct = "wave6";
  398. waveO5.altFunct = "wave3";
  399. waveO5.population = 10;
  400. waveO5.species = "ufo2";
  401. waveO5.freq = 150;
  402. waveO5.shotProb = 0.007;
  403. waveO6.pause = 1200;
  404. waveO6.nextWave = waveO1;
  405. waveO6.randomWaves = true;
  406. waveO6.funct = "wave1";
  407. waveO6.population = 8;
  408. waveO6.species = "ufo1";
  409. waveO6.freq = 150;
  410. waveO6.shotProb = 0.01;
  411. spawnShip();
  412. makeStats();
  413. enemyArray = new Array();
  414. intervalFunct = "firstWave";
  415. intervalTime = 1000;
  416. intervalID = "newWaveInterval";
  417. newWaveInterval = setInterval(firstWave,1000);
  418.