Frame 1
stop();
ballGo = function () {
_root.ball._x = _root.ball._x + ballXSpeed;
_root.ball._y = _root.ball._y + ballYSpeed;
};
controlBat = function () {
bat1._y = _root._ymouse;
};
checkHitPlayer = function () {
if (_root.ball.hitTest(_root.bat1)) {
ballXSpeed = ballXSpeed - (ballXSpeed * 2);
}
};
checkHitEnemy = function () {
if (_root.ball.hitTest(_root.bat2)) {
ballXSpeed = ballXSpeed - (ballXSpeed * 2);
}
};
checkHitWalls = function () {
if (_root.ball.hitTest(_root.top) or _root.ball.hitTest(_root.bottom)) {
ballYSpeed = ballYSpeed * -1;
ballXSpeed = ballXSpeed * 1;
}
};
enemyAI = function () {
bat2.ty = ball._y - (ball._height / 2);
bat2._y = bat2._y + (((bat2.ty - bat2._y) / enemy_speed) * _root.dif);
};
checkScore = function () {
if (ball.hitTest(right)) {
playerScore++;
ball._y = 175;
ball._x = 300;
ballYSpeed = ballYSpeed + 0.5;
ballXSpeed = ballYSpeed * 2;
ballYSpeed = ballYSpeed * 1;
ballXSpeed = ballXSpeed * -1;
}
if (ball.hitTest(_root.left)) {
enemyScore++;
_root.ball._y = 175;
_root.ball._x = 300;
ballYSpeed = ballYSpeed * -1;
ballXSpeed = ballXSpeed * 1;
}
};
checkMouse = function () {
if (_root._currentframe == 1) {
Mouse.show();
} else {
Mouse.hide();
}
};
checkOutcomeLose = function () {
if (_root.playerScore >= 5) {
_root.prevFrame();
_root.outcome = "You Lose";
_root.playerScore = 0;
_root.enemyScore = 0;
}
};
checkOutcomeWin = function () {
if (_root.enemyScore >= 5) {
_root.prevFrame();
_root.outcome = "You Win";
_root.playerScore = 0;
_root.enemyScore = 0;
}
};
onLoad = function () {
_global.enemy_speed = 7.5;
ballXSpeed = 3.6;
ballYSpeed = 3.6;
playerScore = 0;
bat2.ty = 150;
};
onEnterFrame = function () {
ballGo();
controlBat();
checkHitPlayer();
checkHitEnemy();
checkHitWalls();
enemyAI();
checkScore();
checkMouse();
checkOutcomeWin();
checkOutcomeLose();
};
Symbol 4 Button
on (press) {
_root.nextFrame();
_root.dif = 1.1;
}
Symbol 6 Button
on (press) {
_root.nextFrame();
dif = 1.3;
}
Symbol 8 Button
on (press) {
_root.nextFrame();
dif = 1.7;
}