Frame 1
tellTarget ("_level0") {
lbLoadingGame = "";
};
Frame 3
if (_framesloaded >= _totalframes) {
gotoAndPlay (4);
} else {
gotoAndPlay (2);
}
Frame 4
function Brain() {
Brain1(A, G);
}
function Brain1(P, E) {
Kx = P.GoalX - B._x;
Ky = P.GoalY - B._y;
K = Math.sqrt((Kx * Kx) + (Ky * Ky));
if (K == 0) {
return(undefined);
}
Kx = Kx / K;
Ky = Ky / K;
Dx = B._x - P._x;
Dy = B._y - P._y;
D = Math.sqrt((Dx * Dx) + (Dy * Dy));
K0x = Dx - ((Kx * 0.1) * D);
K0y = Dy - ((Ky * 0.1) * D);
K0 = Math.sqrt((K0x * K0x) + (K0y * K0y));
if (K0 == 0) {
return(undefined);
}
K0x = K0x / K0;
K0y = K0y / K0;
P.Vx = P.V * K0x;
P.Vy = P.V * K0y;
P._rotation = Math.atan2(K0y, K0x) * 57.3;
}
function Brain0(P, E) {
if (0 < (P.Dir * (P._x - B._x))) {
P.State = 0;
}
if (50 < (P.Dir * (B._x - P._x))) {
P.State = 1;
}
if (0 < (P.Dir * B.Vx)) {
P.State = 1;
}
if (P.State == 0) {
GotoPoint(P, P.GateX, P.GateY);
} else if (G.State == 1) {
GotoPoint(P, B._x, B._y);
}
}
function GotoPoint(N, x, y) {
dX = x - N._x;
dY = y - N._y;
Phi = 57.3 * Math.atan2(dY, dX);
N._rotation = Phi;
N.Vx = N.V * Math.cos(N._rotation / 57.3);
N.Vy = N.V * Math.sin(N._rotation / 57.3);
}
function Moving() {
B._x = B._x + B.Vx;
B._y = B._y + B.Vy;
G._x = G._x + G.Vx;
G._y = G._y + G.Vy;
A._x = A._x + A.Vx;
A._y = A._y + A.Vy;
}
function Collisions() {
if ((((X1 + Rb) >= B._x) and (GateY1 < B._y)) and (B._y < GateY2)) {
StartPosition();
stScoreA = Number(stScoreA) + 1;
return(undefined);
}
if (((B._x >= (X2 - Rb)) and (GateY1 < B._y)) and (B._y < GateY2)) {
StartPosition();
stScoreG = Number(stScoreG) + 1;
return(undefined);
}
if ((X1 + R) >= G._x) {
G.Vx = Math.abs(G.Vx);
G._rotation = Math.atan2(G.Vy, G.Vx) * 57.3;
}
if (G._x >= (X2 - R)) {
G.Vx = -Math.abs(G.Vx);
G._rotation = Math.atan2(G.Vy, G.Vx) * 57.3;
}
if ((Y1 + R) >= G._y) {
G.Vy = Math.abs(G.Vy);
G._rotation = Math.atan2(G.Vy, G.Vx) * 57.3;
}
if (G._y >= (Y2 - R)) {
G.Vy = -Math.abs(G.Vy);
G._rotation = Math.atan2(G.Vy, G.Vx) * 57.3;
}
if ((X1 + R) >= A._x) {
A.Vx = Math.abs(A.Vx);
A._rotation = Math.atan2(A.Vy, A.Vx) * 57.3;
}
if (A._x >= (X2 - R)) {
A.Vx = -Math.abs(A.Vx);
A._rotation = Math.atan2(A.Vy, A.Vx) * 57.3;
}
if ((Y1 + R) >= A._y) {
A.Vy = Math.abs(A.Vy);
A._rotation = Math.atan2(A.Vy, A.Vx) * 57.3;
}
if (A._y >= (Y2 - R)) {
A.Vy = -Math.abs(A.Vy);
A._rotation = Math.atan2(A.Vy, A.Vx) * 57.3;
}
if (B._x < (X1 + Rb)) {
B.Vx = Math.abs(B.Vx);
}
if ((X2 - Rb) < B._x) {
B.Vx = -Math.abs(B.Vx);
}
if (B._y < (Y1 + Rb)) {
B.Vy = Math.abs(B.Vy);
}
if ((Y2 - Rb) < B._y) {
B.Vy = -Math.abs(B.Vy);
}
dX = G._x - A._x;
dY = G._y - A._y;
S = (dX * dX) + (dY * dY);
if (S < dGA) {
tmp = G.Vx;
G.Vx = A.Vx;
A.Vx = tmp;
tmp = G.Vy;
G.Vy = A.Vy;
A.Vy = tmp;
A._rotation = Math.atan2(A.Vy, A.Vx) * 57.3;
G._rotation = Math.atan2(G.Vy, G.Vx) * 57.3;
Lambda = (((0.9 * Math.sqrt(S)) / (2 * R)) - 1) / 2;
A._x = A._x + (Lambda * dX);
A._y = A._y + (Lambda * dY);
G._x = G._x - (Lambda * dX);
G._y = G._y - (Lambda * dY);
}
dX = G._x - B._x;
dY = G._y - B._y;
S = (dX * dX) + (dY * dY);
if (S < dBG) {
B.Vx = 2 * ((2 * G.Vx) - B.Vx);
B.Vy = 2 * ((2 * G.Vy) - B.Vy);
if (VBmax2 < ((B.Vx * B.Vx) + (B.Vy * B.Vy))) {
B.V = Math.sqrt((B.Vx * B.Vx) + (B.Vy * B.Vy));
B.Vx = (B.Vx * VBmax) / B.V;
B.Vy = (B.Vy * VBmax) / B.V;
}
Lambda = ((0.9 * Math.sqrt(S)) / (R + Rb)) - 1;
B._x = B._x + (Lambda * dX);
B._y = B._y + (Lambda * dY);
}
dX = A._x - B._x;
dY = A._y - B._y;
S = (dX * dX) + (dY * dY);
if (dBG >= S) {
B.Vx = 2 * ((2 * A.Vx) - B.Vx);
B.Vy = 2 * ((2 * A.Vy) - B.Vy);
if (VBmax2 < ((B.Vx * B.Vx) + (B.Vy * B.Vy))) {
B.V = Math.sqrt((B.Vx * B.Vx) + (B.Vy * B.Vy));
B.Vx = (B.Vx * VBmax) / B.V;
B.Vy = (B.Vy * VBmax) / B.V;
}
Lambda = ((0.9 * Math.sqrt(S)) / (R + Rb)) - 1;
B._x = B._x + (Lambda * dX);
B._y = B._y + (Lambda * dY);
}
B.Vx = B.Vx * 0.999;
B.Vy = B.Vy * 0.999;
}
function StartPosition() {
G._x = 83;
G._y = 180;
G.Vx = 2;
G.Vy = 0;
G._rotation = Math.atan2(G.Vy, G.Vx) * 57.3;
G.V = Math.sqrt((G.Vx * G.Vx) + (G.Vy * G.Vy));
A._x = 408;
A._y = 180;
A.Vx = -2;
A.Vy = 0;
A._rotation = Math.atan2(A.Vy, A.Vx) * 57.3;
A.V = Math.sqrt((A.Vx * A.Vx) + (A.Vy * A.Vy));
B._x = 250;
B._y = 180;
B.Vx = 0;
if (random(2) == 0) {
B.Vy = random(20) / 10;
} else {
B.Vy = (-random(20)) / 10;
}
B.V = Math.sqrt((B.Vx * B.Vx) + (B.Vy * B.Vy));
}
function InitGame() {
StartPosition();
stScoreG = (stScoreA = "0");
stTime = "10:00";
Time = getTimer();
GameFinish = false;
wndFinish._visible = false;
}
X1 = 29;
X2 = 470;
Y1 = 46;
Y2 = 318;
GateY1 = 127;
GateY2 = 232;
A.GateX = 472;
A.GateY = 180;
G.GateX = 27;
G.GateY = 180;
A.GoalX = 27;
A.GoalY = 180;
G.GoalX = 472;
G.GoalY = 180;
A.Dir = -1;
G.Dir = 1;
R = A._width / 2;
Rb = B._width / 2;
dGA = (4 * R) * R;
dBG = (R + Rb) * (R + Rb);
dR = R - Rb;
Rb2 = 2 * Rb;
Vmax = 3;
VBmax = 4;
VBmax2 = VBmax * VBmax;
if (!initialized) {
initialized = true;
fscommand ("showmenu", false);
GameFinish = true;
StartPosition();
stScoreG = (stScoreA = "0");
stTime = "10:00";
Time = getTimer();
}
Instance of Symbol 9 MovieClip in Frame 4
onClipEvent (keyDown) {
if (Key.isDown(Key.LEFT)) {
_parent.G._rotation = _parent.G._rotation - 10;
}
if (Key.isDown(Key.RIGHT)) {
_parent.G._rotation = _parent.G._rotation + 10;
}
if (Key.isDown(Key.UP) or Key.isDown(88)) {
if (_parent.G.V < _parent.Vmax) {
_parent.G.V = _parent.G.V + 0.5;
}
}
if (Key.isDown(Key.DOWN) or Key.isDown(90)) {
if (0 < _parent.G.V) {
_parent.G.V = _parent.G.V - 0.5;
}
}
if (Key.isDown(Key.SPACE)) {
}
_parent.G.Vx = _parent.G.V * Math.cos(_parent.G._rotation / 57.3);
_parent.G.Vy = _parent.G.V * Math.sin(_parent.G._rotation / 57.3);
}
onClipEvent (mouseDown) {
_parent.GotoPoint(_parent.G, _parent._xmouse, _parent._ymouse);
}
Instance of Symbol 50 MovieClip "wndFinish" in Frame 4
onClipEvent (keyDown) {
}
onClipEvent (mouseDown) {
if (_parent.GameFinish) {
_parent.InitGame();
}
}
Frame 5
if (GameFinish) {
return(undefined);
}
Collisions();
Moving();
Frame 6
if (GameFinish) {
return(undefined);
}
Collisions();
Moving();
Frame 7
if (GameFinish) {
return(undefined);
}
Collisions();
Moving();
Frame 8
if (GameFinish) {
return(undefined);
}
Moving();
Frame 9
if (GameFinish) {
gotoAndPlay (5);
return(undefined);
}
Collisions();
Moving();
Brain();
var sec = int(600 - ((getTimer() - Time) / 1000));
var min = int(sec / 60);
if (0 >= sec) {
wndFinish._visible = true;
GameFinish = true;
stTime = "00:00";
gotoAndPlay (5);
return(undefined);
}
sec = sec - (60 * min);
if (9 < sec) {
stTime = (min + ":") + sec;
} else {
stTime = (min + ":0") + sec;
}
if (min < 10) {
stTime = "0" + stTime;
}
gotoAndPlay (5);
Symbol 19 Button
on (release) {
InitGame();
}
Symbol 55 Button
on (release) {
getURL ("http://absolutist.com/games.html", "_blank");
}