Frame 1
version = "040527";
_global.v2d = new Object();
_global.v2d.math = new Object();
_global.v2d.math.p2pDistance = function (x1, y1, x2, y2) {
var tx = (x2 - x1);
var ty = (y2 - y1);
return(Math.sqrt((tx * tx) + (ty * ty)));
};
_global.v2d.math.squareHit = function (x1, y1, x2, y2, s) {
return((Math.abs(x1 - x2) <= s) && (Math.abs(y1 - y2) <= s));
};
_global.v2d.math.rectHit = function (x1, y1, x2, y2, sx, sy) {
return((Math.abs(x1 - x2) <= sx) && (Math.abs(y1 - y2) <= sy));
};
_global.v2d.math.withinRect = function (x1, y1, x2, y2, x3, y3) {
return((_global.v2d.math.numBetween(x1, x3, x2) == true) && (_global.v2d.math.numBetween(y1, y3, y2) == true));
};
_global.v2d.math.r2vertSgnAngle = function (x1, y1, x2, y2) {
var rad = Math.asin((x2 - x1) / _global.v2d.math.p2pDistance(x1, y1, x2, y2));
return(((y2 <= y1) ? (rad) : (Math.PI - rad)));
};
_global.v2d.math.r2vertCwAngle = function (x1, y1, x2, y2) {
var temp = Math.asin((x2 - x1) / _global.v2d.math.p2pDistance(x1, y1, x2, y2));
if (temp < 0) {
temp = temp + (Math.PI*2);
}
return(temp);
};
_global.v2d.math.numBetween = function (a, b, c) {
if (a == c) {
return(b == a);
}
if (c > a) {
return((b > a) && (b < c));
}
return((b > c) && (b < a));
};
_global.v2d.math.unify = function (v) {
var l = Math.sqrt((v.x * v.x) + (v.y * v.y));
v.x = v.x / l;
v.y = v.y / l;
return(v);
};
Object.prototype.toString = function (rec, o) {
if (rec === -1) {
return(undefined);
}
if (!o) {
o = this;
}
switch (typeof(o)) {
case "movieclip" :
return("/" + o._target);
case "object" :
case "array" :
var d = typeof(o);
var first = true;
for (var i in o) {
if (!first) {
d = d + ", ";
} else {
d = d + "{";
first = false;
}
d = d + ((i + ": ") + o[i].toString(rec - 1));
}
if (!first) {
d = d + "}";
}
return(d);
case "number" :
case "string" :
}
return(o);
};
_root.createEmptyMovieClip("g", 100);
_root.createEmptyMovieClip("gstep", 101);
CBall = function (id, mc) {
this.id = id;
this.value = id;
this.mc = mc;
this.x = mc._x;
this.y = mc._y;
this.radius = _root.ballSize / 2;
this.mc.engine = this;
this.mc.defaultWidth = this.mc._width;
this.mc.defaultHeight = this.mc._height;
this.glass = 0;
this.glassSmashed = 0;
this.reset();
};
CBall.prototype.reset = function () {
this.vx = 0;
this.vy = 0;
this.mc._x = this.x;
this.mc._y = this.y;
this.mc._xscale = 100;
this.mc._yscale = 100;
this.mc._alpha = 100;
this.mc._visible = true;
this.potted = -1;
this.glassSmashed = 0;
this.setGlass(0, 1);
if ((this.id == 1) && (_root.lvl.colorSwap)) {
this.glass = 0;
this.colorSwap();
}
this.spot = 0;
this.mc.style.gotoAndStop(this.value + 1);
this.mc.style.label.gotoAndStop(this.value + 1);
this.mc.style.mc.gotoAndStop(this.glass + 1);
};
CBall.prototype.showLabel = function () {
this.mc.style.label._visible = 1;
};
CBall.prototype.hideLabel = function () {
this.mc.style.label._visible = 0;
};
CBall.prototype.initColorSwap = function () {
this.value = this.id;
this.mc.style.gotoAndStop(this.value + 1);
this.mc.style.label.gotoAndStop(this.value + 1);
};
CBall.prototype.colorSwap = function () {
if (this.id > 1) {
this.value = this.value + 1;
if (this.value > 7) {
this.value = 2;
}
this.mc.style.gotoAndStop(this.value + 1);
this.mc.style.label.gotoAndStop(this.value + 1);
}
};
CBall.prototype.setGlass = function (bool, force) {
if ((this.potted != -1) && (!force)) {
return(undefined);
}
this.glass = bool;
this.mc.style.mc.gotoAndStop(this.glass + 1);
};
CBall.prototype.smashGlass = function () {
_root.snd.play("glass");
this.potted = 666;
this.spot = 1;
this.mc.style.mc.gotoAndStop("break");
this.glassSmashed = 1;
};
CBall.prototype.move = function () {
if (this.potted > -1) {
if (this.mc._alpha == 0) {
return(undefined);
}
if (this.glassSmashed) {
return(undefined);
}
var hole = _root.table.holes[this.potted];
var a = _global.v2d.math.unify({x:hole.x - this.x, y:hole.y - this.y});
var d = (Math.sqrt(Math.pow(this.tx - hole.x, 2) + Math.pow(this.ty - hole.y, 2)) * 0.08);
this.vx = this.vx * 0.75;
this.vy = this.vy * 0.75;
this.vx = this.vx + (a.x * d);
this.vy = this.vy + (a.y * d);
this.x = this.x + this.vx;
this.y = this.y + this.vy;
this.vz = this.vz + 0.1;
this.mc._width = this.mc._width - this.vz;
this.mc._height = this.mc._height - this.vz;
this.mc._alpha = this.mc._alpha * Math.pow(0.95, _global.dt);
if (this.mc._alpha > 2) {
_root.stepRollTotalMovement = _root.stepRollTotalMovement + 1;
} else {
this.mc._alpha = 0;
this.mc._visible = false;
}
this.redraw();
return(undefined);
}
this.col = {pos:1, type:0, pvx:this.vx, pvy:this.vy};
if ((this.id == 8) && (_root.lvl.breakout)) {
while (!(this.vx + this.vy)) {
this.vx = 5;
this.vy = 0;
this.ax = 0;
this.ay = 0;
}
if (Math.random() < 0.05) {
this.ax = this.ax + ((Math.random() - 0.5) * 0.5);
this.ay = this.ay + ((Math.random() - 0.5) * 0.5);
}
this.vx = this.vx + this.ax;
this.vy = this.vy + this.ay;
this.tv = Math.sqrt((this.vx * this.vx) + (this.vy * this.vy));
this.vx = (this.vx / this.tv) * 6;
this.vy = (this.vy / this.tv) * 6;
}
this.tvx = this.vx * _global.dt;
this.tvy = this.vy * _global.dt;
this.tv = Math.sqrt((this.tvx * this.tvx) + (this.tvy * this.tvy));
if (this.id < 8) {
_root.stepRollTotalMovement = _root.stepRollTotalMovement + this.tv;
}
this.tx = this.x + this.tvx;
this.ty = this.y + this.tvy;
if (this.glassSmashed == 1) {
_root.stepRollTotalMovement = _root.stepRollTotalMovement + 2;
}
if (!((this.vx == 0) && (this.vy == 0))) {
var colPosTemp;
for (var i in _root.table.hwalls) {
var wall = _root.table.hwalls[i];
if (((Math.min(this.y, this.ty) - this.radius) <= wall.y0) && ((Math.max(this.y, this.ty) + this.radius) >= wall.y0)) {
if (((this.ty * wall.dir) <= ((wall.y0 * wall.dir) + this.radius)) && ((this.y * wall.dir) >= (((wall.y0 * wall.dir) + this.radius) - 1E-6))) {
var hitX = (this.x + ((((wall.y0 + (this.radius * wall.dir)) - this.y) / this.tvy) * this.tvx));
if ((hitX >= wall.x0) && (hitX <= wall.x1)) {
colPosTemp = 1 - ((this.ty - (wall.y0 + (this.radius * wall.dir))) / this.tvy);
if (colPosTemp < this.col.pos) {
this.col.type = 1;
this.col.pos = colPosTemp;
this.col.pvx = this.tvx / _global.dt;
this.col.pvy = (Math.abs(this.tvy * _root.table.flex) * wall.dir) / _global.dt;
}
}
}
this.pointCollision({x:wall.x0, y:wall.y0});
this.pointCollision({x:wall.x1, y:wall.y1});
}
}
for (var i in _root.table.vwalls) {
var wall = _root.table.vwalls[i];
if (((Math.min(this.x, this.tx) - this.radius) <= wall.x0) && ((Math.max(this.x, this.tx) + this.radius) >= wall.x0)) {
if (((this.tx * wall.dir) <= ((wall.x0 * wall.dir) + this.radius)) && ((this.x * wall.dir) >= (((wall.x0 * wall.dir) + this.radius) - 1E-6))) {
var hitY = (this.y + ((((wall.x0 + (this.radius * wall.dir)) - this.x) / this.tvx) * this.tvy));
if ((hitY >= wall.y0) && (hitY <= wall.y1)) {
colPosTemp = 1 - ((this.tx - (wall.x0 + (this.radius * wall.dir))) / this.tvx);
if (colPosTemp < this.col.pos) {
this.col.type = 1;
this.col.pos = colPosTemp;
this.col.pvy = this.tvy / _global.dt;
this.col.pvx = (Math.abs(this.tvx * _root.table.flex) * wall.dir) / _global.dt;
}
}
}
this.pointCollision({x:wall.x0, y:wall.y0});
this.pointCollision({x:wall.x1, y:wall.y1});
}
}
var i = 0;
while (i < (_root.ballsAmount + _root.breakout)) {
if (i != this.id) {
this.sphereCollision(_root.balls[i]);
}
i++;
}
var i = 0;
while (i < 6) {
if (_root.lids[i].closed) {
this.pointCollision(_root.lidPoints[i]);
this.pointCollision(_root.lidPoints2[i]);
}
i++;
}
if (this.col.type == 1) {
this.tx = this.x + (this.tvx * this.col.pos);
this.ty = this.y + (this.tvy * this.col.pos);
_root.snd.playEvent("reflect", this.tv * 0.05);
}
this.x = this.tx;
this.y = this.ty;
this.vx = this.col.pvx;
this.vy = this.col.pvy;
if (this.col.type == 2) {
this.col.q.vx = this.col.qvx;
this.col.q.vy = this.col.qvy;
}
var f = (1 - (0.09 * (1 - (Math.min(Math.abs(this.vx) + Math.abs(this.vy), 3) * 0.33))));
f = Math.pow(f * _root.lvl.friction, _global.dt);
this.vx = this.vx * f;
this.vy = this.vy * f;
this.redraw();
}
var hole;
var i = 0;
while (i < 6) {
if (_root.lids[i].closed) {
} else {
hole = _root.table.holes[i];
if ((Math.abs(this.tx - hole.x) <= hole.radius) && (Math.abs(this.ty - hole.y) <= hole.radius)) {
var d = Math.sqrt(Math.pow(this.tx - hole.x, 2) + Math.pow(this.ty - hole.y, 2));
if (d < hole.radius) {
if (this.id != 8) {
_root.pot(this.value, this.id);
} else {
this.spot = 1;
}
_root["h" + i].flash(this.value);
this.potted = i;
this.vz = 0;
}
}
}
i++;
}
};
CBall.prototype.sphereCollision = function (ball) {
if (ball.potted != -1) {
return(undefined);
}
var a = (ball.x - this.x);
var b = (ball.y - this.y);
var c = (Math.pow(this.tvx, 2) + Math.pow(this.tvy, 2));
var d = (((((this.tvy * a) - (this.tvx * b)) / c) * this.tv) * -1);
var j = Math.sqrt(Math.pow(this.radius + ball.radius, 2) - (d * d));
if (!isNaN(j)) {
var p = (((this.tvx * a) + (this.tvy * b)) / c);
p = p * (1 - (j / (p * this.tv)));
if ((p < 0) && (p > -1E-6)) {
p = 0;
}
if ((p >= 0) && (p < this.col.pos)) {
if (this.glass || (ball.glass)) {
if (this.glass) {
this.smashGlass();
}
if (ball.glass) {
ball.smashGlass();
}
}
var qax;
var qay;
var pvx;
var pvy;
var colvx;
var colvy;
var pv;
var qv;
this.col.pos = p;
this.col.type = 2;
this.tx = this.x + (this.tvx * p);
this.ty = this.y + (this.tvy * p);
qax = ball.x - this.tx;
qay = ball.y - this.ty;
pvx = qay * -1;
pvy = qax;
colvx = this.vx - ball.vx;
colvy = this.vy - ball.vy;
var colv = Math.sqrt((colvx * colvx) + (colvy * colvy));
_root.snd.playEvent("ballcollide", colv / 50);
pv = ((colvx * qay) - (colvy * qax)) / ((pvx * qay) - (pvy * qax));
this.col.q = ball;
qv = (colvy - (pv * qax)) / qay;
if (qv eq "NaN") {
this.col.qvx = this.vx;
this.col.qvy = this.vy;
} else {
qax = qax * qv;
qay = qay * qv;
this.col.qvx = ball.vx + qax;
this.col.qvy = ball.vy + qay;
}
pvx = pvx * pv;
pvy = pvy * pv;
this.col.pvx = pvx;
this.col.pvy = pvy;
_root.collision(this, ball);
}
}
};
CBall.prototype.pointCollision = function (point) {
var a = (point.x - this.x);
var b = (point.y - this.y);
var c = (Math.pow(this.tvx, 2) + Math.pow(this.tvy, 2));
var d = (((((this.tvy * a) - (this.tvx * b)) / c) * this.tv) * -1);
var j = Math.sqrt((this.radius * this.radius) - (d * d));
if (!isNaN(j)) {
var p = (((this.tvx * a) + (this.tvy * b)) / c);
p = p * (1 - (j / (p * this.tv)));
if ((p < 0) && (p > -1E-6)) {
p = 0;
}
if ((p >= 0) && (p < this.col.pos)) {
this.col.pos = p;
this.col.type = 3;
this.tx = this.x + (this.tvx * p);
this.ty = this.y + (this.tvy * p);
var x1 = (point.x - this.x);
var y1 = (point.y - this.y);
var n1 = ((((((x1 * x1) + (y1 * y1)) / ((this.tvx * x1) + (this.tvy * y1))) * this.tvy) - y1) / x1);
var pvx = (((y1 * n1) * -1) - x1);
var pvy = ((x1 * n1) - y1);
var pv = (((this.tv * _root.table.flex) / _global.dt) / Math.sqrt((pvx * pvx) + (pvy * pvy)));
this.col.pvx = pvx * pv;
this.col.pvy = Pvy * pv;
}
}
};
CBall.prototype.redraw = function () {
this.mc._x = this.x;
this.mc._y = this.y;
};
CBall.prototype.setSpeed = function (vx, vy) {
this.vx = vx;
this.vy = vy;
};
CBall.prototype.setPos = function (x, y) {
this.x = x;
this.y = y;
this.redraw();
};
CBall.prototype.toString = function () {
return(((((((((("[CBall mc:" + this.mc) + ", x:") + this.x) + ", y:") + this.y) + ", vx:") + this.vx) + ", vy:") + this.vy) + "]");
};
CLevel = function (xml) {
this.level = xml;
this.needScore = 10;
this.draw();
};
CLevel.prototype.draw = function () {
};
CLevel.prototype.serialize = function () {
var i = 0;
while (i < _root.ballsAmount) {
var obj = _root.balls[i];
var ball = this.level.firstChild.childNodes[i];
ball.attributes.id = obj.id;
ball.attributes.x = obj.x;
ball.attributes.y = obj.y;
i++;
}
return(this.level);
};
CLevel.prototype.init = function () {
var level = this.level.firstChild;
this.title = (((("Level " + _root.actLevel) + ": ") + unescape(level.attributes.title)) + " ") + ((_root.superLevel > 1) ? (_root.superLevel + 1) : "");
this.description = unescape(level.attributes.desc);
this.needPottedRed = int(level.attributes.needred);
this.needPottedColor = int(level.attributes.needcolor);
this.needBreak = int(level.attributes.needbreak);
this.needExact = int(level.attributes.needexact);
this.needOrder = level.attributes.needorder;
this.dontRespotColors = int(level.attributes.dontRespotColors);
this.time = int(level.attributes.time);
this.frame = int(level.attributes.frame);
this.speedUp = ((level.attributes.speedup eq "") ? 1 : (int(level.attributes.speedup)));
_root.timer.speed = ((level.attributes.timespeed eq "") ? 1 : (Number(level.attributes.timespeed)));
this.skin = ((level.attributes.skin eq "") ? "default" : (level.attributes.skin));
this.colorSwap = int(level.attributes.colorswap);
_root.swapTimerThreashold = ((this.colorSwap == 1) ? 180 : (((this.colorSwap == 2) ? 90 : 90)));
this.friction = ((level.attributes.friction eq "") ? (_root.table.friction) : (Number(level.attributes.friction)));
this.breakout = ((level.attributes.breakout eq "") ? 0 : 1);
var i = 0;
while (i < 6) {
this["h" + i] = level.attributes["l" + i];
_root.lids[i].gotoAndStop(int(level.attributes["l" + i]) + 1);
i++;
}
var i = 0;
while (i < _root.ballsAmount) {
var ball = _root.balls[i];
ball.x = _root.lvlProto[i].x + ((Math.random() - 0.5) * _root.spotVariance);
ball.y = _root.lvlProto[i].y + ((Math.random() - 0.5) * _root.spotVariance);
ball.reset();
i++;
}
for (var item in level.childNodes) {
item = this.level.firstChild.childNodes[item];
switch (item.nodeName) {
case "b" :
var ball = _root.balls[item.attributes.id];
ball.x = Number(item.attributes.x) + ((Math.random() - 0.5) * _root.spotVariance);
ball.y = Number(item.attributes.y) + ((Math.random() - 0.5) * _root.spotVariance);
ball.reset();
break;
default :
}
}
_root.cue._alpha = 0;
};
itemsPerPage = 5;
ballsAmount = 8;
spotVariance = 0.01;
scoreThreshold = 1500;
tables = new Array();
table = new Object();
table.flex = 0.9;
table.friction = 0.978;
table.x0 = 23.3;
table.x1 = 616.7;
table.y0 = 23.3;
table.y1 = 320.2;
table.cornerHoleSize = (cornerHoleSize ? (cornerHoleSize) : 68);
table.centerHoleSize = (centerHoleSize ? (centerHoleSize) : 60);
table.height = _height - 40;
table.hwalls = new Array();
table.hwalls[0] = {x0:table.x0 + (table.cornerHoleSize / 2), x1:(table.x0 + ((table.x1 - table.x0) / 2)) - (table.centerHoleSize / 2), y0:table.y0, y1:table.y0, dir:1};
table.hwalls[1] = {x0:(table.x0 + ((table.x1 - table.x0) / 2)) + (table.centerHoleSize / 2), x1:table.x1 - (table.cornerHoleSize / 2), y0:table.y0, y1:table.y0, dir:1};
table.hwalls[2] = {x0:table.x0 + (table.cornerHoleSize / 2), x1:(table.x0 + ((table.x1 - table.x0) / 2)) - (table.centerHoleSize / 2), y0:table.y1, y1:table.y1, dir:-1};
table.hwalls[3] = {x0:(table.x0 + ((table.x1 - table.x0) / 2)) + (table.centerHoleSize / 2), x1:table.x1 - (table.cornerHoleSize / 2), y0:table.y1, y1:table.y1, dir:-1};
table.vwalls = new Array();
table.vwalls[0] = {x0:table.x0, x1:table.x0, y0:table.y0 + (table.cornerHoleSize / 2), y1:table.y1 - (table.cornerHoleSize / 2), dir:1};
table.vwalls[1] = {x0:table.x1, x1:table.x1, y0:table.y0 + (table.cornerHoleSize / 2), y1:table.y1 - (table.cornerHoleSize / 2), dir:-1};
table.holes = new Array();
table.holes[0] = {x:17, y:17, radius:40.4};
table.holes[1] = {x:320, y:-14, radius:47.4};
table.holes[2] = {x:640 - table.holes[0].x, y:table.holes[0].y, radius:table.holes[0].radius};
table.holes[3] = {x:table.holes[0].x, y:(1 * table.hwalls[2].y0) - (table.holes[0].y - table.hwalls[0].y0), radius:table.holes[0].radius};
table.holes[4] = {x:table.holes[1].x, y:(1 * table.hwalls[2].y0) - (table.holes[1].y - table.hwalls[0].y0), radius:table.holes[1].radius};
table.holes[5] = {x:table.holes[2].x, y:(1 * table.hwalls[2].y0) - (table.holes[2].y - table.hwalls[0].y0), radius:table.holes[2].radius};
tables[0] = table;
lidPoints = new Array();
lidPoints[0] = {x:((table.vwalls[0].x0 * 0.5) + (table.hwalls[0].x0 * 0.5)) + 5, y:((table.vwalls[0].y0 * 0.5) + (table.hwalls[0].y0 * 0.5)) - 5};
lidPoints[1] = {x:((table.hwalls[0].x1 * 0.5) + (table.hwalls[1].x0 * 0.5)) - 10, y:table.y0 + 5};
lidPoints[2] = {x:((table.vwalls[1].x0 * 0.5) + (table.hwalls[1].x1 * 0.5)) - 5, y:((table.vwalls[1].y0 * 0.5) + (table.hwalls[1].y0 * 0.5)) - 5};
lidPoints[3] = {x:((table.vwalls[0].x0 * 0.5) + (table.hwalls[2].x0 * 0.5)) + 5, y:((table.vwalls[0].y1 * 0.5) + (table.hwalls[2].y0 * 0.5)) + 5};
lidPoints[4] = {x:((table.hwalls[0].x1 * 0.5) + (table.hwalls[1].x0 * 0.5)) - 10, y:table.y1 - 5};
lidPoints[5] = {x:((table.vwalls[1].x0 * 0.5) + (table.hwalls[3].x1 * 0.5)) - 5, y:((table.vwalls[1].y1 * 0.5) + (table.hwalls[3].y0 * 0.5)) + 5};
lidPoints2 = new Array();
lidPoints2[0] = {x:((table.vwalls[0].x0 * 0.5) + (table.hwalls[0].x0 * 0.5)) - 5, y:((table.vwalls[0].y0 * 0.5) + (table.hwalls[0].y0 * 0.5)) + 5};
lidPoints2[1] = {x:((table.hwalls[0].x1 * 0.5) + (table.hwalls[1].x0 * 0.5)) + 10, y:table.y0 + 5};
lidPoints2[2] = {x:((table.vwalls[1].x0 * 0.5) + (table.hwalls[1].x1 * 0.5)) + 5, y:((table.vwalls[1].y0 * 0.5) + (table.hwalls[1].y0 * 0.5)) + 5};
lidPoints2[3] = {x:((table.vwalls[0].x0 * 0.5) + (table.hwalls[2].x0 * 0.5)) - 5, y:((table.vwalls[0].y1 * 0.5) + (table.hwalls[2].y0 * 0.5)) - 5};
lidPoints2[4] = {x:((table.hwalls[0].x1 * 0.5) + (table.hwalls[1].x0 * 0.5)) + 10, y:table.y1 - 5};
lidPoints2[5] = {x:((table.vwalls[1].x0 * 0.5) + (table.hwalls[3].x1 * 0.5)) + 5, y:((table.vwalls[1].y1 * 0.5) + (table.hwalls[3].y0 * 0.5)) - 5};
table = new Object();
table.flex = tables[0].flex;
table.friction = tables[0].friction;
table.x0 = tables[0].x0;
table.x1 = tables[0].x1;
table.y0 = tables[0].y0;
table.y1 = tables[0].y1;
table.cornerHoleSize = tables[0].cornerHoleSize;
table.centerHoleSize = tables[0].centerHoleSize;
table.height = tables[0].height;
table.hwalls = new Array();
table.hwalls[0] = {x0:table.x0, x1:table.x1, y0:table.y0, y1:table.y0, dir:1};
table.hwalls[1] = {x0:-100, x1:-101, y0:-100, y1:-101, dir:1};
table.hwalls[2] = tables[0].hwalls[2];
table.hwalls[3] = tables[0].hwalls[3];
table.vwalls = new Array();
table.vwalls[0] = {x0:table.x0, x1:table.x0, y0:table.y0, y1:table.y1 - (table.cornerHoleSize / 2), dir:1};
table.vwalls[1] = {x0:table.x1, x1:table.x1, y0:table.y0, y1:table.y1 - (table.cornerHoleSize / 2), dir:-1};
table.holes = new Array();
table.holes[0] = {x:-100, y:-100, radius:1};
table.holes[1] = {x:-100, y:-100, radius:1};
table.holes[2] = {x:-100, y:-100, radius:1};
table.holes[3] = tables[0].holes[3];
table.holes[4] = tables[0].holes[4];
table.holes[5] = tables[0].holes[5];
tables[1] = table;
table = new Object();
table.flex = tables[0].flex;
table.friction = tables[0].friction;
table.x0 = tables[0].x0;
table.x1 = tables[0].x1;
table.y0 = tables[0].y0;
table.y1 = tables[0].y1;
table.cornerHoleSize = tables[0].cornerHoleSize;
table.centerHoleSize = tables[0].centerHoleSize;
table.height = tables[0].height;
table.hwalls = new Array();
table.hwalls[2] = {x0:table.x0, x1:table.x1, y0:table.y1, y1:table.y1, dir:-1};
table.hwalls[3] = {x0:-100, x1:-101, y0:-100, y1:-101, dir:-1};
table.hwalls[0] = tables[0].hwalls[0];
table.hwalls[1] = tables[0].hwalls[1];
table.vwalls = new Array();
table.vwalls[0] = {x0:table.x0, x1:table.x0, y0:table.y0 + (table.cornerHoleSize / 2), y1:table.y1, dir:1};
table.vwalls[1] = {x0:table.x1, x1:table.x1, y0:table.y0 + (table.cornerHoleSize / 2), y1:table.y1, dir:-1};
table.holes = new Array();
table.holes[0] = tables[0].holes[0];
table.holes[1] = tables[0].holes[1];
table.holes[2] = tables[0].holes[2];
table.holes[3] = {x:-100, y:-100, radius:1};
table.holes[4] = {x:-100, y:-100, radius:1};
table.holes[5] = {x:-100, y:-100, radius:1};
tables[2] = table;
aimDistance = 3;
aimRange = 50;
ballSize = 24;
this.steps = -1;
replayDataSlots = new Array();
_root.replayDataSlots[1] = new Array();
_root.replayDataSlots[1][0] = {x:203, y:169.95, vx:28.2282346046794, vy:0};
_root.replayDataSlots[1][1] = {x:388.95, y:169.95, vx:0, vy:0};
_root.replayDataSlots[1][2] = {x:416.95, y:153.95, vx:0, vy:0};
_root.replayDataSlots[1][3] = {x:416.95, y:184.95, vx:0, vy:0};
_root.replayDataSlots[1][4] = {x:444.95, y:168.95, vx:0, vy:0};
_root.replayDataSlots[1][5] = {x:475.95, y:169.95, vx:0, vy:0};
_root.replayDataSlots[1][6] = {x:509.95, y:169.95, vx:0, vy:0};
_root.replayDataSlots[1][7] = {x:542.95, y:169.95, vx:0, vy:0};
_root.replayDataSlots[2] = new Array();
_root.replayDataSlots[2][0] = {x:435.53254579983, y:282.529219395612, vx:-10.8018815036205, vy:-3.88055991123523};
_root.replayDataSlots[2][1] = {x:181.309250796516, y:498.750719159373, vx:-2.52374030597811E-18, vy:2.8650554134667E-18};
_root.replayDataSlots[2][2] = {x:444.996423706607, y:332.92118806533, vx:3.70632672696534E-10, vy:6.40451012190524E-10};
_root.replayDataSlots[2][3] = {x:103.959243218691, y:125.979241226676, vx:-0.168341140386019, vy:-0.0825094140402536};
_root.replayDataSlots[2][4] = {x:322.386221548055, y:59.8600270768538, vx:-4.46027017527593E-7, vy:-3.00509085586092E-8};
_root.replayDataSlots[2][5] = {x:287.831056269539, y:304.066637712036, vx:1.37588566724853E-5, vy:-2.16042838801739E-5};
_root.replayDataSlots[2][6] = {x:389.942879410448, y:325.320767727873, vx:-1.42404514264455E-20, vy:-1.3386968667468E-20};
_root.replayDataSlots[2][7] = {x:477.159829529633, y:364.459565310889, vx:-8.72098344355839E-8, vy:2.76352449074515E-7};
_root.replayDataSlots[3] = new Array();
_root.replayDataSlots[3][0] = {x:233.728252230275, y:305.315505136142, vx:1.03267099835645, vy:5.40254867960916};
_root.replayDataSlots[3][1] = {x:181.309250796516, y:498.750719159373, vx:-3.23044024335169E-37, vy:3.66733070164618E-37};
_root.replayDataSlots[3][2] = {x:440.923819804678, y:343.919409689538, vx:-2.18443160756074E-14, vy:-2.67926083433765E-13};
_root.replayDataSlots[3][3] = {x:101.718939050347, y:124.881196008626, vx:-2.15480171722322E-20, vy:-1.05613771329653E-20};
_root.replayDataSlots[3][4] = {x:322.386215612274, y:59.8600266769327, vx:-5.70923887703587E-26, vy:-3.84657898940948E-27};
_root.replayDataSlots[3][5] = {x:315.436644354803, y:315.445593484631, vx:4.45097432973508E-5, vy:-2.73611142484804E-5};
_root.replayDataSlots[3][6] = {x:467.611976404249, y:55.1317718260599, vx:-0.0336334980630561, vy:0.0492420233503286};
_root.replayDataSlots[3][7] = {x:477.159828369034, y:364.459568988621, vx:-1.11630407498509E-26, vy:3.53736900236696E-26};
_root.replayDataSlots[4] = new Array();
_root.replayDataSlots[4][0] = {x:416.113101738138, y:308.948209680405, vx:15.0174081993993, vy:-6.83708710913236};
_root.replayDataSlots[4][1] = {x:181.309250796516, y:498.750719159373, vx:-1.51161133026735E-27, vy:1.71604432301587E-27};
_root.replayDataSlots[4][2] = {x:440.925199940032, y:343.936337400106, vx:-0.000102215528517469, vy:-0.00125369941210376};
_root.replayDataSlots[4][3] = {x:101.718939051708, y:124.881196009293, vx:-1.00829064921959E-10, vy:-4.94195717449737E-11};
_root.replayDataSlots[4][4] = {x:322.386215612274, y:59.8600266769327, vx:-2.67150899679735E-16, vy:-1.79991949862751E-17};
_root.replayDataSlots[4][5] = {x:287.83123937406, y:304.066350199625, vx:8.24096028754935E-15, vy:-1.29400319907029E-14};
_root.replayDataSlots[4][6] = {x:318.32650278171, y:349.141322089796, vx:-0.067525605653441, vy:0.0224599098140375};
_root.replayDataSlots[4][7] = {x:477.159828369034, y:364.459568988621, vx:-5.22349203407743E-17, vy:1.65523168995895E-16};
lvlProto = new Array();
lvlProto[0] = {x:157, y:206};
lvlProto[1] = {x:450, y:170};
lvlProto[2] = {x:157, y:246};
lvlProto[3] = {x:157, y:170};
lvlProto[4] = {x:157, y:94};
lvlProto[5] = {x:320, y:170};
lvlProto[6] = {x:397, y:170};
lvlProto[7] = {x:560, y:170};
lvls = new Array();
lvls[0] = new CLevel(new XML("<lvl time=\"99\" title=\"Little Break\" needred=\"1\" needcolor=\"1\" desc=\"Pot 1 red and 1 colour\"><b y=\"132\" x=\"157\" id=\"0\" /><b y=\"61\" x=\"552.95\" id=\"1\" /></lvl>"));
lvls[1] = new CLevel(new XML("<lvl time=\"99\" title=\"Coffee Break\" needred=\"2\" needcolor=\"2\" desc=\"Pot 2 reds and 2 colours\"></lvl>"));
lvls[2] = new CLevel(new XML("<lvl time=\"99\" title=\"Tea Break\" needred=\"3\" needcolor=\"3\" desc=\"Pot 3 reds and 3 colours\"></lvl>"));
lvls[3] = new CLevel(new XML("<lvl time=\"99\" title=\"Lunch Break\" needbreak=\"20\" desc=\"Get a break of 20 or more\"></lvl>"));
lvls[4] = new CLevel(new XML("<lvl time=\"99\" title=\"Weekend Break\" needred=\"4\" needcolor=\"4\" desc=\"Pot 4 reds and 4 colours\"></lvl>"));
lvls[5] = new CLevel(new XML("<lvl time=\"99\" title=\"Long Break\" needbreak=\"25\" desc=\"Get a break of 25 or more\"></lvl>"));
lvls[6] = new CLevel(new XML("<lvl time=\"99\" title=\"Longer Break\" needred=\"5\" needcolor=\"5\" desc=\"Pot 5 reds and 5 colours\"></lvl>"));
lvls[7] = new CLevel(new XML("<lvl time=\"110\" title=\"Big Break\" needbreak=\"30\" desc=\"Get a break of 30 or more\"></lvl>"));
lvls[8] = new CLevel(new XML("<lvl time=\"110\" title=\"Bigger Break\" needbreak=\"35\" desc=\"Get a break of 35 or more\"></lvl>"));
lvls[9] = new CLevel(new XML("<lvl time=\"110\" title=\"Huge Break\" needbreak=\"40\" desc=\"Get a break of 40 or more\"></lvl>"));
lvls[10] = new CLevel(new XML("<lvl time=\"130\" title=\"Exact Break\" needexact=\"41\" desc=\"Get a break of exactly 41\"></lvl>"));
lvls[11] = new CLevel(new XML("<lvl time=\"130\" title=\"Break Up\" frame=\"2\" needbreak=\"35\" desc=\"Get a break of 35 or more - the bottom three pockets are closed\"></lvl>"));
lvls[12] = new CLevel(new XML("<lvl time=\"140\" title=\"Break Down\" frame=\"1\" needbreak=\"40\" desc=\"Get a break of 40 or more - the top three pockets are closed\"></lvl>"));
lvls[13] = new CLevel(new XML("<lvl time=\"140\" title=\"Break in a Row\" dontRespotColors=\"1\" needorder=\"1213141516171\" desc=\"Get a break of 34 by potting the colours in ascending order\"></lvl>"));
lvls[14] = new CLevel(new XML("<lvl time=\"140\" title=\"Nervous Break Down\" colorswap=\"1\" needbreak=\"40\" desc=\"Get a break of 40 or more - all the colours swap around every 6 seconds\"></lvl>"));
lvls[15] = new CLevel(new XML("<lvl time=\"140\" title=\"Break the Ice\" skin=\"ice\" friction=\"0.99\" needbreak=\"40\" desc=\"Get a break of 40 or more - table turns to ice and there is almost no friction\"></lvl>"));
lvls[16] = new CLevel(new XML("<lvl time=\"140\" title=\"Hand Break\" l0=\"2\" l1=\"2\" l2=\"2\" l3=\"2\" l4=\"2\" l5=\"2\" colorswap=\"3\" needbreak=\"40\" desc=\"Get a break of 40 or more - a mini hand comes and blocks pockets every so often\"></lvl>"));
lvls[17] = new CLevel(new XML("<lvl time=\"140\" title=\"Break Light\" speedup=\"2\" needbreak=\"50\" desc=\"Get a break of 50 or more - balls all move at twice the speed\"></lvl>"));
lvls[18] = new CLevel(new XML("<lvl time=\"150\" title=\"Breaking Glass\" colorswap=\"2\" needbreak=\"50\" desc=\"Get a break of 50 or more - one of the balls is glass, changing every three seconds and the next glass ball is random\"></lvl>"));
lvls[19] = new CLevel(new XML("<lvl time=\"400\" title=\"Biggest Break\" needbreak=\"147\" desc=\"Get a break of 147 or more\"></lvl>"));
snd = new Object();
snd.lib = new Array();
snd.global = new Sound();
snd.global.setVolume(100);
snd.active = 1;
snd.actMc = 0;
snd.idMc = 0;
snd.mcs = new Array();
var i = 0;
while (i < 10) {
snd.mcs[i] = _root.createEmptyMovieClip("sndMc" + this.idMc, this.idMc++);
i++;
}
snd.load = function (id, volume) {
if (volume eq "") {
volume = 100;
}
var mc = _root.createEmptyMovieClip("sndMc" + this.idMc, this.idMc++);
this.lib[id] = new Sound(mc);
this.lib[id].mc = mc;
this.lib[id].attachSound(id);
this.lib[id].setVolume(volume);
};
snd.play = function (id) {
this.lib[id].start(id);
this.lib[id].setVolume(100);
};
snd.playLoop = function (id) {
this.lib[id].start(id, 99999);
this.lib[id].playing = 1;
};
snd.playEvent = function (id, volume) {
if (volume === undefined) {
volume = 1;
}
volume = Math.max(0, Math.min(1, volume));
var mc = this.getMc();
var s = new Sound(mc);
s.attachSound(id);
s.setVolume(volume * 100);
s.start();
};
snd.stopAll = function () {
for (var i in this.lib) {
this.lib[i].stop();
}
};
snd.getMc = function () {
this.actMc++;
if (this.actMc >= this.mcs.length) {
this.actMc = 0;
}
return(this.mcs[this.actMc]);
};
snd.stop = function (id) {
this.lib[id].stop();
this.lib[id].playing = 0;
};
snd.load("thunder");
snd.load("titlemusic");
snd.load("levelmusic");
snd.load("ballcollide");
snd.load("tube");
snd.load("cuehit");
snd.load("tic");
snd.load("go");
snd.load("pot");
snd.load("gameover");
snd.load("foul", 80);
snd.load("glass");
snd.load("thunderCrack");
snd.load("thunderRumble");
snd.load("excellent");
submitScore = function () {
game = "lightningbreak";
score = _root.totalScore;
if (_url.indexOf("playaholics") != -1) {
getURL ("http://www.playaholics.com/comp_entry.php", "_top", "POST");
} else if (_url.indexOf("bluesqgames") != -1) {
_root.submit.loadVariables((("http://www.bluesqgames.net/multigame/submitscore/index.php?game_name=" + game) + "&score=") + score, _root.submit);
getURL ("http://www.bluesqgames.net/multigame/playagain/index.php", "_top");
}
};
cleanup = function () {
Mouse.removeListener(this.stepAim);
Mouse.removeListener(this.stepPower);
this.onMouseDown = 0;
this.onMouseUp = 0;
this.onEnterFrame = 0;
this.timer.running = false;
_root.snd.stopAll();
_root.endGame();
};
endGame = function () {
if (_root.gameEnded) {
return(undefined);
}
_root.gameEnded = true;
if (_root.totalScore > 0) {
_root.user.data.tr = int(_root.user.data.tr) + 1;
if (_root.user.data.tr == 0) {
_root.user.data.tr = 1;
}
_root.user.data.th = Math.max(_root.totalScore, int(_root.user.data.th));
_root.user.data.ta = ((Number(_root.user.data.ta) * (_root.user.data.tr - 1)) + _root.totalScore) / _root.user.data.tr;
_root.flush();
}
};
this.timer = createEmptyMovieClip("timer", 99);
this.timer.running = false;
this.timer.speed = 1;
timer.init = function (timeTotal) {
this.timeTotal = timeTotal * 1000;
this.timeStart = getTimer();
_root.timeLeft = this.timeTotal;
this.running = false;
};
timer.onEnterFrame = function () {
if (_root.paused) {
this.timestamp = getTimer();
return(undefined);
}
_global.dt = (((getTimer() - this.timestamp) / 33) * 0.3) + (_global.dt * 0.7);
this.timestamp = getTimer();
if (this.running) {
_root.timeLeft = _root.timeLeft - ((_global.dt * 33) * this.speed);
}
this.update();
};
timer.update = function () {
if (_root.paused) {
return(undefined);
}
_root.bg.time.time.time.gotoAndStop(Math.max(Math.floor(_root.timeLeft / 1000) + 2, 1));
if ((_root.timeLeft <= -0.5) && (this.running)) {
this.running = false;
if (_root.onEnterFrame != stepRoll) {
_root.startLevelOver();
}
}
};
timer.initColorSwap = function () {
this.colorSwapTimer = 0;
var i = 1;
while (i < _root.ballsAmount) {
_root.balls[i].initColorSwap();
i++;
}
};
timer.stepColorSwap = function () {
if (_root.paused) {
return(undefined);
}
if (!_root.lvl.colorSwap) {
return(undefined);
}
this.colorSwapTimer = this.colorSwapTimer + _global.dt;
if (this.colorSwapTimer > _root.swapTimerThreashold) {
this.colorSwapTimer = 0;
_root.colorSwap();
}
};
timer.timestamp = getTimer();
initGame = function () {
_root.levelsPlayed = 0;
_root.totalShots = 0;
_root.gameEnded = false;
_root.actScore = 0;
_root.totalScore = 0;
_root.actBreak = 0;
_root.timeLeft = -1;
_root.pointer.gotoAndStop("wait");
_root.timer.running = false;
initTable();
loadLevel(_root.actLvl);
};
initTable = function () {
this.balls = new Array();
var i = 0;
while (i < (this.ballsAmount + 1)) {
this.balls[i] = new CBall(i, this["b" + i]);
i++;
}
this.lids = new Array();
var i = 0;
while (i < 6) {
this.lids[i] = _root["l" + i];
i++;
}
};
loadLevel = function (id) {
_root.actLvl = id;
_root.actLevel = _root.actLvl + 1;
if (_root.actLvl > _root.maxLevel) {
_root.user.data.maxLevel = _root.actLvl;
_root.flush();
_root.maxLevel = int(_root.user.data.maxLevel);
}
_root.actScore = 0;
_root.actBreak = 0;
_root.actPottedRed = 0;
_root.actPottedColor = 0;
_root.actPottedOrder = "";
_root.nominatedNext = 1;
_root.actRoundsPlayed = _root.stats[this.actLvl].rounds;
_root.actHighScore = _root.stats[this.actLvl].highscore;
_root.actAvgScore = _root.stats[this.actLvl].average;
_root.lvl = _root.lvls[_root.actLvl % 20];
_root.lvl.init();
_root.timePerLevel = (this.lvl.time * (1 - (Math.floor(_root.actLvl / 20) * 0.1))) + 0.99;
if (_root.timePerLevel == 100.99) {
_root.timePerLevel = 99.99;
}
_root.bg.outer.gotoAndStop(_root.lvl.skin);
_root.bg.time.inner.gotoAndStop(_root.lvl.skin);
if (_root.lvl.breakout) {
_root.balls[8].setPos(100, 100);
_root.balls[8].reset();
}
_root.h0._visible = _root.lvl.frame != 1;
_root.h1._visible = _root.lvl.frame != 1;
_root.h2._visible = _root.lvl.frame != 1;
_root.h3._visible = _root.lvl.frame != 2;
_root.h4._visible = _root.lvl.frame != 2;
_root.h5._visible = _root.lvl.frame != 2;
_root.frame.gotoAndStop(_root.lvl.frame + 1);
_root.table = _root.tables[_root.lvl.frame];
_root.startLevel();
};
startLevel = function () {
this.phase = 0;
this.onEnterFrame = this.stepLevel;
this.nominated = 1;
_root.timer.initColorSwap();
};
stepLevel = function () {
if (this.paused) {
return(undefined);
}
this.timer.stepColorSwap();
if (this.phaseDelay > 0) {
this.phaseDelay = this.phaseDelay - _global.dt;
return(undefined);
}
switch (this.phase) {
case 0 :
_root.snd.play("levelmusic");
_root.bg.gotoAndPlay("level");
this.phase++;
return;
case 1 :
return;
case 2 :
_root.osd.gotoAndPlay("level");
this.phase++;
return;
case 3 :
return;
case 4 :
_root.osd.gotoAndPlay("countdown3");
_root.snd.playEvent("tic", 50);
this.phaseDelay = 20;
this.phase++;
return;
case 5 :
_root.osd.gotoAndPlay("countdown2");
_root.snd.playEvent("tic", 50);
this.phaseDelay = 20;
this.phase++;
return;
case 6 :
_root.osd.gotoAndPlay("countdown1");
_root.snd.playEvent("tic", 50);
this.phaseDelay = 20;
this.phase++;
return;
case 7 :
_root.osd.gotoAndPlay("go");
_root.snd.play("go");
this.phaseDelay = 20;
this.phase++;
case 8 :
if ((this.totalShots > 0) || (this.actLvl != 0)) {
_root.spotBall(0);
_root.spotBall(1, 1);
}
var i = 0;
while (i < (_root.ballsAmount + _root.lvl.breakout)) {
_root.balls[i].mc.gotoAndPlay("appear");
i++;
}
this.phaseDelay = 10;
this.phase++;
return;
case 9 :
_root.timer.running = true;
startAim();
return;
}
};
startAim = function () {
this.nominated = this.nominatedNext;
this.validPotMode = 0;
this.shotPots = "";
_root.pointer.gotoAndStop("aim");
var i = 0;
while (i < _root.ballsAmount) {
if ((_root.balls[i].spot || (int(_root.balls[i].x) == 0)) || (int(_root.balls[i].y) == 0)) {
_root.spotBall(i);
}
i++;
}
_root.cue._visible = true;
_root.cue.scale._visible = false;
_root.cue.gfx._y = (this.balls[0].radius * -1) - this.aimDistance;
_root.cue._x = this.balls[0].x;
_root.cue._y = this.balls[0].y;
if (_root.lvl.needOrder eq "") {
if (this.nominated > 0) {
this.balls[this.nominated].mc.marker.gotoAndPlay("active");
} else {
var i = 2;
while (i < _root.ballsAmount) {
this.balls[i].mc.marker.gotoAndPlay("active");
i++;
}
}
} else {
var target = _root.lvl.needOrder.charAt(_root.actPottedOrder.length);
this.balls[target].mc.marker.gotoAndPlay("active");
this.nominated = target;
}
var i = 0;
while (i < this.ballsAmount) {
this.balls[i].showLabel();
i++;
}
Mouse.addListener(this.stepAim);
this.onEnterFrame = this.stepAim;
};
stepAim = function () {
if (_root.paused) {
return(undefined);
}
this.timer.stepColorSwap();
if (this.phaseDelay > 0) {
this.phaseDelay = this.phaseDelay - _global.dt;
return(undefined);
}
if (_root._ymouse > 348) {
_root.pointer.gotoAndStop("wait");
} else {
_root.pointer.gotoAndStop("aim");
}
_root.cue._alpha = Math.min(_root.cue._alpha + 15, 100);
_root.cue._rotation = ((_global.v2d.math.r2vertSgnAngle(this.balls[0].x, this.balls[0].y, _root._xmouse, _root._ymouse) / Math.PI) * 180) - 180;
_root.aimVector = _global.v2d.math.unify({x:_root._xmouse - _root.balls[0].x, y:_root._ymouse - _root.balls[0].y});
};
stepAim.onMouseDown = function () {
if (_root.paused) {
return(undefined);
}
if (_root._ymouse > 348) {
return(undefined);
}
Mouse.removeListener(this);
_root.startPower();
};
startPower = function () {
Mouse.addListener(this.stepPower);
_root.cue._alpha = 100;
_root.cue.scale._visible = true;
_root.cue.scale._y = (this.balls[0].radius * -1) - this.aimDistance;
this.startPowerTime = getTimer();
this.powerOld = 0;
this.powerAct = 0;
this.powerV = 0;
this.onEnterFrame = this.stepPower;
};
stepPower = function () {
if (_root.paused) {
return(undefined);
}
this.stepAim();
var dt = (getTimer() - this.startPowerTime);
this.powerAct = (1 - Math.cos(dt / 350)) / 2;
this.cueV = (((this.powerAct - this.powerOld) * this.aimRange) * -1) / _global.dt;
this.cue.scale.gotoAndStop(1 + Math.floor(this.powerAct * 50));
this.pointer.gotoAndStop(2 + Math.floor(this.powerAct * 50));
this.powerOld = this.powerAct;
_root.cue.gfx._y = ((this.balls[0].radius * -1) - this.aimDistance) - (this.powerAct * this.aimRange);
};
stepPower.onMouseUp = function () {
Mouse.removeListener(this);
_root.pointer.gotoAndStop(1);
_root.cue.scale._visible = false;
_root.cueA = Math.max(Math.pow(_root.powerAct * 4, 1.8), 0.1);
_root.startShoot();
};
startShoot = function () {
this.totalShots++;
this.onEnterFrame = this.stepShoot;
var i = 0;
while (i < this.ballsAmount) {
this.balls[i].hideLabel();
i++;
}
};
stepShoot = function () {
if (_root.paused) {
return(undefined);
}
this.timer.stepColorSwap();
ty = _root.cue.gfx._y + (this.cueV * _global.dt);
this.cueV = this.cueV + (this.cueA * _global.dt);
if (ty > (this.balls[0].radius * -1)) {
ty = this.balls[0].radius * -1;
_root.snd.playEvent("cuehit", _root.powerAct);
this.cueV = this.cueV * _root.lvl.speedUp;
this.balls[0].vx = this.aimVector.x * this.cueV;
this.balls[0].vy = this.aimVector.y * this.cueV;
this.startRoll();
}
_root.cue.gfx._y = ty;
};
startRoll = function () {
var i = 1;
while (i < _root.ballsAmount) {
if (this.balls[i].mc.marker._currentframe > 1) {
this.balls[i].mc.marker.gotoAndPlay("vanish");
}
i++;
}
this.replaySave();
_root.pointer.gotoAndStop("wait");
this.firstHit = 0;
this.stepRollCount = 0;
this.onEnterFrame = this.stepRoll;
};
stepRoll = function () {
if (_root.paused) {
return(undefined);
}
this.timer.stepColorSwap();
if (this.steps == 0) {
return(undefined);
}
if (this.steps > 0) {
this.steps--;
}
_root.gstep.clear();
this.stepRollTotalMovement = 0;
var i = 0;
while (i < (this.ballsAmount + _root.lvl.breakout)) {
this.balls[i].move();
i++;
}
this.stepRollCount = this.stepRollCount + _global.dt;
if (this.stepRollCount > 30) {
if (_root.cue._alpha > 0) {
_root.cue._alpha = Math.max((_root.cue._alpha * 0.8) - 1, 0);
} else {
_root.cue._visible = false;
}
if (this.stepRollTotalMovement < 0.2) {
var i = 0;
while (i < this.ballsAmount) {
this.balls[i].setSpeed(0, 0);
i++;
}
_root.pointer.gotoAndStop("ready");
if (_root.missionAccomplished()) {
this.startLevelOver();
return(undefined);
}
var allPotted = true;
var i = 1;
while (i < _root.ballsAmount) {
if (_root.balls[i].potted == -1) {
allPotted = false;
}
i++;
}
if (allPotted) {
this.startLevelOver();
return(undefined);
}
if ((_root.firstHit == 0) && (_root.balls[0].potted == -1)) {
_root.foul(4, "- 4 seconds for missing");
}
if ((_root.lvl.needExact != 0) && (_root.lvl.actBreak > _root.lvl.needExact)) {
this.startLevelOver();
return(undefined);
}
if (this.timeLeft <= 0) {
this.startLevelOver();
} else {
this.startAim();
}
}
}
};
startLevelOver = function (gameover) {
this.phase = 0;
if (gameover) {
this.phase = "alreadydead";
}
this.phaseDelay = 0;
Mouse.removeListener(this.stepPower);
Mouse.removeListener(this.stepAim);
this.pointer.gotoAndStop("wait");
this.onEnterFrame = this.stepLevelOver;
_root.stats[this.actLvl].rounds++;
_root.stats[this.actLvl].highscore = Math.max(_root.stats[this.actLvl].highscore, _root.actScore);
_root.stats[this.actLvl].average = Math.round(((_root.stats[this.actLvl].average * (_root.stats[this.actLvl].rounds - 1)) + _root.actScore) / _root.stats[this.actLvl].rounds);
_root.user.data[this.actLvl + "r"] = _root.stats[this.actLvl].rounds;
_root.user.data[this.actLvl + "h"] = _root.stats[this.actLvl].highscore;
_root.user.data[this.actLvl + "a"] = _root.stats[this.actLvl].average;
_root.flush();
};
stepLevelOver = function () {
if (_root.paused) {
return(undefined);
}
if (_root.cue._alpha > 0) {
_root.cue._alpha = Math.max((_root.cue._alpha * 0.9) - 1, 0);
} else {
_root.cue._visible = false;
}
if (this.phaseDelay > 0) {
this.phaseDelay = this.phaseDelay - _global.dt;
return(undefined);
}
switch (this.phase) {
case 0 :
this.snd.play("thunderRumble");
if (_root.missionAccomplished()) {
_root.levelsPlayed++;
_root.actTimeBonus = _root.levelsPlayed * Math.floor(_root.timeLeft / 1000);
_root.totalScore = _root.totalScore + _root.actTimeBonus;
_root.actScore = _root.actScore + _root.actTimeBonus;
_root.osd.gotoAndPlay("welldone");
} else {
_root.osd.gotoAndPlay("timeout");
}
this.phaseDelay = 30;
this.phase++;
return;
case 1 :
if (_root.missionAccomplished()) {
_root.tube.empty();
}
this.phaseDelay = 30;
this.phase++;
return;
case 2 :
if (_root.missionAccomplished()) {
var i = 0;
while (i < _root.ballsAmount) {
_root.balls[i].mc.gotoAndPlay("vanish");
i++;
}
}
this.phaseDelay = 30;
this.phase++;
return;
case 3 :
this.phase++;
if (_root.missionAccomplished()) {
this.loadLevel(_root.actLvl + 1);
}
return;
case 4 :
this.snd.play("gameover");
_root.osd.gotoAndPlay("gameover");
this.phase++;
return;
case "alreadydead" :
this.phase = 5;
case 5 :
}
};
replaySave = function (slot) {
if (slot) {
this.replayDataSlots[slot] = this.replayData;
var i = 0;
while (i < this.ballsAmount) {
i++;
}
return(undefined);
}
this.replayData = new Array();
var i = 0;
while (i < this.ballsAmount) {
this.replayData[i] = {x:this.balls[i].x, y:this.balls[i].y, vx:this.balls[i].vx, vy:this.balls[i].vy};
i++;
}
};
replayLoad = function (slot) {
if (slot) {
this.replayData = this.replayDataSlots[slot];
}
if (!this.replayData) {
return(undefined);
}
var i = 0;
while (i < this.ballsAmount) {
this.balls[i].setPos(this.replayData[i].x, this.replayData[i].y);
this.balls[i].setSpeed(this.replayData[i].vx, this.replayData[i].vy);
i++;
}
this.cue._visible = false;
this.cue._alpha = 0;
this.startRoll();
};
standardShot = function () {
this.balls[0].vx = 20;
this.balls[0].vy = 0;
this.startRoll();
};
pot = function (value, id) {
this.snd.play("pot");
_root.balls[id].spot = 1;
switch (value) {
case 0 :
_root.foul(4, "- 4 seconds for potting white ball");
return;
default :
this.shotPots = this.shotPots + ("" + value);
if (((_root.lvl.needOrder.substr(this.actPottedOrder.length, 1) eq value) || ((this.nominated == value) || ((this.nominated == 0) && (value > 1)))) || (this.validPotMode)) {
if (_root.lvl.dontRespotColors && (value > 1)) {
_root.balls[id].spot = 0;
}
if (this.validPotMode) {
_root.osd.gotoAndPlay("excellent");
_root.snd.play("excellent");
}
this.validPotMode = 1;
this.score(value);
if (value == 1) {
this.nominatedNext = 0;
this.actPottedRed++;
} else {
this.nominatedNext = 1;
this.actPottedColor++;
}
this.actPottedOrder = this.actPottedOrder + value;
_root.tube.addBall(value);
} else {
_root.foul(4, "- 4 seconds for potting wrong ball");
}
}
};
score = function (value) {
_root.actBreak = _root.actBreak + value;
_root.actScore = _root.actScore + (value * Math.floor(_root.timeLeft / 1000));
_root.totalScore = _root.totalScore + (value * Math.floor(_root.timeLeft / 1000));
};
collision = function (b0, b1) {
if ((b0.id == 0) || (b1.id == 0)) {
var col = (b0.id + b1.id);
this.firstHit = col;
this.firstHitLegal = 1;
}
};
foul = function (seconds, text) {
_root.lightning.gotoAndPlay("double");
_root.actFoul = text;
_root.timeLeft = _root.timeLeft - (seconds * 1000);
_root.osd.gotoAndPlay("foul");
_root.snd.play("foul");
};
spotBall = function (id, flags) {
var tableCenterX = (_root.table.x0 + ((_root.table.x1 - _root.table.x0) / 2));
var tableCenterY = (_root.table.y0 + ((_root.table.y1 - _root.table.y0) / 2));
var difficulty = 0.5;
var posX;
var posY;
putX = _root.lvlProto[id].x;
putY = _root.lvlProto[id].y;
while (true) {
if (id == 0) {
putX = _root.lvlProto[id].x;
putY = tableCenterY + ((((_root.table.y1 - _root.table.y0) - _root.ballSize) - 2) * (Math.random() - 0.5));
} else if (id == 1) {
r0 = Math.random();
r1 = Math.random() - 0.5;
if (flags && 1) {
r0 = Math.max(r0, 0.2);
r1 = Math.max(0.3, Math.abs(r1));
if (_root.balls[0].y < tableCenterY) {
r1 = r1 * -1;
}
}
putX = _root.lvlProto[id].x + (85 * r0);
putY = _root.lvlProto[id].y + ((150 * r1) * r0);
}
var space = 999;
var i = 0;
while (i < _root.ballsAmount) {
if ((i == id) || (_root.balls[i].potted > -1)) {
} else {
space = Math.min(space, _global.v2d.math.p2pDistance(putX, putY, _root.balls[i].x, _root.balls[i].y));
}
i++;
}
if (space > (_root.ballSize + 1)) {
_root.balls[id].reset();
_root.balls[id].setPos(putX, putY);
_root.balls[id].mc.gotoAndPlay("appear");
_root.balls[id].spot = 0;
return;
}
putX = putX + (_root.ballSize + 2);
if (putX > (_root.table.x1 - _root.ballSize)) {
putX = _root.lvlProto[id].x;
putY = putY + (_root.ballSize + 2);
}
}
};
missionAccomplished = function () {
if (((((_root.actPottedRed >= _root.lvl.needPottedRed) && (_root.actPottedColor >= _root.lvl.needPottedColor)) && (_root.actBreak >= _root.lvl.needBreak)) && ((_root.actBreak == _root.lvl.needExact) || (_root.lvl.needExact == 0))) && ((_root.actPottedOrder == _root.lvl.needOrder) || (_root.lvl.needOrder eq ""))) {
this.timer.running = false;
return(true);
}
return(false);
};
colorSwap = function () {
if (!_root.lvl.colorSwap) {
return(undefined);
}
switch (_root.lvl.colorSwap) {
case 1 :
var i = 1;
while (i < _root.ballsAmount) {
_root.balls[i].colorSwap();
i++;
}
return;
case 2 :
var old = (-1);
var i = 0;
while (i < _root.ballsAmount) {
if (_root.balls[i].glass) {
old = i;
_root.balls[i].setGlass(0);
}
i++;
}
var closeId;
do {
closeId = random(_root.ballsAmount - 1) + 1;
} while (closeId == old);
_root.balls[closeId].setGlass(1);
return;
case 3 :
var old = (-1);
var i = 0;
while (i < 6) {
if (_root["l" + i].closed) {
_root["l" + i].hand.gotoAndPlay("open");
} else {
old = i;
}
i++;
}
var closeId;
do {
closeId = random(6);
} while (closeId == old);
_root["l" + closeId].hand.gotoAndPlay("close");
}
};
Instance of Symbol 90 MovieClip "pointer" in Frame 1
onClipEvent (load) {
Mouse.hide();
}
onClipEvent (mouseMove) {
_x = _root._xmouse;
_y = _root._ymouse;
updateAfterEvent();
}
Frame 2
snd.play("thunderCrack");
snd.playLoop("titlemusic");
stop();
Frame 5
play();
_root.user = SharedObject.getLocal("user_data");
_root.maxLevel = int(_root.user.data.maxLevel);
if (_root.version eq "nkcheat") {
_root.maxLevel = 40;
}
_root.stats = new Array(20);
_root.stats.total = {rounds:0, highscore:0, average:0};
var i = 0;
while (i < Math.max(20, _root.maxLevel)) {
_root.stats[i] = new Object();
_root.stats[i].rounds = int(_root.user.data[i + "r"]);
_root.stats[i].highscore = int(_root.user.data[i + "h"]);
_root.stats[i].average = int(_root.user.data[i + "a"]);
i++;
}
_root.stats.total.highscore = int(_root.user.data.th);
_root.stats.total.average = int(_root.user.data.ta);
_root.stats.total.rounds = int(_root.user.data.tr);
Frame 6
function setButtons() {
buttonNextPage._visible = _root.maxLevel >= ((actPage + 1) * _root.itemsPerPage);
buttonPrevPage._visible = actPage > 0;
}
actPage = int((_root.maxLevel - (_root.maxLevel % _root.itemsPerPage)) / _root.itemsPerPage);
setButtons();
buttonNextPage.b.onRelease = function () {
_root.actPage++;
var i = 0;
while (i < _root.itemsPerPage) {
_root["d" + i].update();
i++;
}
_root.setButtons();
};
buttonPrevPage.b.onRelease = function () {
_root.actPage--;
var i = 0;
while (i < _root.itemsPerPage) {
_root["d" + i].update();
i++;
}
_root.setButtons();
};
stop();
Instance of Symbol 146 MovieClip "d0" in Frame 6
//component parameters
onClipEvent (initialize) {
levelNumber = 0;
}
Instance of Symbol 146 MovieClip in Frame 6
//component parameters
onClipEvent (initialize) {
levelNumber = 1;
}
Instance of Symbol 146 MovieClip in Frame 6
//component parameters
onClipEvent (initialize) {
levelNumber = 2;
}
Instance of Symbol 146 MovieClip in Frame 6
//component parameters
onClipEvent (initialize) {
levelNumber = 3;
}
Instance of Symbol 146 MovieClip in Frame 6
//component parameters
onClipEvent (initialize) {
levelNumber = 4;
}
Frame 7
stop();
snd.stop("titlemusic");
initGame();
Symbol 25 MovieClip Frame 9
stop();
_parent._parent._parent._visible = false;
Symbol 26 MovieClip Frame 1
stop();
Symbol 26 MovieClip Frame 3
stop();
Symbol 42 MovieClip Frame 1
stop();
Symbol 43 MovieClip [ball] Frame 1
stop();
Symbol 46 MovieClip Frame 1
gotoAndStop(_root.lvl.skin);
Symbol 47 MovieClip Frame 1
stop();
Symbol 47 MovieClip Frame 4
stop();
Symbol 49 Button
on (press) {
if (_root.version ne "nkcheat") {
return(undefined);
}
if (!Key.isDown(16)) {
this.mode = "aim";
aim._x = 0;
aim._y = 0;
aim._visible = true;
aim.startDrag();
} else {
this.mode = "move";
this.startDrag();
_root.startAim();
}
}
on (release, releaseOutside) {
if (_root.version ne "nkcheat") {
return(undefined);
}
if (this.mode == "aim") {
aim.stopDrag();
this.engine.setSpeed(aim._x / 5, aim._y / 5);
aim._visible = false;
} else {
this.engine.setSpeed(0, 0);
var round = 1E-6;
this.engine.setPos(int(_root._xmouse / round) * round, int(_root._ymouse / round) * round);
this.stopDrag();
_root.startAim();
}
}
Symbol 50 MovieClip [ballSprite] Frame 1
stop();
_visible = false;
Symbol 50 MovieClip [ballSprite] Frame 2
_visible = true;
Symbol 50 MovieClip [ballSprite] Frame 5
stop();
Symbol 50 MovieClip [ballSprite] Frame 12
play();
Symbol 50 MovieClip [ballSprite] Frame 16
gotoAndStop (1);
Symbol 61 MovieClip Frame 1
stop();
Symbol 79 Button
on (release) {
gotoAndStop (4);
}
Symbol 84 Button
on (release) {
gotoAndStop (5);
}
Symbol 90 MovieClip Frame 1
stop();
Symbol 90 MovieClip Frame 53
stop();
Symbol 99 Button
on (release) {
_root.gotoAndStop("menu_nosound");
}
Symbol 113 Button
on (release) {
nextFrame();
}
Symbol 124 Button
on (release) {
prevFrame();
}
Symbol 125 MovieClip Frame 1
stop();
Symbol 143 Button
on (release) {
_root.actLvl = levelNumber + (_root.actPage * _root.itemsPerPage);
_root.gotoAndStop("game");
}
Symbol 146 MovieClip Frame 1
_name = ("d" + levelNumber);
update = function () {
var levelNumber = (this.levelNumber + (_root.actPage * _root.itemsPerPage));
levelNumberDisplay = levelNumber + 1;
var superLevel = int(levelNumber / 20);
_root.superLevel = superLevel;
levelName = _root.lvls[levelNumber % 20].level.firstChild.attributes.title + ((superLevel > 0) ? (" " + (superLevel + 1)) : "");
levelDescription = _root.lvls[levelNumber % 20].level.firstChild.attributes.desc;
levelHigh = _root.stats[levelNumber].highscore;
levelAverage = _root.stats[levelNumber].average;
levelPlays = _root.stats[levelNumber].rounds;
if (int(_root.maxLevel) >= int(levelNumber)) {
gotoAndStop (2);
} else {
gotoAndStop (3);
}
};
update();
Symbol 160 Button
on (release) {
_root.gotoAndStop("help");
}
Symbol 164 MovieClip Frame 1
stop();
Symbol 175 MovieClip Frame 1
_parent.gotoAndStop("default");
Symbol 175 MovieClip Frame 2
_parent.gotoAndPlay("hurry");
Symbol 175 MovieClip Frame 3
_parent.gotoAndPlay("hurry");
Symbol 175 MovieClip Frame 4
_parent.gotoAndPlay("hurry");
Symbol 175 MovieClip Frame 5
_parent.gotoAndPlay("hurry");
Symbol 175 MovieClip Frame 6
_parent.gotoAndPlay("hurry");
Symbol 175 MovieClip Frame 7
_parent.gotoAndPlay("hurry");
Symbol 175 MovieClip Frame 8
_parent.gotoAndPlay("hurry");
Symbol 175 MovieClip Frame 9
_parent.gotoAndPlay("hurry");
Symbol 175 MovieClip Frame 10
_parent.gotoAndPlay("hurry");
Symbol 175 MovieClip Frame 11
_parent.gotoAndPlay("hurry");
Symbol 175 MovieClip Frame 12
_root.lightning.gotoAndPlay("single");
_root.snd.play("thunderRumble");
_parent.gotoAndPlay("hurry");
Symbol 176 MovieClip Frame 1
this.onEnterFrame = function () {
gotoAndStop(_root.lvl.skin);
};
Symbol 176 MovieClip Frame 3
stop();
Symbol 178 MovieClip Frame 1
stop();
Symbol 178 MovieClip Frame 12
gotoAndStop (1);
Symbol 178 MovieClip Frame 16
gotoAndStop (1);
Symbol 181 MovieClip Frame 1
stop();
Symbol 182 MovieClip Frame 1
stop();
Symbol 182 MovieClip Frame 2
play();
Symbol 182 MovieClip Frame 9
_root.timer.init(_root.timePerLevel);
Symbol 182 MovieClip Frame 17
_root.phase++;
Symbol 185 MovieClip Frame 1
stop();
Symbol 187 MovieClip Frame 1
stop();
c.gotoAndStop(1);
flash = function (id) {
this.c.gotoAndStop(id + 1);
this.gotoAndPlay(2);
};
Symbol 190 MovieClip Frame 1
_parent.closed = 0;
stop();
Symbol 190 MovieClip Frame 6
_parent.closed = 1;
Symbol 190 MovieClip Frame 8
stop();
Symbol 190 MovieClip Frame 12
_parent.closed = 0;
Symbol 190 MovieClip Frame 15
stop();
Symbol 192 MovieClip Frame 1
stop();
closed = 0;
Symbol 192 MovieClip Frame 2
closed = 1;
Symbol 192 MovieClip Frame 3
stop();
Symbol 203 MovieClip Frame 1
stop();
Symbol 213 MovieClip Frame 1
tubeX0 = 0;
tubeX1 = 354;
tubeWidth = tubeX1 - tubeX0;
capacity = 14;
nextIn = 0;
var i = 0;
while (i < capacity) {
var ball = this.container.attachMovie("ball", "b" + i, 100 + i);
ball._x = tube.X1;
ball._y = 0;
ball.gotoAndStop(1);
i++;
}
this.init = function () {
var ball;
var i = 0;
while (i < this.capacity) {
ball = this.container["b" + i];
ball._x = tubeX1;
i++;
}
};
this.empty = function () {
this.emptyFlag = 1;
this.nextIn = 0;
};
this.onEnterFrame = function () {
var ball;
if (this.emptyFlag) {
var i = 0;
while (i < this.capacity) {
ball = this.container["b" + i];
ball._x = Math.min(ball._x + (3 * _global.dt), this.tubeX1);
if ((i == 0) && (ball._x == this.tubeX1)) {
this.emptyFlag = 0;
}
i++;
}
return(undefined);
}
var i = 0;
while (i < this.nextIn) {
ball = this.container["b" + i];
if (!ball.active) {
} else if (ball.delay > 0) {
ball.delay = ball.delay - _global.dt;
} else {
var tx = (ball._x - (ball.vx * _global.dt));
if (i == 0) {
if (tx < tubeX0) {
tx = tubeX0;
ball.vx = Math.abs(ball.vx) * -0.2;
if (Math.abs(ball.vx) < 0.03) {
ball.active = 0;
}
}
} else if ((tx - _root.ballSize) < this.container["b" + (i - 1)]._x) {
tx = Math.min(_root.ballSize + this.container["b" + (i - 1)]._x, tubeX1);
ball.vx = Math.abs(ball.vx) * -0.2;
if ((Math.abs(ball.vx) < 0.03) && (ball._x != this.tubeX1)) {
ball.active = 0;
}
}
ball._x = tx;
ball.vx = ball.vx + ball.ax;
}
i++;
}
};
this.addBall = function (id) {
if (this.nextIn >= this.capacity) {
return(undefined);
}
_root.snd.playEvent("tube");
var ball = this.container["b" + nextIn];
ball.gotoAndStop(id + 1);
ball.active = 1;
ball.vx = 3;
ball.ax = 0.04;
ball.delay = 30;
this.nextIn++;
};
this.init();
Symbol 247 Button
on (release) {
_root.submitScore();
}
Symbol 253 Button
on (release) {
_root.cleanup();
_root.gotoAndStop("chooselevel");
}
Symbol 256 MovieClip Frame 1
if (_root.totalScore >= _root.scoreThreshold) {
stop();
}
Symbol 256 MovieClip Frame 2
stop();
Symbol 259 MovieClip Frame 1
stop();
Symbol 259 MovieClip Frame 2
display = "Level " + (_root.actLvl + 1);
Symbol 259 MovieClip Frame 124
_root.phase++;
Symbol 259 MovieClip Frame 126
stop();
Symbol 259 MovieClip Frame 127
display = "3";
play();
Symbol 259 MovieClip Frame 141
stop();
Symbol 259 MovieClip Frame 144
display = "2";
play();
Symbol 259 MovieClip Frame 158
stop();
Symbol 259 MovieClip Frame 160
display = "1";
play();
Symbol 259 MovieClip Frame 174
stop();
Symbol 259 MovieClip Frame 176
display = "GO";
play();
Symbol 259 MovieClip Frame 190
play();
Symbol 259 MovieClip Frame 202
stop();
Symbol 259 MovieClip Frame 228
display = "Game Over";
Symbol 259 MovieClip Frame 342
display = "Final Score: " + _root.totalScore;
Symbol 259 MovieClip Frame 431
_root.pointer.gotoAndStop("ready");
Symbol 259 MovieClip Frame 435
stop();
Symbol 259 MovieClip Frame 454
display = "! FOUL !";
_root.bg.time.gotoAndPlay("hit");
Symbol 259 MovieClip Frame 524
gotoAndStop (190);
Symbol 259 MovieClip Frame 528
display = "! EXCELLENT !";
Symbol 259 MovieClip Frame 601
gotoAndStop (190);
Symbol 259 MovieClip Frame 605
display = "Time Up";
play();
Symbol 259 MovieClip Frame 617
_root.snd.play("thunderCrack");
_root.lightning.gotoAndPlay("double");
Symbol 259 MovieClip Frame 681
stop();
Symbol 259 MovieClip Frame 684
display = "Level Completed";
play();
Symbol 259 MovieClip Frame 757
_root.snd.play("thunderCrack");
Symbol 259 MovieClip Frame 763
_root.lightning.gotoAndPlay("double");
display = (("Bonus = " + _root.levelsPlayed) + " x Time = ") + _root.actTimeBonus;
play();
Symbol 259 MovieClip Frame 885
stop();
Symbol 268 Button
on (release) {
_root.snd.global.setVolume(0);
nextFrame();
}
Symbol 272 Button
on (release) {
_root.snd.global.setVolume(100);
prevFrame();
}
Symbol 273 MovieClip Frame 1
stop();
Symbol 277 Button
on (release) {
gotoAndStop (2);
}
Symbol 283 Button
on (release) {
prevFrame();
}
Symbol 287 Button
on (release) {
_root.cleanup();
_root.gotoAndStop("menu");
}
Symbol 288 MovieClip Frame 1
stop();
Symbol 292 Button
on (release) {
_root.pause.gotoAndStop(2);
_root.paused = true;
nextFrame();
}
Symbol 296 Button
on (release) {
_root.pause.gotoAndStop(1);
_root.paused = false;
prevFrame();
}
Symbol 297 MovieClip Frame 1
stop();
Symbol 301 MovieClip Frame 1
stop();
Symbol 301 MovieClip Frame 5
gotoAndStop (1);
Symbol 304 MovieClip Frame 1
stop();