Frame 1
stop();
_global.DEG2RAD = 0.01745329252;
_global.RAD2DEG = 57.295779513;
_global.ang2D = function (xDistance, yDistance) {
with (Math) {
flip = 0;
if (yDistance >= 0) {
flip = PI;
}
return(57.295779513 * (flip - atan(xDistance / yDistance)));
}
};
_global.dist2 = function (x, y) {
return((x * x) + (y * y));
};
_global.dist = function (x, y) {
return(Math.sqrt((x * x) + (y * y)));
};
_global.xvel = function (angle) {
with (Math) {
return(sin(angle * 0.01745329252));
}
};
_global.segment = function (degree, segs) {
return(Math.round(((1080 + degree) * segs) / 360) % segs);
};
_global.yvel = function (angle) {
with (Math) {
return(-cos(angle * 0.01745329252));
}
};
_global.turn = function (currentAngle, preferredAngle, maxTurnSpeed) {
t = preferredAngle - currentAngle;
while (t > 180) {
t = t - 360;
}
while (t < -180) {
t = t + 360;
}
if (t < (-maxTurnSpeed)) {
return(-maxTurnSpeed);
}
if (t > maxTurnSpeed) {
return(maxTurnSpeed);
}
return(t);
};
Instance of Symbol 21 MovieClip "l1" in Frame 1
onClipEvent (load) {
i = 1;
r = (_root.l2._x - _x) / (_root.l2._yscale / 100);
trace(r);
}
onClipEvent (enterFrame) {
pt._rotation = ang2D(_xmouse, _ymouse);
_root.l2.pt._rotation = (-Math.acos(0.333333333333333 * Math.cos(pt._rotation * DEG2RAD))) * RAD2DEG;
_root.l2.pt.ret._y = (-r) * Math.cos((90 + _root.l2.pt._rotation) * DEG2RAD);
_root.t1.text = pt._rotation;
_root.t2.text = Math.cos((90 + _root.l2.pt._rotation) * DEG2RAD);
}
Frame 2
bi = 0;
stop();
Instance of Symbol 37 MovieClip in Frame 2
onClipEvent (enterFrame) {
_x = (_x - _root.player.xv);
_y = (_y - _root.player.yv);
_x = (_x % 96);
_y = (_y % 96);
}
Instance of Symbol 46 MovieClip "player" in Frame 2
onClipEvent (load) {
xv = 0;
yv = -4;
rv = 0;
fc = 0;
bs = 8;
bi = 0;
hull = 100;
topSpeed = 4;
accelFrames = 20;
}
onClipEvent (enterFrame) {
if (hull < 0) {
_root.gotoAndStop("lose");
}
fc++;
if (Key.isDown(38)) {
thrust = true;
th._alpha = ((th._alpha * 4) + 100) / 5;
th._yscale = th._alpha;
} else {
thrust = false;
th._alpha = th._alpha * 0.8;
th._yscale = th._alpha;
}
if (Key.isDown(40)) {
}
if (Key.isDown(37)) {
rv = rv - 0.4;
}
if (Key.isDown(39)) {
rv = rv + 0.4;
}
if (Key.isDown(32)) {
if ((fc % 6) == 1) {
bi++;
b = _root.attachMovie("bul", "pb" + bi, bi + 200);
b.xv = xvel(_rotation) * bs;
b.yv = yvel(_rotation) * bs;
b._rotation = _rotation;
b._x = _x;
b._y = _y;
b.canhit = true;
b.onEnterFrame = function () {
this._x = this._x + (this.xv - _root.player.xv);
this._y = this._y + (this.yv - _root.player.yv);
if (this.canhit) {
if (_root.n.h.hitTest(this._x, this._y, true)) {
this.canhit = false;
this.xv = _root.n.xv;
this.yv = _root.n.yv;
this.gotoAndPlay("pop");
_root.n.hull = _root.n.hull - 5;
this._rotation = random(360);
}
if (_root.n2.h.hitTest(this._x, this._y, true)) {
this.canhit = false;
this.xv = _root.n2.xv;
this.yv = _root.n2.yv;
this.gotoAndPlay("pop");
_root.n2.hull = _root.n2.hull - 10;
this._rotation = random(360);
}
}
};
}
} else {
hull = ((hull * 1500) + 100) / 1501;
}
_rotation = (_rotation + rv);
if (thrust) {
xv = ((xv * accelFrames) + (xvel(_rotation) * topSpeed)) / (accelFrames + 1);
yv = ((yv * accelFrames) + (yvel(_rotation) * topSpeed)) / (accelFrames + 1);
rv = rv * 0.8;
} else {
xv = xv * 0.995;
yv = yv * 0.995;
rv = rv * 0.9;
}
}
Instance of Symbol 48 MovieClip in Frame 2
onClipEvent (enterFrame) {
_xscale = (_root.player.hull * 6);
}
Instance of Symbol 56 MovieClip "n2" in Frame 2
onClipEvent (load) {
pd = 0;
rv = 0;
xv = 0;
yv = 0;
bs = 8;
reflex = 24;
rc = 1;
fc = 0;
hull = 100;
pdang._visible = true;
turnspeed = 0.4;
topSpeed = 4;
accelFrames = 20;
}
onClipEvent (enterFrame) {
if (hull < 0) {
_root.gotoAndStop("win");
}
fc++;
rc--;
thrust = false;
a2p = ang2D(_x - _root.player._x, _y - _root.player._y);
dp = dist(_x - _root.player._x, _y - _root.player._y);
if (rc < 0) {
rc = random(reflex);
afp = Math.floor(a2p - _root.player._rotation);
if (segment(afp, 12) == 0) {
pd = a2p + 135;
mde = "evade";
pdang._alpha = 100;
thrust = true;
} else if (dp > 90) {
ps = dist(_root.player.xv, _root.player.yv);
pa = _root.player._rotation + _root.player.rv;
cantarget = (ps / bs) * Math.sin((pa - a2p) * DEG2RAD);
if ((cantarget < 1) && (cantarget > -1)) {
mde = "aim";
pd = (180 + a2p) - (Math.asin(cantarget) * RAD2DEG);
pdang._alpha = 100;
} else {
mde = "cant hit";
pd = 180 + a2p;
pdang._alpha = 20;
thrust = true;
}
} else {
mde = "too close";
pd = a2p;
pdang._alpha = 20;
thrust = true;
}
}
if ((segment(_rotation - pd, 24) == 0) && (mde == "aim")) {
if ((fc % 6) == 1) {
mde = "firing";
_root.bi++;
b = _root.attachMovie("bul", "b" + _root.bi, _root.bi);
b.xv = xvel(_rotation) * bs;
b.yv = yvel(_rotation) * bs;
b._x = _x;
b._y = _y;
b.canhit = true;
b._rotation = _rotation;
b.onEnterFrame = function () {
this._x = this._x + (this.xv - _root.player.xv);
this._y = this._y + (this.yv - _root.player.yv);
if (this.canhit) {
if (_root.player.h.hitTest(this._x, this._y, true)) {
this.canhit = false;
this.xv = _root.player.xv;
this.yv = _root.player.yv;
this.gotoAndPlay("pop");
this._rotation = random(360);
_root.player.hull = _root.player.hull - 10;
}
}
};
}
} else {
hull = ((hull * 1500) + 100) / 1501;
}
pang._rotation = (180 + a2p) - _rotation;
pdoff = pd - _rotation;
pdang._rotation = pdoff;
rv = rv + turn(_rotation, pd, turnspeed);
if ((thrust == true) || (segment(pdoff, 3) == 0)) {
rv = rv * 0.8;
xv = ((xv * accelFrames) + (xvel(_rotation) * topSpeed)) / (accelFrames + 1);
yv = ((yv * accelFrames) + (yvel(_rotation) * topSpeed)) / (accelFrames + 1);
th._visible = true;
} else {
rv = rv * 0.9;
xv = xv * 0.995;
yv = yv * 0.995;
th._visible = false;
}
_x = (_x + (xv - _root.player.xv));
_y = (_y + (yv - _root.player.yv));
if (isNaN(rv)) {
trace("NaNed");
rv = 0;
}
_rotation = (_rotation + rv);
tb._rotation = -_rotation;
vel = Math.sqrt((xv * xv) + (yv * yv));
}
Instance of Symbol 60 MovieClip "ret" in Frame 2
onClipEvent (load) {
target = _root.n2;
player = _root.player;
}
onClipEvent (enterFrame) {
cantarget = (target.vel / player.bs) * Math.sin(((target._rotation - target.a2p) + 180) * DEG2RAD);
if ((cantarget < 1) && (cantarget > -1)) {
pd = target.a2p - (Math.asin(cantarget) * RAD2DEG);
_x = (player._x + (xvel(pd) * target.dp));
_y = (player._y + (yvel(pd) * target.dp));
_alpha = 100;
} else {
_alpha = 20;
}
_rotation = ang2D(_x - target._x, _y - target._y);
t._yscale = dist(_x - target._x, _y - target._y);
}
Instance of Symbol 56 MovieClip "n" in Frame 2
onClipEvent (load) {
pd = 0;
rv = 0;
xv = 0;
yv = 0;
bs = 8;
reflex = 13;
rc = 1;
fc = 0;
hull = 100;
pdang._visible = true;
turnspeed = 0.4;
topSpeed = 4;
accelFrames = 20;
}
onClipEvent (enterFrame) {
if (hull < 0) {
_root.gotoAndStop("win");
}
fc++;
rc--;
thrust = false;
a2p = ang2D(_x - _root.player._x, _y - _root.player._y);
dp = dist(_x - _root.player._x, _y - _root.player._y);
if (rc < 0) {
rc = random(reflex);
afp = Math.floor(a2p - _root.player._rotation);
if (segment(afp, 12) == 0) {
pd = a2p + 135;
mde = "evade";
pdang._alpha = 100;
thrust = true;
} else if (dp > 90) {
ps = dist(_root.player.xv, _root.player.yv);
pa = _root.player._rotation + _root.player.rv;
cantarget = (ps / bs) * Math.sin((pa - a2p) * DEG2RAD);
if ((cantarget < 1) && (cantarget > -1)) {
mde = "aim";
pd = (180 + a2p) - (Math.asin(cantarget) * RAD2DEG);
pdang._alpha = 100;
} else {
mde = "cant hit";
pd = 180 + a2p;
pdang._alpha = 20;
thrust = true;
}
} else {
mde = "too close";
pd = a2p;
pdang._alpha = 20;
thrust = true;
}
}
if ((segment(_rotation - pd, 24) == 0) && (mde == "aim")) {
if ((fc % 6) == 1) {
mde = "firing";
_root.bi++;
b = _root.attachMovie("bul", "b" + _root.bi, _root.bi);
b.xv = xvel(_rotation) * bs;
b.yv = yvel(_rotation) * bs;
b._x = _x;
b._y = _y;
b.canhit = true;
b._rotation = _rotation;
b.onEnterFrame = function () {
this._x = this._x + (this.xv - _root.player.xv);
this._y = this._y + (this.yv - _root.player.yv);
if (this.canhit) {
if (_root.player.h.hitTest(this._x, this._y, true)) {
this.canhit = false;
this.xv = _root.player.xv;
this.yv = _root.player.yv;
this.gotoAndPlay("pop");
this._rotation = random(360);
_root.player.hull = _root.player.hull - 10;
}
}
};
}
} else {
hull = ((hull * 1500) + 100) / 1501;
}
pang._rotation = (180 + a2p) - _rotation;
pdoff = pd - _rotation;
pdang._rotation = pdoff;
rv = rv + turn(_rotation, pd, turnspeed);
if ((thrust == true) || (segment(pdoff, 3) == 0)) {
rv = rv * 0.8;
xv = ((xv * accelFrames) + (xvel(_rotation) * topSpeed)) / (accelFrames + 1);
yv = ((yv * accelFrames) + (yvel(_rotation) * topSpeed)) / (accelFrames + 1);
th._visible = true;
} else {
rv = rv * 0.9;
xv = xv * 0.995;
yv = yv * 0.995;
th._visible = false;
}
_x = (_x + (xv - _root.player.xv));
_y = (_y + (yv - _root.player.yv));
if (isNaN(rv)) {
trace("NaNed");
rv = 0;
}
_rotation = (_rotation + rv);
tb._rotation = -_rotation;
vel = Math.sqrt((xv * xv) + (yv * yv));
}
Instance of Symbol 60 MovieClip "ret" in Frame 2
onClipEvent (load) {
target = _root.n;
player = _root.player;
}
onClipEvent (enterFrame) {
cantarget = (target.vel / player.bs) * Math.sin(((target._rotation - target.a2p) + 180) * DEG2RAD);
if ((cantarget < 1) && (cantarget > -1)) {
pd = target.a2p - (Math.asin(cantarget) * RAD2DEG);
_x = (player._x + (xvel(pd) * target.dp));
_y = (player._y + (yvel(pd) * target.dp));
_alpha = 100;
} else {
_alpha = 20;
}
_rotation = ang2D(_x - target._x, _y - target._y);
t._yscale = dist(_x - target._x, _y - target._y);
}
Frame 3
stop();
Instance of Symbol 37 MovieClip in Frame 3
onClipEvent (enterFrame) {
_x = (_x - _root.player.xv);
_y = (_y - _root.player.yv);
_x = (_x % 96);
_y = (_y % 96);
}
Frame 4
stop();
Symbol 12 MovieClip [bul] Frame 100
this.removeMovieClip();
Symbol 12 MovieClip [bul] Frame 109
this.removeMovieClip();
Symbol 32 Button
on (release) {
_root.gotoAndPlay("game");
}
Instance of Symbol 48 MovieClip "hp" in Symbol 51 MovieClip Frame 1
onClipEvent (enterFrame) {
_xscale = _parent._parent.hull;
}
Symbol 63 Button
on (release) {
_root.gotoAndStop(1);
}