Frame 1
var currentLvl = 1;
var lvl1Code = new Array(1, 1, 1, 1, 1, 1, 1);
var lvl2Code = new Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1);
var lvl3Code = new Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1);
var lvl4Code = new Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1);
var lvl5Code = new Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1);
var lvlArray = new Array(lvl1Code, lvl2Code, lvl3Code, lvl4Code, lvl5Code);
Frame 2
function calcBallAngle() {
var _local1 = mcBall._x - mcPaddle._x;
var _local2 = (_local1 / (mcPaddle._width - mcBall._width)) - 0.5;
ballXSpeed = _local2 * 10;
ballYSpeed = ballYSpeed * -1;
}
function makeLvl() {
var _local6 = _root.lvlArray[currentLvl - 1].length;
var _local5 = 0;
var _local3 = 0;
while (_local3 < _local6) {
if (lvlArray[currentLvl - 1][_local3] == 1) {
_root.brickAmt++;
_root.attachMovie("mcBrick", "brick" + _local3, _root.getNextHighestDepth());
_root["brick" + _local3]._x = 15 + ((_local3 - (_local5 * 7)) * 75);
_root["brick" + _local3]._y = 10 + (_local5 * 20);
_root["brick" + _local3].onEnterFrame = function () {
if (this.hitTest(_root.mcBall)) {
this.removeMovieClip();
ballYSpeed = ballYSpeed * -1;
_root.brickAmt--;
_root.score = _root.score + 10;
}
if (_root.gameOver) {
this.removeMovieClip();
}
};
var _local4 = 1;
while (_local4 <= 10) {
if (_local3 == ((_local4 * 7) - 1)) {
_local5++;
}
_local4++;
}
}
_local3++;
}
}
stop();
var ballXSpeed = 10;
var ballYSpeed = 10;
var brickAmt = 0;
var lives = 3;
var gameOver = false;
var score = 0;
makeLvl();
mcBg.onRelease = function () {
mcBg._x = 800;
txtStart.text = "";
_root.onEnterFrame = function () {
mcPaddle._x = _xmouse - (mcPaddle._width * 0.5);
if (_xmouse < (mcPaddle._width / 2)) {
mcPaddle._x = 0;
}
if (_xmouse > (Stage.width - (mcPaddle._width / 2))) {
mcPaddle._x = Stage.width - mcPaddle._width;
}
mcBall._x = mcBall._x + ballXSpeed;
mcBall._y = mcBall._y + ballYSpeed;
if (mcBall._x >= (Stage.width - mcBall._width)) {
ballXSpeed = ballXSpeed * -1;
}
if (mcBall._x <= 0) {
ballXSpeed = ballXSpeed * -1;
}
if (mcBall._y >= (Stage.height - mcBall._height)) {
ballYSpeed = ballYSpeed * -1;
lives--;
if (lives <= 0) {
gameOver = true;
gotoAndStop ("lose");
_root.onEnterFrame = null;
}
}
if (mcBall._y <= 0) {
ballYSpeed = ballYSpeed * -1;
}
if (mcBall.hitTest(mcPaddle)) {
calcBallAngle();
}
if (brickAmt == 0) {
currentLvl++;
makeLvl();
mcBall._x = 175;
mcBall._y = 250;
mcBg._x = 0;
_root.onEnterFrame = null;
txtStart.text = "Theres more!";
}
txtStats.text = (((("Level: " + currentLvl) + "\t\tLives: ") + lives) + "\t\tScore: ") + score;
};
};
txtStart.text = "Don't Let the ball fall!";
txtStats.text = (((("Level: " + currentLvl) + "\t\tLives: ") + lives) + "\t\tScore: ") + score;
Frame 10
mcBg._x = 0;
mcBg.onRelease = function () {
gotoAndPlay (1);
};