home *** CD-ROM | disk | FTP | other *** search
- function spawnShip()
- {
- layer++;
- _root.attachMovie("ship","ship",layer);
- layer++;
- }
- function makeStats()
- {
- textFormat = new TextFormat();
- textFormat.color = 16777215;
- textFormat.font = "Verdana";
- textFormat.size = 18;
- _root.createTextField("scoreText",MAX_LAYER,scoreTextX,scoreTextY,600,50);
- _root.createTextField("bonusText",MAX_LAYER + 1,bonusTextX,bonusTextY,600,50);
- _root.createTextField("livesText",MAX_LAYER + 2,livesTextX,livesTextY,300,50);
- _root.createTextField("multiText",MAX_LAYER + 3,multiTextX,multiTextY,300,50);
- }
- function randomizeWaves()
- {
- i = 1;
- while(i <= 6)
- {
- _root["waveO" + i].species = "ufo" + Math.floor(Math.random() * 3.99 + 1);
- _root["waveO" + i].funct = "wave" + Math.floor(Math.random() * 5.99 + 1);
- _root["waveO" + i].population = Math.floor(Math.random() * 4) + 7;
- _root["waveO" + i].shotProb = Math.random() * 0.015;
- i++;
- }
- }
- function powerUpDrop(pux, puy)
- {
- layer++;
- randomNum = Math.floor(Math.random() * 100);
- if(randomNum < 15)
- {
- PUtype = "rapidFire";
- }
- else if(randomNum < 30)
- {
- PUtype = "upgrade";
- }
- else if(randomNum < 40)
- {
- PUtype = "helper";
- }
- else if(randomNum < 50)
- {
- PUtype = "speedUp";
- }
- else if(randomNum < 58)
- {
- PUtype = "multiplierUp";
- }
- else if(randomNum < 65)
- {
- PUtype = "lifeUp";
- }
- else if(randomNum < 70)
- {
- PUtype = "death";
- }
- else if(randomNum < 80)
- {
- PUtype = "bankrupt";
- }
- else if(randomNum < 90)
- {
- PUtype = "slowDown";
- }
- else
- {
- PUtype = "scoreUp";
- }
- attachMovie(PUtype,PUtype + layer,layer);
- _root[PUtype + _root.layer]._x = pux;
- _root[PUtype + _root.layer]._y = puy;
- }
- function firstWave()
- {
- clearInterval(newWaveInterval);
- currentWave = waveO1;
- intervalFunct = "createEnemy";
- intervalTime = currentWave.freq;
- intervalID = "waves";
- waves = setInterval(createEnemy,currentWave.freq);
- }
- function newWave()
- {
- clearInterval(newWaveInterval);
- currentWave = currentWave.nextWave;
- if(currentWave == null)
- {
- currentWave = waveOne;
- }
- intervalFunct = "createEnemy";
- intervalTime = currentWave.freq;
- intervalID = "waves";
- waves = setInterval(createEnemy,currentWave.freq);
- }
- function createEnemy()
- {
- waveCount++;
- layer++;
- if(fullRandom == true && currentWave != waveO6)
- {
- randomizeWaves();
- fullRandom = false;
- }
- else if(currentWave.randomWaves == true)
- {
- fullRandom = true;
- randomInt = Math.floor(Math.random() * 5.99 + 1);
- currentWave.funct = "wave" + randomInt;
- }
- if(currentWave.funct == "wave2" || currentWave.funct == "wave4" || currentWave.funct == "wave6")
- {
- currentWave.startPoint = upperRight;
- }
- else
- {
- currentWave.startPoint = upperLeft;
- }
- _root.attachMovie(currentWave.species,currentWave.species + layer,layer,currentWave.startPoint);
- _root[currentWave.species + layer].goFunct = _root[currentWave.funct];
- _root[currentWave.species + layer].onEnterFrame = _root[currentWave.species + layer].goFunct;
- if(currentWave.altFunct != null)
- {
- tempFunctHolder = currentWave.funct;
- currentWave.funct = currentWave.altFunct;
- currentWave.altFunct = tempFunctHolder;
- }
- enemyArray[waveCount].destroy();
- enemyArray[waveCount] = _root[currentWave.species + layer];
- layer++;
- if(waveCount >= currentWave.population)
- {
- if(layer > MAX_LAYER / 30)
- {
- layer = 5;
- }
- waveCount = 0;
- clearInterval(waves);
- intervalFunct = "newWave";
- intervalTime = currentWave.nextWave.pause;
- intervalID = "newWaveInterval";
- newWaveInterval = setInterval(newWave,currentWave.nextWave.pause);
- }
- }
- function pause()
- {
- _quality = "HIGH";
- clearInterval(waves);
- clearInterval(newWaveInterval);
- clearInterval(_root[intervalID]);
- for(name in _root)
- {
- _root[name]._alpha = 50;
- _root[name].onEnterFrame = null();
- }
- showList._alpha = 100;
- starBG.stop();
- starBG2.stop();
- starBG3.stop();
- starBG4.stop();
- _root.onEnterFrame = unpause;
- }
- function unpause()
- {
- if(Key.isDown(32))
- {
- _quality = "LOW";
- _root[intervalID] = setInterval(_root[intervalFunct],intervalTime);
- for(name in _root)
- {
- _root[name]._alpha = 100;
- _root[name].onEnterFrame = _root[name]._root[name][_root[name].process];
- }
- showList._alpha = 0;
- starBG.play();
- starBG2.play();
- starBG3.play();
- starBG4.play();
- _root.onEnterFrame = null;
- }
- }
- function wave1()
- {
- this.hitCheck();
- this.fire();
- if(this._x < 200)
- {
- this.count = this.count + 1;
- this._x += this.Hspeed;
- this._y += this.Vspeed;
- this.Vspeed--;
- this.Hspeed = this.Hspeed + 1;
- }
- else if(this._x < 650)
- {
- this.count = this.count + 1;
- this._x += this.Hspeed;
- this._y += this.Vspeed;
- this.Vspeed += 2;
- this.Hspeed -= 1;
- }
- if(this._y >= 600 || this._y <= -50 || _X > 650 || _X < -50)
- {
- this.destroy();
- }
- }
- function wave2()
- {
- this.hitCheck();
- this.fire();
- if(this._x > 300)
- {
- this.count = this.count + 1;
- this._x -= this.Hspeed;
- this._y += this.Vspeed;
- this.Vspeed--;
- this.Hspeed = this.Hspeed + 1;
- }
- else if(this._x > -50)
- {
- this.count = this.count + 1;
- this._x -= this.Hspeed;
- this._y += this.Vspeed;
- this.Vspeed += 2;
- this.Hspeed -= 1;
- }
- if(this._y >= 600 || this._y <= -50 || this._x <= -50)
- {
- this.destroy();
- }
- }
- function wave3()
- {
- this.hitCheck();
- this.fire();
- if(this._x < 300)
- {
- this.count = 1;
- this._x += this.Hspeed;
- this._y += this.Vspeed;
- this.Vspeed--;
- this.Hspeed += 2;
- }
- else if(this._x < 650)
- {
- this.count = 2;
- this._x += this.Hspeed;
- this._y += this.Vspeed;
- this.Vspeed -= 1;
- this.Hspeed -= 2.5;
- }
- if(this._y >= 600 || this._y <= -50 || this._x >= 650)
- {
- this.destroy();
- }
- }
- function wave4()
- {
- this.hitCheck();
- this.fire();
- if(this._x > 300)
- {
- this.count = 1;
- this._x -= this.Hspeed;
- this._y += this.Vspeed;
- this.Vspeed--;
- this.Hspeed += 2;
- }
- else if(this._x > -50)
- {
- this.count = 2;
- this._x -= this.Hspeed;
- this._y += this.Vspeed;
- this.Vspeed -= 1;
- this.Hspeed -= 2.5;
- }
- if(this._y >= 600 || this._y <= -50 || this._x >= 650)
- {
- this.destroy();
- }
- }
- function wave5()
- {
- this.hitCheck();
- this.fire();
- if(this._x < 300)
- {
- this.count = 1;
- this._x += this.Hspeed;
- this._y += this.Vspeed;
- this.Vspeed--;
- this.Hspeed += 2;
- }
- else if(this._x < 650)
- {
- this.count = 2;
- this._x += this.Hspeed;
- this._y += this.Vspeed;
- this.Vspeed -= 1;
- this.Hspeed -= 2.5;
- }
- if(this._y >= 600 || this._y <= -50 || this._x >= 650)
- {
- this.destroy();
- }
- }
- function wave6()
- {
- this.hitCheck();
- this.fire();
- if(this._x > 400)
- {
- this.count = this.count + 1;
- this._x -= this.Hspeed;
- this._y += this.Vspeed;
- this.Vspeed--;
- this.Hspeed = this.Hspeed + 1;
- }
- else if(this._x > -50)
- {
- this.count = this.count + 1;
- this._x -= this.Hspeed;
- this._y += this.Vspeed;
- this.Vspeed += 2;
- this.Hspeed -= 1;
- }
- if(this._y >= 600 || this._y <= -50 || _X > 650 || _X < -50)
- {
- this.destroy();
- }
- }
- _quality = "LOW";
- showList._alpha = 0;
- MAX_LAYER = 3000;
- layer = 0;
- score = 0;
- lives = 5;
- fullrandom = false;
- scoreTextX = 0;
- scoreTextY = 0;
- bonusTextX = 0;
- bonusTextY = 25;
- livesTextX = 0;
- livesTextY = 545;
- multiTextX = 0;
- multiTextY = 570;
- _global.MAX_Y = 550;
- _global.MAX_X = 550;
- _global.MIN_Y = 150;
- _global.MIN_X = 50;
- upperLeft = new Object();
- upperLeft._x = 0;
- upperLeft._y = 0;
- upperRight = new Object();
- upperRight._x = 650;
- upperRight._y = 0;
- waveO1 = new Object();
- waveO2 = new Object();
- waveO3 = new Object();
- waveO4 = new Object();
- waveO5 = new Object();
- waveO6 = new Object();
- waveO1.pause = 1500;
- waveO1.nextWave = waveO2;
- waveO1.funct = "wave1";
- waveO1.population = 7;
- waveO1.species = "ufo1";
- waveO1.freq = 200;
- waveO1.shotProb = 0.005;
- waveO2.pause = 2000;
- waveO2.nextWave = waveO3;
- waveO2.funct = "wave2";
- waveO2.population = 5;
- waveO2.species = "ufo2";
- waveO2.freq = 200;
- waveO2.shotProb = 0.015;
- waveO3.pause = 800;
- waveO3.nextWave = waveO4;
- waveO3.funct = "wave3";
- waveO3.population = 7;
- waveO3.species = "ufo1";
- waveO3.freq = 150;
- waveO3.shotProb = 0.01;
- waveO4.pause = 1500;
- waveO4.nextWave = waveO5;
- waveO4.funct = "wave4";
- waveO4.population = 7;
- waveO4.species = "ufo3";
- waveO4.freq = 150;
- waveO4.shotProb = 0.01;
- waveO5.pause = 1000;
- waveO5.nextWave = waveO6;
- waveO5.funct = "wave6";
- waveO5.altFunct = "wave3";
- waveO5.population = 10;
- waveO5.species = "ufo2";
- waveO5.freq = 150;
- waveO5.shotProb = 0.007;
- waveO6.pause = 1200;
- waveO6.nextWave = waveO1;
- waveO6.randomWaves = true;
- waveO6.funct = "wave1";
- waveO6.population = 8;
- waveO6.species = "ufo1";
- waveO6.freq = 150;
- waveO6.shotProb = 0.01;
- spawnShip();
- makeStats();
- enemyArray = new Array();
- intervalFunct = "firstWave";
- intervalTime = 1000;
- intervalID = "newWaveInterval";
- newWaveInterval = setInterval(firstWave,1000);
-