Frame 1
scorenumber = 0;
highscorenumber = 0;
Explosions = new Array();
BadShots = new Array();
PlayerShots = new Array();
PShotID = 0;
BShotID = 0;
ExplosionID = 0;
PShotTimer = 0;
UniqueID = 10;
stop();
this.onEnterFrame = function () {
if (PShotTimer > 0) {
PShotTimer--;
}
if (Key.isDown(32)) {
if (PShotTimer < 1) {
PShotID = PShotID + 1;
UniqueID = UniqueID + 1;
if (PShotID == 40) {
PShotID = 1;
}
PlayerShots[PShotID] = MakeObject("PShot", PlayerShotT, UniqueID, PlayerShip._x, PlayerShip._y);
PShotTimer = 10;
}
}
};
md = function (x1, y1, x2, y2) {
x = x1 - x2;
y = y1 - y2;
var _local1 = Math.sqrt((x * x) + (y * y));
if (_local1 == 0) {
_local1 = 999;
}
return(_local1);
};
MakeObject = function (instname, template, id, x, y) {
var _local2;
var _local1 = instname + id;
_local2 = template.duplicateMovieClip(_local1, id);
setProperty(_local1, _x , x);
setProperty(_local1, _y , y);
return(_local2);
};
Instance of Symbol 2 MovieClip "PlayerShotT" in Frame 1
onClipEvent (load) {
xmove = random(5) - random(5);
ymove = (random(5) + 15) * -1;
}
onClipEvent (enterFrame) {
this._x = this._x + xmove;
this._y = this._y + ymove;
if (this._y < 0) {
this.removeMovieClip();
}
col = _root.md(_x, _y, _root.Alien._x, _root.Alien._y);
if (col < 40) {
_root.UniqueID++;
_root.ExplosionID++;
_root.Explosions[_root.ExplosionID] = _root.MakeObject("Explosion", _root.ExplosionT, _root.UniqueID, _root.Alien._x, _root.Alien._y);
_root.Alien._x = random(640);
_root.Alien._y = random(480);
_root.Alien.xmove = random(15) - random(15);
_root.Alien.ymove = random(15) - random(15);
_root.scorenumber++;
_root.score = "Score " + _root.scorenumber;
this.removeMovieClip();
}
}
Instance of Symbol 4 MovieClip "Alien" in Frame 1
onClipEvent (load) {
xmove = random(15) - random(15);
ymove = random(15) - random(15);
this._x = random(640);
this._y = random(480);
}
onClipEvent (enterFrame) {
this._x = this._x + xmove;
this._y = this._y + ymove;
if (this._x > 640) {
xmove = Math.abs(xmove) * -1;
}
if (this._x < 0) {
xmove = Math.abs(xmove);
}
if (this._y > 425) {
ymove = Math.abs(ymove) * -1;
}
if (this._y < 70) {
ymove = Math.abs(ymove);
}
fire = random(20);
if (fire == 1) {
_root.BShotID = _root.BShotID + 1;
_root.UniqueID = _root.UniqueID + 1;
_root.BadShots[_root.BShotID] = _root.MakeObject("BShot", _root.AlienShotT, _root.UniqueID, _root.Alien._x, _root.Alien._y);
}
}
Instance of Symbol 6 MovieClip "AlienShotT" in Frame 1
onClipEvent (load) {
xmove = random(5) - random(5);
ymove = random(5) + 15;
}
onClipEvent (enterFrame) {
this._x = this._x + xmove;
this._y = this._y + ymove;
if (this._y > 480) {
this.removeMovieClip();
}
col = _root.md(_x, _y, _root.PlayerShip._x, _root.PlayerShip._y);
if (col < 47) {
_root.UniqueID++;
_root.ExplosionID++;
_root.Explosions[_root.ExplosionID] = _root.MakeObject("Explosion2", _root.Explosion, _root.UniqueID, _root.PlayerShip._x, _root.PlayerShip._y);
_root.PlayerShip._x = random(640);
if (_root.scorenumber > _root.highscorenumber) {
_root.highscorenumber = _root.scorenumber;
_root.highscore = "High Score: " + _root.highscorenumber;
}
_root.scorenumber = 0;
_root.score = "Score " + _root.scorenumber;
this.removeMovieClip();
}
}
Instance of Symbol 10 MovieClip "PlayerShip" in Frame 1
onClipEvent (enterFrame) {
if (Key.isDown(39) and (this._x < 600)) {
this._x = this._x + 15;
} else if (Key.isDown(37) and (this._x > 40)) {
this._x = this._x - 15;
}
}
Symbol 8 MovieClip Frame 10
this.onEnterFrame = function () {
this.removeMovieClip();
};