Frame 1
setup = function () {
firing = false;
fireRate = 10;
enemyTime = 0;
enemyRate = 30;
score = 0;
score_txt.text = score;
counter = 20;
counter_txt.text = counter;
ship.onMouseDown = function () {
firing = true;
repeatTime = 0;
};
ship.onMouseUp = function () {
firing = false;
};
ship.onEnterFrame = function () {
this.destx = _xmouse;
var _local3 = this.destx - this._x;
this._x = this._x + (_local3 * 0.15);
if (firing && (repeatTime == 0)) {
createProjectile("bullet", this._x, this._y - 5, 0, -15);
}
repeatTime++;
repeatTime = repeatTime % fireRate;
if (enemyTime == 0) {
var _local2 = (Math.random() * 100) + 80;
createEnemy("bob", _local2, -30);
createEnemy("bob", 200, -30);
createEnemy("bob", 400 - _local2, -30);
}
enemyTime++;
enemyTime = enemyTime % 30;
};
doCounter = function () {
counter--;
counter_txt.text = counter;
if (counter == 0) {
delete ship.onEnterFrame;
delete bgscroller.onEnterFrame;
enemyLayer.removeMovieClip();
projectileLayer.removeMovieClip();
startButton._visible = true;
clearInterval(countID);
}
};
countID = setInterval(doCounter, 1000);
_root.createEmptyMovieClip("projectileLayer", 99);
projectileCount = 0;
_root.createEmptyMovieClip("enemyLayer", 98);
enemyCount = 0;
ship.swapDepths(100);
ship.gotoAndStop(1);
bgscroller.onEnterFrame = function () {
if (this._y >= 500) {
this._y = 0;
}
this._y = this._y + 5;
};
};
createProjectile = function (type, x, y, dx, dy) {
var _local4 = "proj" + projectileCount;
projectileLayer.attachMovie(type, _local4, projectileCount);
projectileLayer[_local4]._x = x;
projectileLayer[_local4]._y = y;
projectileLayer[_local4].dx = dx;
projectileLayer[_local4].dy = dy;
projectileLayer[_local4].onEnterFrame = function () {
this._x = this._x + this.dx;
this._y = this._y + this.dy;
if (this._y < 0) {
this.removeMovieClip();
}
var _local2 = 0;
while (_local2 < 10) {
var _local3 = "enemy" + _local2;
if (this.hitTest(enemyLayer[_local3]) && (enemyLayer[_local3]._currentframe == 1)) {
enemyLayer[_local3].play();
score++;
score_txt.text = score;
this.removeMovieClip();
}
_local2++;
}
};
projectileCount++;
projectileCount = projectileCount % 10;
};
createEnemy = function (type, x, y) {
var _local2 = "enemy" + enemyCount;
enemyLayer.attachMovie(type, _local2, enemyCount);
enemyLayer[_local2]._x = x;
enemyLayer[_local2].xline = x;
enemyLayer[_local2]._y = y;
enemyLayer[_local2].dy = (Math.random() * 3) + 10;
enemyLayer[_local2].t = Math.random() * 6.28;
enemyLayer[_local2].onEnterFrame = function () {
this._x = this.xline + (Math.sin(this.t) * 100);
this._y = this._y + this.dy;
this.t = this.t + 0.1;
if ((this._currentframe == 1) && (ship.hitTest(this._x, this._y, true))) {
counter = 1;
doCounter();
ship.play();
}
if (this._y > 500) {
this.removeMovieClip();
}
};
enemyCount++;
enemyCount = enemyCount % 10;
};
startButton.onRelease = function () {
this._visible = false;
setup();
};
Symbol 7 MovieClip [bob] Frame 1
stop();
Symbol 7 MovieClip [bob] Frame 15
this.removeMovieClip();
Symbol 18 MovieClip Frame 1
stop();
Symbol 18 MovieClip Frame 11
stop();