Frame 1
stop();
Instance of Symbol 22 MovieClip in Frame 1
onClipEvent (load) {
leftEdge = this._x - (this._width / 2);
}
onClipEvent (enterFrame) {
var perc = Math.Round(100 * (_root.getBytesLoaded() / _root.getBytesTotal()));
this._xscale = perc;
this._x = leftEdge + (this._width / 2);
if (perc == 100) {
_parent.play();
}
}
Frame 2
function sPop() {
_root.pop.start();
}
function sWallClick() {
_root.wallClick.start();
}
function die() {
paddle.play();
if (lives < 0) {
gameOver();
}
}
function drawGameOverScreen() {
var s = _root.attachMovie("gameOverScreen", "gameOverScreen", 20);
s._x = 192;
s._y = 253;
}
function gameOver() {
theBricks._visible = (paddle._visible = (ball._visible = 0));
drawGameOverScreen();
}
function drawBrick(name, x, y, d, mask) {
var b = this.attachMovie("brick", name, d);
b._x = x;
b._y = y;
b.mask = mask;
return(b);
}
function endLevel() {
ball.deltaX = 0;
ball.deltaY = 0;
brickCount = 0;
brickTotal = 0;
rows = "";
percent.p = 0;
lmask.removeMovieClip();
theLogo.removeMovieClip();
theBricks.removeMovieClip();
nextLevel._visible = 1;
}
function drawLevel(x) {
var name = ("level" + x);
theBricks = _root.createEmptyMovieClip(name, 10);
theBricks._y = 100;
lmask = _root.createEmptyMovieClip("logoMask", 12);
lmask._y = 100;
lmask.drawBrick = drawBrick;
theLogo = _root.attachMovie("adLogo", "logo", 11);
theLogo._x = 190;
theLogo._y = 234;
theLogo.setMask(lmask);
r = 0;
while (r <= 18) {
var rowName = ("row_" + r);
var currentRow = theBricks.createEmptyMovieClip(rowName, r + 1);
_root.rows.push(currentRow);
currentRow._x = 0;
currentRow._y = _root.Y_GRID * r;
currentRow.drawBrick = drawBrick;
c = 0;
while (c <= 7) {
var id = ((8 * r) + c);
var mBrickName = ("brick_" + id);
var brickName = ("brick_" + c);
var xPos = ((_root.X_GRID / 2) + (c * _root.X_GRID));
var bMask = lmask.drawBrick(mBrickName, xPos, _root.Y_GRID * r, id);
var b = currentRow.drawBrick(brickName, xPos, 0, c, bMask);
_root.brickTotal++;
c++;
}
r++;
}
}
function startLevel(n) {
brickCount = 0;
rows = new Array();
ball.mode = "waitForServe";
var levelTotal = blur._totalframes;
if (n > levelTotal) {
while (n > levelTotal) {
n = n - levelTotal;
}
}
blur._alpha = 100;
blur.gotoAndStop(n);
bgimage.gotoAndStop(n);
drawLevel(n);
levelNumber = n;
}
function startGame() {
gameOverScreen.removeMovieClip();
blur._alpha = 100;
scoreboard.score = 0;
lives = 3;
paddle._visible = (ball._visible = 1);
startLevel(1);
}
X_GRID = 48;
Y_GRID = 15;
rows = new Array();
pop = new Sound();
pop.attachSound("pop");
wallClick = new Sound();
wallClick.attachSound("wallClick");
startGame();
stop();
Instance of Symbol 39 MovieClip "ball" in Frame 2
onClipEvent (load) {
this.mode = "waitForServe";
this.basespeed = 10;
this.deltaX = (this.deltaY = this.basespeed);
rebound = function (brick) {
_root.sPop();
_root.blur._alpha = 100 - (_root.percentCount.p * 1.75);
if (_root.blur._alpha < 0) {
_root.blur._alpha = 0;
}
var xDiff = Math.abs(this._x - brick._x);
var yDiff = Math.abs(this._y - brick._y);
var yInt = (((brick._height + this._height) / 2) - yDiff);
var xInt = (((brick._width + this._width) / 2) - xDiff);
if (xDiff > (brick._width / 2)) {
this.deltaX = this.deltaX * -1;
} else {
var slopeToCorner = ((brick._height / 2) / (brick._width / 2));
var slopeToBall = (yDiff / xDiff);
if ((slopeToBall > slopeToCorner) || (slopeToBall < (-1 * slopeToCorner))) {
this.deltaY = this.deltaY * -1;
} else {
this.deltaX = this.deltaX * -1;
}
}
brick.mask.unloadMovie();
brick.unloadMovie();
_root.scoreboard.score = _root.scoreboard.score + 10;
_root.brickCount++;
if (_root.brickCount == _root.brickTotal) {
_root.endLevel();
}
};
}
onClipEvent (enterFrame) {
if (this.mode == "waitForServe") {
this._y = 474;
this._x = _parent.paddle._x;
}
if (this.mode == "inPlay") {
this._x = this._x + this.deltaX;
this._y = this._y + this.deltaY;
if (this._x > 384) {
this._x = 384 - (this._x - 384);
this.deltaX = -1 * Math.abs(this.deltaX);
_root.sWallClick();
} else if (this._x < 0) {
this._x = -this._x;
this.deltaX = Math.abs(this.deltaX);
_root.sWallClick();
}
if (this._y < 0) {
this._y = -this._y;
this.deltaY = Math.abs(this.deltaY);
_root.sWallClick();
} else if (this._y > Stage.height) {
_root.die();
}
if (this.hitTest(_root.paddle)) {
_root.sWallClick();
this.deltaY = -1 * Math.abs(this.deltaY);
var distFromPaddCtr = (this._x - _root.paddle._x);
this.deltaX = 2 * (this.basespeed * (distFromPaddCtr / _root.paddle._width));
}
if (this.hitTest(_root.theBricks)) {
c = 0;
while (c < _root.rows.length) {
var currentRow = _root.rows[c];
if (this.hitTest(currentRow)) {
b = 0;
while (b < 9) {
var bRef = ("brick_" + b);
var testBrick = eval ("currentRow." + bRef);
if (this.hitTest(testBrick)) {
rebound(testBrick);
}
b++;
}
}
c++;
}
}
}
}
Instance of Symbol 53 MovieClip "paddle" in Frame 2
onClipEvent (mouseUp) {
if (_root.ball.mode == "waitForServe") {
_root.ball.mode = "inPlay";
_root.ball.deltaX = (_root.ball.deltaY = _root.ball.basespeed);
_root.ball.deltaY = -1 * Math.abs(_root.ball.deltaY);
}
}
onClipEvent (enterFrame) {
this._x = _root._xmouse;
if (this._x < 35) {
this._x = 35;
}
if (this._x > 349) {
this._x = 349;
}
}
Instance of Symbol 56 MovieClip "scoreboard" in Frame 2
onClipEvent (enterFrame) {
this.scoreShadow = this.score;
}
Instance of Symbol 60 MovieClip "percentCount" in Frame 2
onClipEvent (enterFrame) {
this.p = Math.round(100 * (_root.brickCount / _root.brickTotal));
}
Instance of Symbol 65 MovieClip "nextLevel" in Frame 2
onClipEvent (load) {
this._visible = 0;
this._alpha = 66;
}
onClipEvent (keyDown) {
if ((Key.getCode() == 32) && (this._visible)) {
this._visible = 0;
_root.startLevel(_root.levelNumber + 1);
}
}
Symbol 15 Button
on (release) {
_root.startGame();
}
Symbol 32 MovieClip Frame 1
stop();
Symbol 32 MovieClip Frame 2
stop();
Symbol 37 MovieClip Frame 1
stop();
Symbol 37 MovieClip Frame 2
stop();
Symbol 53 MovieClip Frame 1
_root.ball.mode = "waitForServe";
stop();
Symbol 53 MovieClip Frame 2
Symbol 53 MovieClip Frame 12
_root.lives = _root.lives - 1;