rendered paste bodyvar swidth = Stage.width;
var sheight = Stage.height;
var brickX = 100;
var brickY = 150;
var large = 10;
var none = 0;
//Create Paddle
_root.attachMovie("Paddle","GPaddle",15999);
_root.GPaddle.onEnterFrame = PaddleMove;
_root.GPaddle._y = 400 - (0.5 * _root.GPaddle._height);
//Create Ball
_root.attachMovie("Ball","ball",15998);
_root.ball._x = swidth/2;
_root.ball._y = sheight/2;
_root.ball.xMove = -5;
_root.ball.yMove = 10;
_root.ball.onEnterFrame = BallMove;
CreateBricks();
function CreateBricks()
{
var brickNum = 0;
for(var y = 50; y < (50 + 5*30); y+= 30)
{
for(var x = 100; x < (100 + 8*50); x+= 50)
{
brickNum ++;
_root.attachMovie("Brick","B" + brickNum,brickNum);
_root["B" + brickNum]._x = x;
_root["B" + brickNum]._y = y;
myColor = Math.round( Math.random()*0xFFFFFF );
myColoredObject = new Color (_root["B" + brickNum]);
myColoredObject.setRGB(myColor);
_root["B" + brickNum].onEnterFrame = CheckForBrickHit;
}
}
}
function CheckForBrickHit()
{
if (this.hitTest(_root.ball))
{
trace("ZOMG we hit a brick");
_root.ball.yMove *= -1;
delete this.onEnterFrame;
this.removeMovieClip();
}
}
function PaddleMove()
{
this._x = _root._xmouse;
}
function BallMove()
{
if (this._y > sheight)
{
trace("ZOMG YOU LOSE");
}
else if (this.hitTest(_root.GPaddle))
{
var ballX = _root.ball._x;
var paddleX = _root.GPaddle._x;
var paddleWidth = _root.GPaddle._width;
if (ballX == paddleX)
{
this.xMove = none;
trace("wow right in the middle!");
}
else if (ballX > paddleX - (0.5 * paddleWidth) && ballX < (paddleX - .25 * paddleWidth))
{
this.xMove = large * -1;
trace("ZOMG hit leftMost (Sorted)");
}
else if (ballX > (paddleX - .25 * paddleWidth) && ballX < paddleX)
{
this.xMove = this.xMove * -1;
trace("ZOMG hit the left middle (SORTED)");
}
else if (ballX > paddleX && ballX < (paddleX + .25* paddleWidth))
{
if (this.xMove < 0)
{
xMove = xMove * -1;
}
trace("ZOMG hit the right middle (SORTED)");
}
else if (ballX < (paddleX + 0.5 * paddleWidth) && ballX > (paddleX + 0.25*paddleWidth))
{
this.xMove = large;
trace("ZOMG hit the far right");
}
this.yMove *= -1;
}
else if (this._y < 0)
{
this.yMove *= -1;
}
else if (this._x > swidth || this._x < 0)
{
this.xMove *= -1;
}
this._x += this.xMove;
this._y += this.yMove;
}