Frame 1
stop();
Instance of Symbol 16 MovieClip in Frame 1
onClipEvent (load) {
_xscale = 0;
}
onClipEvent (enterFrame) {
_xscale = ((_root.getBytesLoaded() / _root.getBytesTotal()) * 100);
_parent.loadedText = Math.floor(_root.getBytesLoaded() / 1024) + "K";
_parent.totalText = Math.floor(_root.getBytesTotal() / 1024) + "K";
if (_xscale >= 100) {
_root._visible = 1;
_parent.play();
}
}
Frame 2
loadMovieNum ("sphereCageSoundtrack.swf", 2);
stageHeight = Stage.height;
stageWidth = stageHeight * 1.375;
centerX = (stageWidth * 2) / 3;
centerY = stageHeight / 2;
focalLength = stageHeight;
radius = stageHeight * 0.4;
radAdj = radius * 0.8;
planeSize = stageHeight / 20;
smoothness = 80;
colors = [];
colors.push({textCol:4495684, paintColor:[0, 1, 0], planeColor:"234523"});
colors.push({textCol:3368635, paintColor:[0, 0, 1], planeColor:"003399"});
colors.push({textCol:16737792, paintColor:[1, 0.4, 0], planeColor:"DD4400"});
currentColor = 0;
this.createEmptyMovieClip("backShadow", 1);
this.createEmptyMovieClip("targetMC", 2);
this.attachMovie("ball", "ballMC", 10);
this.createEmptyMovieClip("planeMC", 20);
this.createEmptyMovieClip("paddleMC", 30);
this.createEmptyMovieClip("sphere", 100);
this.createEmptyMovieClip("painting", 150);
this.createEmptyMovieClip("paintMask", 151);
this.createEmptyMovieClip("blip0MC", 250);
this.createEmptyMovieClip("blip1MC", 251);
this.createEmptyMovieClip("blip2MC", 252);
this.createEmptyMovieClip("missMC", 253);
this.createEmptyMovieClip("gameOverMC", 254);
this.createEmptyMovieClip("gameOpenMC", 255);
this.attachMovie("reflect", "reflect", 200);
reflect._height = (reflect._width = radius * 2);
reflect._alpha = 4;
sphere.createEmptyMovieClip("rim", 0);
sphere.createEmptyMovieClip("shadow", 1);
sphere.createEmptyMovieClip("highlight", 2);
targetMC.createEmptyMovieClip("topTarget", 0);
targetMC.createEmptyMovieClip("bottomTarget", 1);
reflect._x = (targetMC._x = (ballMC._x = (planeMC._x = (paddleMC._x = (sphere._x = (backShadow._x = centerX))))));
reflect._y = (targetMC._y = (ballMC._y = (planeMC._y = (paddleMC._y = (sphere._y = (backShadow._y = centerY))))));
blip0 = new Sound(blip0MC);
blip1 = new Sound(blip1MC);
blip2 = new Sound(blip2MC);
miss = new Sound(missMC);
blip0.attachSound("blip0");
blip1.attachSound("blip1");
blip2.attachSound("blip2");
miss.attachSound("miss");
gameOverSound = new Sound(gameOverMC);
gameOpenSound = new Sound(gameOpenMC);
gameOverSound.attachSound("gameOver");
gameOpenSound.attachSound("gameOpen");
this.lineStyle(10, 2236962, 100);
this.beginFill(0, 100);
this.lineTo(stageWidth / 3, 0);
this.lineTo(stageWidth / 3, stageHeight);
this.lineTo(0, stageHeight);
this.lineTo(0, 0);
this.endFill();
this.lineTo(stageWidth, 0);
this.lineTo(stageWidth, stageHeight);
this.lineTo(0, stageHeight);
this.lineStyle(2, 15658734, 60);
this.moveTo(0, 0);
this.lineTo(stageWidth / 3, 0);
this.lineTo(stageWidth / 3, stageHeight);
this.lineTo(0, stageHeight);
this.lineTo(0, 0);
this.lineTo(stageWidth, 0);
this.lineTo(stageWidth, stageHeight);
this.lineTo(0, stageHeight);
paintMask.beginFill(0, 100);
paintMask.moveTo(3, 3);
paintMask.lineTo((stageWidth / 3) - 3, 3);
paintMask.lineTo((stageWidth / 3) - 3, stageHeight - 3);
paintMask.lineTo(3, stageHeight - 3);
paintMask.endFill();
painting.setMask(paintMask);
textHeight = stageHeight / 20;
statsTitle = new TextFormat();
statsTitle.color = colors[currentColor].textCol;
statsTitle.font = "statsTitleFont";
statsTitle.size = stageHeight * 0.04;
statsTitle.underline = 1;
stats = new TextFormat();
stats.color = 16777215 /* 0xFFFFFF */;
stats.font = "statsFont";
stats.size = stageHeight * 0.05;
stats.bold = 1;
this.createTextField("livesTitleTF", 501, stageWidth / 40, textHeight, 0, 0);
this.createTextField("highTitleTF", 502, stageWidth / 40, textHeight * 4, 0, 0);
this.createTextField("scoreTitleTF", 503, stageWidth / 40, textHeight * 7, 0, 0);
this.createTextField("highTF", 504, stageWidth / 40, textHeight * 5, 0, 0);
this.createTextField("scoreTF", 505, stageWidth / 40, textHeight * 8, 0, 0);
livesTitleTF.setNewTextFormat(statsTitle);
highTitleTF.setNewTextFormat(statsTitle);
scoreTitleTF.setNewTextFormat(statsTitle);
highTF.setNewTextFormat(stats);
scoreTF.setNewTextFormat(stats);
highTitleTF.embedFonts = (scoreTitleTF.embedFonts = (livesTitleTF.embedFonts = 1));
highTF.embedFonts = (scoreTF.embedFonts = 1);
highTitleTF.autoSize = (scoreTitleTF.autoSize = (livesTitleTF.autoSize = "left"));
highTF.autoSize = (scoreTF.autoSize = "left");
livesTitleTF.text = "LIVES";
highTitleTF.text = "HIGH SCORE";
scoreTitleTF.text = "SCORE";
highTF.text = "00000000";
highTitleTF.selectable = 0;
scoreTitleTF.selectable = 0;
livesTitleTF.selectable = 0;
highTF.selectable = 0;
scoreTF.selectable = 0;
imagescoreCredit.swapDepths(555);
imagescoreCredit.music.textColor = colors[currentColor].textCol;
LightSource = function (x, y, z, brightness) {
var _local1 = this;
_local1.x = x;
_local1.y = y;
_local1.z = z;
_local1.brightness = brightness;
_local1.calcMag = function () {
var _local1 = this;
_local1.magnitude = Math.sqrt(((_local1.x * _local1.x) + (_local1.y * _local1.y)) + (_local1.z * _local1.z));
};
_local1.calcMag();
};
Model = function () {
};
Model.prototype.applyTransform = function () {
var _local2 = this;
if (_local2.transformMatrix) {
var _local3 = 0;
while (_local3 < _local2.vertexList.length) {
var _local1 = _local2.vertexList[_local3];
var x = ((((_local2.transformMatrix.a * _local1.x) + (_local2.transformMatrix.b * _local1.y)) + (_local2.transformMatrix.c * _local1.z)) + (_local2.transformMatrix.d * _local1.w));
var y = ((((_local2.transformMatrix.e * _local1.x) + (_local2.transformMatrix.f * _local1.y)) + (_local2.transformMatrix.g * _local1.z)) + (_local2.transformMatrix.h * _local1.w));
var z = ((((_local2.transformMatrix.i * _local1.x) + (_local2.transformMatrix.j * _local1.y)) + (_local2.transformMatrix.k * _local1.z)) + (_local2.transformMatrix.l * _local1.w));
_local1.x = x;
_local1.y = y;
_local1.z = z;
_local3++;
}
delete _local2.transformMatrix;
}
};
Model.prototype.getSideColor = function (side) {
var _local1 = side;
var _local3 = this;
var verts = [_local3.vertexList[_local1.vertices[0]], _local3.vertexList[_local1.vertices[1]], _local3.vertexList[_local1.vertices[2]]];
var _local2 = _local3.factorLightAngle(verts);
var r = (parseInt(_local1.sideColor.substr(0, 2), 16) * _local2);
var g = (parseInt(_local1.sideColor.substr(2, 2), 16) * _local2);
var b = (parseInt(_local1.sideColor.substr(4, 2), 16) * _local2);
return(((r << 16) | (g << 8)) | b);
};
Model.prototype.factorLightAngle = function (vertices) {
var _local1 = vertices;
var U = [_local1[0].x - _local1[1].x, _local1[0].y - _local1[1].y, _local1[0].z - _local1[1].z];
var _local3 = [_local1[1].x - _local1[2].x, _local1[1].y - _local1[2].y, _local1[1].z - _local1[2].z];
var _local2 = [(U[1] * _local3[2]) - (U[2] * _local3[1]), -((U[0] * _local3[2]) - (U[2] * _local3[0])), (U[0] * _local3[1]) - (U[1] * _local3[0])];
var magP = Math.sqrt(((_local2[0] * _local2[0]) + (_local2[1] * _local2[1])) + (_local2[2] * _local2[2]));
var dP = (((_local2[0] * light.x) + (_local2[1] * light.y)) + (_local2[2] * light.z));
if (dP > 0) {
dP = dP * -1;
}
return(((Math.acos(dP / (magP * light.magnitude)) / Math.PI) * light.brightness) / 100);
};
Model.prototype.rotateX = function (degree) {
var _local2 = (degree * Math.PI) / 180;
var _local1 = Math.sin(_local2);
var _local3 = Math.cos(_local2);
var matrix = {a:1, b:0, c:0, d:0, e:0, f:_local3, g:_local1, h:0, i:0, j:-_local1, k:_local3, l:0, m:0, n:0, o:0, p:1};
this.transform(matrix);
};
Model.prototype.rotateY = function (degree) {
var _local2 = (degree * Math.PI) / 180;
var _local1 = Math.sin(_local2);
var _local3 = Math.cos(_local2);
var matrix = {a:_local3, b:0, c:-_local1, d:0, e:0, f:1, g:0, h:0, i:_local1, j:0, k:_local3, l:0, m:0, n:0, o:0, p:1};
this.transform(matrix);
};
Model.prototype.rotateZ = function (degree) {
var _local2 = (degree * Math.PI) / 180;
var _local1 = Math.sin(_local2);
var _local3 = Math.cos(_local2);
var matrix = {a:_local3, b:_local1, c:0, d:0, e:-_local1, f:_local3, g:0, h:0, i:0, j:0, k:1, l:0, m:0, n:0, o:0, p:1};
this.transform(matrix);
};
Model.prototype.translate = function (x, y, z) {
var _local1 = {a:1, b:0, c:0, d:x, e:0, f:1, g:0, h:y, i:0, j:0, k:1, l:z, m:0, n:0, o:0, p:1};
this.transform(_local1);
};
Model.prototype.transform = function (matrix) {
var _local1 = this;
var _local2 = matrix;
if (_local1.transformMatrix) {
var a = ((((_local2.a * _local1.transformMatrix.a) + (_local2.b * _local1.transformMatrix.e)) + (_local2.c * _local1.transformMatrix.i)) + (_local2.d * _local1.transformMatrix.m));
var b = ((((_local2.a * _local1.transformMatrix.b) + (_local2.b * _local1.transformMatrix.f)) + (_local2.c * _local1.transformMatrix.j)) + (_local2.d * _local1.transformMatrix.n));
var c = ((((_local2.a * _local1.transformMatrix.c) + (_local2.b * _local1.transformMatrix.g)) + (_local2.c * _local1.transformMatrix.k)) + (_local2.d * _local1.transformMatrix.o));
var d = ((((_local2.a * _local1.transformMatrix.d) + (_local2.b * _local1.transformMatrix.h)) + (_local2.c * _local1.transformMatrix.l)) + (_local2.d * _local1.transformMatrix.p));
var e = ((((_local2.e * _local1.transformMatrix.a) + (_local2.f * _local1.transformMatrix.e)) + (_local2.g * _local1.transformMatrix.i)) + (_local2.h * _local1.transformMatrix.m));
var f = ((((_local2.e * _local1.transformMatrix.b) + (_local2.f * _local1.transformMatrix.f)) + (_local2.g * _local1.transformMatrix.j)) + (_local2.h * _local1.transformMatrix.n));
var g = ((((_local2.e * _local1.transformMatrix.c) + (_local2.f * _local1.transformMatrix.g)) + (_local2.g * _local1.transformMatrix.k)) + (_local2.h * _local1.transformMatrix.o));
var h = ((((_local2.e * _local1.transformMatrix.d) + (_local2.f * _local1.transformMatrix.h)) + (_local2.g * _local1.transformMatrix.l)) + (_local2.h * _local1.transformMatrix.p));
var i = ((((_local2.i * _local1.transformMatrix.a) + (_local2.j * _local1.transformMatrix.e)) + (_local2.k * _local1.transformMatrix.i)) + (_local2.l * _local1.transformMatrix.m));
var j = ((((_local2.i * _local1.transformMatrix.b) + (_local2.j * _local1.transformMatrix.f)) + (_local2.k * _local1.transformMatrix.j)) + (_local2.l * _local1.transformMatrix.n));
var k = ((((_local2.i * _local1.transformMatrix.c) + (_local2.j * _local1.transformMatrix.g)) + (_local2.k * _local1.transformMatrix.k)) + (_local2.l * _local1.transformMatrix.o));
var l = ((((_local2.i * _local1.transformMatrix.d) + (_local2.j * _local1.transformMatrix.h)) + (_local2.k * _local1.transformMatrix.l)) + (_local2.l * _local1.transformMatrix.p));
_local1.transformMatrix = {a:a, b:b, c:c, d:d, e:e, f:f, g:g, h:h, i:i, j:j, k:k, l:l, m:0, n:0, o:0, p:1};
} else {
_local1.transformMatrix = _local2;
}
};
Model.prototype.render = function () {
var _local2 = this;
_local2.applyTransform();
var _local1 = 0;
while (_local1 < _local2.vertexList.length) {
var _local3 = focalLength / (focalLength - _local2.vertexList[_local1].z);
_local2.clip[_local1]._xscale = (_local2.clip[_local1]._yscale = ((_local3 / 4) * _local2.vertexList[_local1].z) + 50);
_local2.clip[_local1]._x = _local2.vertexList[_local1].x * _local3;
_local2.clip[_local1]._y = _local2.vertexList[_local1].y * _local3;
_local1++;
}
};
BallModel = function () {
};
BallModel.prototype = new Model();
BallModel.prototype.move = function () {
var x = (this.direction.x * this.rate);
var y = (this.direction.y * this.rate);
var z = (this.direction.z * this.rate);
this.translate(x, y, z);
with (this.vertexList[0]) {
var mag = this.getMagnitude();
if ((mag + this.rad) > radAdj) {
if (this.checkPaddle() && (!ok2Hit)) {
playBlip(this.rate);
ok2Hit = 1;
updateScore();
this.rate = (((this.rate + 0.1) < 6) ? (this.rate + 0.1) : 6);
this.direction = {x:(-x) / mag, y:(-y) / mag, z:(-z) / mag};
} else if (!ok2Hit) {
miss.start();
killBall();
}
} else if (((mag - this.rad) < 10) && (ok2Hit)) {
delete ok2Hit;
playBlip(this.rate);
this.checkAngle();
this.startLoc = {x:x, y:y, z:z};
}
}
};
BallModel.prototype.getMagnitude = function () {
with (this.vertexList[0]) {
return(Math.sqrt(((x * x) + (y * y)) + (z * z)));
}
};
BallModel.prototype.setDirection = function (x, y, z) {
var _local2 = Math.sqrt(((x * x) + (y * y)) + (z * z));
var _local3 = [x / _local2, y / _local2, z / _local2];
var _local1 = [(_local3[0] * radAdj) - this.vertexList[0].x, (_local3[1] * radAdj) - this.vertexList[0].y, (_local3[2] * radAdj) - this.vertexList[0].z];
_local2 = Math.sqrt(((_local1[0] * _local1[0]) + (_local1[1] * _local1[1])) + (_local1[2] * _local1[2]));
this.direction = {x:_local1[0] / _local2, y:_local1[1] / _local2, z:_local1[2] / _local2};
};
BallModel.prototype.checkPaddle = function () {
var x;
var _local3;
var _local2;
var _local1 = 0;
while (_local1 < 4) {
x = x + paddle.vertexList[_local1].x;
_local3 = _local3 + paddle.vertexList[_local1].y;
_local2 = _local2 + paddle.vertexList[_local1].z;
_local1++;
}
x = x / 4;
_local3 = _local3 / 4;
_local2 = _local2 / 4;
x = x - ball.vertexList[0].x;
_local3 = _local3 - ball.vertexList[0].y;
_local2 = _local2 - ball.vertexList[0].z;
var dist = Math.sqrt(((x * x) + (_local3 * _local3)) + (_local2 * _local2));
if (dist < (planeSize + ball.rad)) {
return(true);
}
return(false);
};
BallModel.prototype.checkAngle = function () {
var _local2 = [plane.vertexList[0], plane.vertexList[1], plane.vertexList[2]];
var U = [_local2[0].x - _local2[1].x, _local2[0].y - _local2[1].y, _local2[0].z - _local2[1].z];
var V = [_local2[1].x - _local2[2].x, _local2[1].y - _local2[2].y, _local2[1].z - _local2[2].z];
var _local1 = [(U[1] * V[2]) - (U[2] * V[1]), -((U[0] * V[2]) - (U[2] * V[0])), (U[0] * V[1]) - (U[1] * V[0])];
var magP = Math.sqrt(((_local1[0] * _local1[0]) + (_local1[1] * _local1[1])) + (_local1[2] * _local1[2]));
_local1 = [_local1[0] / magP, _local1[1] / magP, _local1[2] / magP];
var _local3 = [-this.direction.x, -this.direction.y, -this.direction.z];
var dP = (((_local1[0] * _local3[0]) + (_local1[1] * _local3[1])) + (_local1[2] * _local3[2]));
var dPxN = [_local1[0] * dP, _local1[1] * dP, _local1[2] * dP];
_local3 = [(dPxN[0] + dPxN[0]) - _local3[0], (dPxN[1] + dPxN[1]) - _local3[1], (dPxN[2] + dPxN[2]) - _local3[2]];
this.setDirection(_local3[0], _local3[1], _local3[2]);
var incidence = Math.acos(dp);
if (incidence > Math.PI) {
incidence = Math.PI - incidence;
}
var theta = (Math.PI - (incidence * 2));
var mag = this.getMagnitude();
var sinTheta = Math.sin(theta);
var angle = Math.asin((mag * sinTheta) / radAdj);
angle = (Math.PI - angle) - theta;
var distance = ((Math.sin(angle) * radAdj) / sinTheta);
setTarget(distance);
};
BallModel.prototype.rotateDirection = function (axis, degree) {
var _local1 = this;
var _local2 = Math.sin((degree * Math.PI) / 180);
var _local3 = Math.cos((degree * Math.PI) / 180);
if (axis == "y") {
var x = ((_local3 * _local1.direction.x) - (_local2 * _local1.direction.z));
_local1.direction.z = (_local3 * _local1.direction.z) + (_local2 * _local1.direction.x);
_local1.direction.x = x;
} else {
var z = ((_local3 * _local1.direction.z) - (_local2 * _local1.direction.y));
_local1.direction.y = (_local3 * _local1.direction.y) + (_local2 * _local1.direction.z);
_local1.direction.z = z;
}
};
BallModel.prototype.reset = function () {
var _local1 = this;
flash();
_local1.clip[0]._visible = 1;
_local1.rate = 0;
_local1.vertexList[0] = {x:0, y:0, z:0, w:1};
_local1.clip[0]._parent._xscale = (_local1.clip[0]._parent._yscale = 0);
_local1.setDirection(Math.random() - 1, Math.random() - 0.5, Math.random());
setTarget(radAdj);
_local1.clip[0]._parent.onEnterFrame = function () {
var _local1 = this;
_local1._xscale = (_local1._yscale = _local1._yscale + ((100 - _local1._xscale) / 5));
ball.render();
if (_local1._xscale > 90) {
delete _local1.onEnterFrame;
ball.rate = 1.5;
target.clip[0]._visible = 1;
target.clip[1]._visible = 1;
}
};
};
PlaneModel = function () {
};
PlaneModel.prototype = new Model();
PlaneModel.prototype.render = function () {
super.applyTransform();
this.clip.clear();
this.clip.lineStyle(1, 0, 100);
var _local2 = [];
this.zDepth = 0;
var _local1 = 0;
while (_local1 < this.vertexList.length) {
var _local3 = this.vertexList[_local1];
_local2[_local1] = {};
var scale = (focalLength / (focalLength - _local3.z));
_local2[_local1].x = _local3.x * scale;
_local2[_local1].y = _local3.y * scale;
this.zDepth = this.zDepth + _local3.z;
_local1++;
}
this.clip.moveTo(_local2[0].x, _local2[0].y);
this.clip.beginFill(this.getSideColor(this.side[0]), this.side[0].fillAlpha);
var j = 1;
while (j < _local2.length) {
this.clip.lineTo(_local2[j].x, _local2[j].y);
j++;
}
this.clip.lineTo(_local2[0].x, _local2[0].y);
this.clip.endFill();
};
PopUp = function (w, h) {
var _local1 = this;
var _local2 = h;
_local1.vertexList = [];
_local1.vertexList.push({x:-w, y:-_local2, z:20, w:1});
_local1.vertexList.push({x:-w, y:_local2, z:20, w:1});
_local1.vertexList.push({x:w, y:_local2, z:20, w:1});
_local1.vertexList.push({x:w, y:-_local2, z:20, w:1});
_local1.vertexList.push({x:(-w) - 15, y:(-_local2) - 15, z:0, w:1});
_local1.vertexList.push({x:(-w) - 15, y:_local2 + 15, z:0, w:1});
_local1.vertexList.push({x:w + 15, y:_local2 + 15, z:0, w:1});
_local1.vertexList.push({x:w + 15, y:(-_local2) - 15, z:0, w:1});
_local1.vertexList.push({x:(-w) + 5, y:(-_local2) + 5, z:15, w:1});
_local1.vertexList.push({x:(-w) + 5, y:_local2 - 5, z:15, w:1});
_local1.vertexList.push({x:w - 5, y:_local2 - 5, z:15, w:1});
_local1.vertexList.push({x:w - 5, y:(-_local2) + 5, z:15, w:1});
_local1.side = [];
_local1.side.push({vertices:[0, 1, 2, 3], sideColor:"666666"});
_local1.side.push({vertices:[0, 4, 5, 1], sideColor:"888888"});
_local1.side.push({vertices:[0, 3, 7, 4], sideColor:"888888"});
_local1.side.push({vertices:[7, 3, 2, 6], sideColor:"333333"});
_local1.side.push({vertices:[1, 5, 6, 2], sideColor:"333333"});
_local1.side.push({vertices:[8, 9, 10, 11], sideColor:"666666"});
_local1.side.push({vertices:[0, 8, 9, 1], sideColor:"444444"});
_local1.side.push({vertices:[3, 2, 10, 11], sideColor:"777777"});
_local1.side.push({vertices:[9, 10, 2, 1], sideColor:"777777"});
_local1.side.push({vertices:[0, 3, 11, 8], sideColor:"444444"});
};
PopUp.prototype = new Model();
PopUp.prototype.render = function () {
var _local1 = this;
_local1.clip.clear();
var verts2D = [];
var _local2 = 0;
while (_local2 < _local1.vertexList.length) {
var whichVert = _local1.vertexList[_local2];
verts2D[_local2] = {};
var scale = (focalLength / (focalLength - whichVert.z));
verts2D[_local2].x = whichVert.x * scale;
verts2D[_local2].y = whichVert.y * scale;
_local2++;
}
_local2 = 0;
while (_local2 < _local1.side.length) {
_local1.clip.moveTo(verts2D[_local1.side[_local2].vertices[0]].x, verts2D[_local1.side[_local2].vertices[0]].y);
_local1.clip.beginFill(_local1.getSideColor(_local1.side[_local2]), 100);
var _local3 = 1;
while (_local3 < _local1.side[_local2].vertices.length) {
_local1.clip.lineTo(verts2D[_local1.side[_local2].vertices[_local3]].x, verts2D[_local1.side[_local2].vertices[_local3]].y);
_local3++;
}
_local1.clip.lineTo(verts2D[_local1.side[_local2].vertices[0]].x, verts2D[_local1.side[_local2].vertices[0]].y);
_local1.clip.endFill();
_local2++;
}
};
Object.prototype.duplicate = function () {
var _local1 = this;
var _local2 = {};
for (var _local3 in _local1) {
_local2[_local3] = _local1[_local3];
}
return(_local2);
};
initGame = function () {
var _local1 = this;
Mouse.hide();
paint();
scoreTF.text = "00000000";
lives = 4;
_local1.attachMovie("ball", "ball1", 160);
_local1.attachMovie("ball", "ball2", 161);
_local1.attachMovie("ball", "ball3", 162);
ball1._xscale = (ball1._yscale = (ball2._xscale = (ball2._yscale = (ball3._xscale = (ball3._yscale = stageHeight / 8)))));
ball1._y = (ball2._y = (ball3._y = stageHeight / 7));
ball1._x = (stageWidth / 40) + (ball1._width / 2);
ball2._x = ((stageWidth / 40) * 3) + (ball2._width / 2);
ball3._x = ((stageWidth / 40) * 5) + (ball3._width / 2);
paddle.render();
plane.render();
ball.clip[0]._visible = 0;
gameOverSound.stop();
gameOpenSound.start();
paddleMC.onEnterFrame = function () {
paddle.rotateY((gameOpenSound.duration - gameOpenSound.position) / 100);
plane.rotateX(((gameOpenSound.duration - gameOpenSound.position) / 100) + 2);
plane.rotateY(((gameOpenSound.duration - gameOpenSound.position) / 200) + 1);
plane.rotateZ((gameOpenSound.duration - gameOpenSound.position) / 100);
paddle.render();
plane.render();
sortDepths();
};
gameOpenSound.onSoundComplete = function () {
paddleMC.onEnterFrame = frameCode;
ball.reset();
miss.start();
_level2.soundtrack.start(0, 999);
};
};
paint = function () {
i = 0;
while (i < 25) {
painting.createEmptyMovieClip("p" + i, i);
var _local2 = painting["p" + i];
_local2._x = Math.random() * ((stageWidth / 3) - 0);
_local2._y = (Math.random() * (stageHeight - (stageHeight / 4))) + (stageHeight / 4);
var _local1 = (Math.random() * 50) + 100;
var _local3 = Math.ceil(Math.random() * 100);
var r = ((_local3 * colors[currentColor].paintColor[0]) << 16);
var g = ((_local3 * colors[currentColor].paintColor[1]) << 8);
var b = (_local3 * colors[currentColor].paintColor[2]);
_local3 = (r || (g)) || (b);
var paintColors = [_local3, _local3];
var alphas = [50, 0];
var ratios = [0, 200];
var matrix = {matrixType:"box", x:(-_local1) / 2, y:(-_local1) / 2, w:_local1, h:_local1, r:0};
_local2.beginGradientFill("radial", paintColors, alphas, ratios, matrix);
_local2.moveTo((-_local1) / 2, (-_local1) / 2);
_local2.lineTo(_local1 / 2, (-_local1) / 2);
_local2.lineTo(_local1 / 2, _local1 / 2);
_local2.lineTo((-_local1) / 2, _local1 / 2);
_local2.endFill();
i++;
}
};
drawSphereAssets = function (mc, params, center, smoothness) {
var ang = (360 / smoothness);
var _local3 = Math.sin(ang * (Math.PI/180)) * radius;
var _local2 = Math.cos(ang * (Math.PI/180)) * radius;
mc.moveTo(_local3, _local2);
var matrix = {a:params.hotspot, b:0, c:0, d:0, e:params.hotspot, f:0, g:center.x, h:center.y, i:0};
mc.beginGradientFill("radial", params.colors, params.alphas, params.ratios, matrix);
var _local1 = 1;
while (_local1 <= smoothness) {
_local3 = Math.sin(((ang * _local1) * Math.PI) / 180) * radius;
_local2 = Math.cos(((ang * _local1) * Math.PI) / 180) * radius;
mc.lineTo(_local3, _local2);
_local1++;
}
mc.endFill();
};
setTarget = function (distance) {
var _local2 = distance;
target.vertexList[0].x = (ball.direction.x * _local2) + ball.vertexList[0].x;
target.vertexList[0].y = (ball.direction.y * _local2) + ball.vertexList[0].y;
target.vertexList[0].z = (ball.direction.z * _local2) + ball.vertexList[0].z;
var _local1 = _local2 + (radius - radAdj);
target.vertexList[1].x = (ball.direction.x * _local1) + ball.vertexList[0].x;
target.vertexList[1].y = (ball.direction.y * _local1) + ball.vertexList[0].y;
target.vertexList[1].z = (ball.direction.z * _local1) + ball.vertexList[0].z;
drawTarget();
};
drawTarget = function () {
var _local1 = 0;
while (_local1 < target.clip.length) {
target.clip[_local1].clear();
if (target.vertexList[_local1].z > 0) {
targetMC.swapDepths(99);
var _local2 = 16777215 /* 0xFFFFFF */;
} else {
targetMC.swapDepths(2);
var _local2 = colors[currentColor].textCol;
}
target.clip[_local1].lineStyle(1, _local2, 100);
target.clip[_local1].moveTo((-planeSize) / 8, (-planeSize) / 8);
target.clip[_local1].lineTo(planeSize / 8, planeSize / 8);
target.clip[_local1].moveTo(planeSize / 8, (-planeSize) / 8);
target.clip[_local1].lineTo((-planeSize) / 8, planeSize / 8);
_local1++;
}
target.render();
};
sortDepths = function () {
if (ball.vertexList[0].z > -1) {
ballMC.swapDepths(25);
} else {
ballMC.swapDepths(15);
}
if (paddle.zDepth > 0) {
paddle.clip.swapDepths(30);
} else {
paddle.clip.swapDepths(10);
}
};
spinWorld = function (axis, rate) {
var _local1 = rate;
paddle.render();
plane.render();
ball.render();
if (axis == "y") {
paddle.rotateY(_local1);
} else {
paddle.rotateX(_local1);
}
plane.transformMatrix = paddle.transformMatrix.duplicate();
target.transformMatrix = paddle.transformMatrix.duplicate();
ball.transformMatrix = paddle.transformMatrix.duplicate();
ball.rotateDirection(axis, _local1);
drawTarget();
};
killBall = function () {
lives--;
this["ball" + lives].removeMovieClip();
if (lives == 0) {
delete paddleMC.onEnterFrame;
ball.clip[0]._visible = 0;
target.clip[0]._visible = 0;
target.clip[1]._visible = 0;
gameOverPopUp();
Mouse.show();
} else {
ball.reset();
}
};
updateScore = function () {
var _local1 = parseInt(scoreTF.text, 10);
_local1 = _local1 + Math.floor(ball.rate * 20);
_local1 = _local1 + "";
while (_local1.length < 8) {
_local1 = "0" + _local1;
}
scoreTF.text = _local1;
};
frameCode = function () {
if (Key.isDown(65)) {
spinWorld("y", -paddle.rate);
} else if (Key.isDown(68)) {
spinWorld("y", paddle.rate);
}
if (Key.isDown(83)) {
spinWorld("x", -paddle.rate);
} else if (Key.isDown(87)) {
spinWorld("x", paddle.rate);
}
ball.move();
plane.rotateX(2);
plane.rotateY(1);
plane.rotateZ(0.5);
if (Key.isDown(39)) {
paddle.rotateY(-paddle.rate);
} else if (Key.isDown(37)) {
paddle.rotateY(paddle.rate);
}
if (Key.isDown(38)) {
paddle.rotateX(-paddle.rate);
} else if (Key.isDown(40)) {
paddle.rotateX(paddle.rate);
}
plane.render();
paddle.render();
if (ball.rate) {
ball.render();
}
sortDepths();
};
gameOverPopup = function () {
var _local1 = this;
_local1.createEmptyMovieClip("dim", 200000);
dim.beginFill(6645093, 80);
dim.lineTo(stageWidth, 0);
dim.lineTo(stageWidth, stageHeight);
dim.lineTo(0, stageHeight);
dim.endFill();
var popUpWidth = (stageWidth / 4);
var _local2 = stageHeight / 4;
_local1.createEmptyMovieClip("gm", 200001);
gm._x = stageWidth / 2;
gm._y = stageHeight / 2;
gameOver = new popUp(popUpWidth, _local2);
gameOver.clip = gm;
gameOver.render();
gm.createTextField("title", 0, 0, (-_local2) * 0.9, 0, 0);
statsTitle.size = stageHeight / 10;
gm.title.setNewTextFormat(statsTitle);
gm.title.embedFonts = 1;
gm.title.autoSize = "center";
gm.title.text = "Game Over";
gm.title.selectable = 0;
statsTitle.size = stageHeight * 0.04;
gm.createTextField("message", 1, 0, (-_local2) * 0.2, 0, 0);
gm.message.setNewTextFormat(stats);
gm.message.embedFonts = 1;
gm.message.selectable = 0;
gm.message.autoSize = "center";
gm.createTextField("score", 2, 0, _local2 * 0.1, 0, 0);
gm.score.setNewTextFormat(stats);
gm.score.embedFonts = 1;
gm.score.autoSize = "center";
gm.score.selectable = 0;
var _local3 = parseInt(scoreTF.text, 10);
gm.score.text = _local3;
if (_local3 > parseInt(highTF.text, 10)) {
gm.message.text = "You made high score!";
highTF.text = scoreTF.text;
} else {
gm.message.text = "You scored:";
}
gm.createTextField("replay", 3, 0, _local2 * 0.5, 0, 0);
gm.replay.setNewTextFormat(stats);
gm.replay.embedFonts = 1;
gm.replay.textColor = 8421504 /* 0x808080 */;
gm.replay.autoSize = "center";
gm.replay.text = "click to play again";
gm.replay.selectable = 0;
gm.col = 80;
gm.direction = 1;
gm.onEnterFrame = function () {
var _local1 = this;
_local1.col = _local1.col + (5 * _local1.direction);
if ((_local1.col > 254) || (_local1.col < 80)) {
_local1.direction = _local1.direction * -1;
}
var r = (_local1.col << 16);
var g = (_local1.col << 8);
var _local3 = _local1.col;
var _local2 = (r + g) + _local3;
_local1.replay.textColor = _local2;
};
gm.onPress = function () {
dim.removeMovieClip();
reColor();
initGame();
this.removeMovieClip();
};
_level2.soundtrack.stop();
gameOverSound.start();
gameOverSound.onSoundComplete = function () {
_level2.soundtrack.start(0, 999);
};
};
startGamePopup = function () {
var _local1 = this;
_local1.createEmptyMovieClip("dim", 200000);
dim.beginFill(6645093, 80);
dim.lineTo(stageWidth, 0);
dim.lineTo(stageWidth, stageHeight);
dim.lineTo(0, stageHeight);
dim.endFill();
var _local3 = stageWidth / 4;
var _local2 = stageHeight / 4;
_local1.createEmptyMovieClip("sg", 200001);
sg._x = stageWidth / 2;
sg._y = stageHeight / 2;
startGame = new popUp(_local3, _local2);
startGame.clip = sg;
startGame.render();
sg.createTextField("title", 0, 0, -_local2, 0, 0);
statsTitle.size = stageHeight / 10;
sg.title.setNewTextFormat(statsTitle);
sg.title.embedFonts = 1;
sg.title.autoSize = "center";
sg.title.text = "SphereCage";
sg.title.selectable = 0;
statsTitle.size = stageHeight * 0.04;
sg.createTextField("message", 1, (-_local3) * 0.9, (-_local2) * 0.4, _local3 * 1.8, _local2);
stats.align = "center";
stats.size = stageHeight * 0.035;
sg.message.setNewTextFormat(stats);
sg.message.embedFonts = 1;
sg.message.wordWrap = 1;
sg.message.text = "use your arrows keys to maneuver the paddle\n\nuse the a, s, d, w keys\nto spin the sphere";
sg.message.selectable = 0;
sg.createTextField("replay", 3, 0, _local2 * 0.6, 0, 0);
stats.align = "left";
stats.size = stageHeight * 0.05;
sg.replay.setNewTextFormat(stats);
sg.replay.embedFonts = 1;
sg.replay.textColor = 8421504 /* 0x808080 */;
sg.replay.autoSize = "center";
sg.replay.text = "click to start";
sg.replay.selectable = 0;
sg.col = 80;
sg.direction = 1;
sg.onEnterFrame = function () {
var _local1 = this;
_local1.col = _local1.col + (5 * _local1.direction);
if ((_local1.col > 254) || (_local1.col < 80)) {
_local1.direction = _local1.direction * -1;
}
var r = (_local1.col << 16);
var g = (_local1.col << 8);
var _local3 = _local1.col;
var _local2 = (r + g) + _local3;
_local1.replay.textColor = _local2;
};
sg.onPress = function () {
_level2.soundtrack.stop();
stats.align = "left";
dim.removeMovieClip();
initGame();
this.removeMovieClip();
};
};
pausePopup = function () {
var _local1 = this;
_local1.createEmptyMovieClip("dim", 200000);
dim.beginFill(6645093, 80);
dim.lineTo(stageWidth, 0);
dim.lineTo(stageWidth, stageHeight);
dim.lineTo(0, stageHeight);
dim.endFill();
var _local3 = stageWidth / 3;
var _local2 = stageHeight / 8;
_local1.createEmptyMovieClip("pg", 200001);
pg._x = stageWidth / 2;
pg._y = stageHeight / 2;
pausedGame = new popUp(_local3, _local2);
pausedGame.clip = pg;
pausedGame.render();
pg.createTextField("message", 1, (-_local3) * 0.9, (-_local2) * 0.5, _local3 * 1.8, _local2);
stats.align = "center";
stats.size = stageHeight * 0.035;
pg.message.setNewTextFormat(stats);
pg.message.embedFonts = 1;
pg.message.text = "paused game";
pg.message.selectable = 0;
pg.createTextField("replay", 3, 0, _local2 * 0.1, 0, 0);
stats.align = "left";
stats.size = stageHeight * 0.05;
pg.replay.setNewTextFormat(stats);
pg.replay.embedFonts = 1;
pg.replay.textColor = 8421504 /* 0x808080 */;
pg.replay.autoSize = "center";
pg.replay.text = "hit spacebar to continue";
pg.replay.selectable = 0;
pg.col = 80;
pg.direction = 1;
pg.onEnterFrame = function () {
var _local1 = this;
_local1.col = _local1.col + (5 * _local1.direction);
if ((_local1.col > 254) || (_local1.col < 80)) {
_local1.direction = _local1.direction * -1;
}
var r = (_local1.col << 16);
var g = (_local1.col << 8);
var _local3 = _local1.col;
var _local2 = (r + g) + _local3;
_local1.replay.textColor = _local2;
};
pg.setPauseOK = function () {
var _local1 = this;
_local1.onKeyDown = function () {
if (Key.getCode() == 32) {
stats.align = "left";
dim.removeMovieClip();
paddleMC.onEnterFrame = frameCode;
this._parent.onKeyDown = pauseGame;
this.removeMovieClip();
}
};
Key.addListener(pg);
clearInterval(waitPause);
};
waitPause = setInterval(pg, "setPauseOK", 1000);
};
pauseGame = function () {
if (Key.getCode() == 32) {
delete paddleMC.onEnterFrame;
delete this.onKeyDown;
pausePopUp();
}
};
playBlip = function (rate) {
this["blip" + (Math.ceil(rate / 2) - 1)].start();
};
reColor = function () {
currentColor = (((currentColor + 1) > (colors.length - 1)) ? 0 : (currentColor + 1));
imagescoreCredit.music.textColor = (statsTitle.color = colors[currentColor].textCol);
livesTitleTF.setTextFormat(statsTitle);
scoreTitleTF.setTextFormat(statsTitle);
highTitleTF.setTextFormat(statsTitle);
plane.side[0].sideColor = colors[currentColor].planeColor;
};
flash = function () {
var _local1 = this;
_local1.createEmptyMovieClip("flasher", 2700);
flasher._x = centerX;
flasher._y = centerY;
flashObj = {colors:[16777215, 16777215, 16777215, 16777215, 16777215], alphas:[0, 60, 0, 30, 0], ratios:[20, 100, 150, 200, 250], hotspot:radius * 2};
drawSphereAssets(flasher, flashObj, {x:0, y:0}, smoothness);
flasher._xscale = (flasher._yscale = 10);
flasher.onEnterFrame = function () {
var _local1 = this;
_local1._xscale = (_local1._yscale = _local1._yscale * 1.5);
_local1._alpha = _local1._alpha - 20;
_local1._rotation = _local1._rotation + 15;
if (_local1._alpha < 0) {
_local1.removeMovieClip();
}
};
};
paddle = new PlaneModel();
paddle.clip = paddleMC;
paddle.rate = 8;
paddle.vertexList = [];
paddle.vertexList.push({x:-planeSize, y:-planeSize, z:radAdj, w:1});
paddle.vertexList.push({x:-planeSize, y:planeSize, z:radAdj, w:1});
paddle.vertexList.push({x:planeSize, y:planeSize, z:radAdj, w:1});
paddle.vertexList.push({x:planeSize, y:-planeSize, z:radAdj, w:1});
paddle.side = [];
paddle.side.push({vertices:[0, 1, 2, 3], sideColor:"550055", fillAlpha:50});
plane = new PlaneModel();
plane.clip = planeMC;
plane.vertexList = [];
plane.vertexList.push({x:-planeSize, y:-planeSize, z:0, w:1});
plane.vertexList.push({x:-planeSize, y:planeSize, z:0, w:1});
plane.vertexList.push({x:planeSize, y:planeSize, z:0, w:1});
plane.vertexList.push({x:planeSize, y:-planeSize, z:0, w:1});
plane.side = [];
plane.side.push({vertices:[0, 1, 2, 3], sideColor:colors[currentColor].planeColor, fillAlpha:100});
ball = new BallModel();
ball.clip = [ballMC.innerBall];
ball.rad = ballMC._width / 2;
ball.vertexList = [];
ball.vertexlist.push({x:0, y:0, z:0, w:1});
target = new Model();
target.clip = [targetMC.topTarget, targetMC.bottomTarget];
target.vertexList = [];
target.vertexList.push({x:0, y:0, z:0, w:1});
target.vertexList.push({x:0, y:0, z:0, w:1});
light = new LightSource(-20000, -20000, 20000, 100);
sphereHL = {colors:[16777215, 16777215], alphas:[20, 0], ratios:[0, 225], hotspot:radAdj};
sphereShadow = {colors:[0, 0], alphas:[0, 30], ratios:[100, 155], hotspot:radius * 3.6};
sphereBackShadow = {colors:[592137, 0], alphas:[20, 0], ratios:[80, 140], hotspot:radius * 4};
sphereRim = {colors:[16777215, 16777215], alphas:[0, 2], ratios:[230, 230], hotspot:radius * 2};
drawSphereAssets(backShadow, sphereBackShadow, {x:50, y:40}, smoothness);
drawSphereAssets(sphere.shadow, sphereShadow, {x:(-radius) / 4, y:(-radius) / 4}, smoothness);
drawSphereAssets(sphere.highlight, sphereHL, {x:(-radius) / 3, y:(-radius) / 3}, smoothness);
drawSphereAssets(sphere.rim, sphereRim, {x:0, y:0}, smoothness);
this.onKeyDown = pauseGame;
Key.addListener(this);
startGamePopUp();
stop();