Frame 1
function UpdateCircle(circle) {
circle.clip._x = circle.x;
circle.clip._y = circle.y;
}
function ApplyForces(circle, identifier) {
circle.xmov = circle.xmov * circle.friction;
circle.ymov = circle.ymov * circle.friction;
if (circle.xmov > circle.maxSpeed) {
circle.xmov = circle.maxSpeed;
}
if (circle.xmov < (-circle.maxSpeed)) {
circle.xmov = -circle.maxSpeed;
}
if (circle.ymov > circle.maxSpeed) {
circle.ymov = circle.maxSpeed;
}
if (circle.ymov < (-circle.maxSpeed)) {
circle.ymov = -circle.maxSpeed;
}
circle.x = circle.x + circle.xmov;
circle.y = circle.y + circle.ymov;
if (identifier == 1) {
if (circle.y < paddle.dragy1) {
circle.y = paddle.dragy1;
}
}
}
function CheckWalls(circle) {
if ((circle.x + circle.radius) > (table.width + table.xOffset)) {
PlaySound("hitWall", circle.xmov * 40);
circle.x = (table.width + table.xOffset) - circle.radius;
circle.xmov = (-circle.xmov) * circle.wallBounce;
} else if ((circle.x - circle.radius) < table.xOffset) {
PlaySound("hitWall", circle.xmov * -40);
circle.x = table.xOffset + circle.radius;
circle.xmov = (-circle.xmov) * circle.wallBounce;
} else if ((circle.y + circle.radius) > (table.height + table.yOffset)) {
if (((circle.name == "puck") && (circle.x > table.goalXstart)) && (circle.x < table.goalXend)) {
scoreObj.start();
game.CPUScore++;
_root["pegCPU" + game.CPUScore].gotoAndPlay("closed");
game.lastGoal = "CPU";
game.state = "goal";
} else {
PlaySound("hitWall", circle.ymov * 40);
circle.y = (table.height + table.yOffset) - circle.radius;
circle.ymov = (-circle.ymov) * circle.wallBounce;
}
} else if ((circle.y - circle.radius) < table.yOffset) {
if (((circle.name == "puck") && (circle.x > table.goalXstart)) && (circle.x < table.goalXend)) {
scoreObj.start();
game.playerScore++;
_root["peg" + game.playerScore].gotoAndPlay("closed");
game.lastGoal = "player";
game.state = "goal";
} else {
PlaySound("hitWall", circle.ymov * -40);
circle.y = table.yOffset + circle.radius;
circle.ymov = (-circle.ymov) * circle.wallBounce;
}
}
}
function CheckGoalWalls(circle) {
if (circle.x > table.goalXend) {
circle.x = table.goalXend - circle.radius;
circle.xmov = (-circle.xmov) * circle.wallBounce;
} else if (circle.x < table.goalXstart) {
circle.x = table.goalXstart + circle.radius;
circle.xmov = (-circle.xmov) * circle.wallBounce;
}
}
function CircleToCircleDetection(circle_a, circle_b) {
var _local4 = circle_a.x - circle_b.x;
var _local5 = circle_a.y - circle_b.y;
var _local6 = Math.sqrt((_local4 * _local4) + (_local5 * _local5));
var _local3 = Math.abs(circle_a.xmov - circle_a.ymov) + Math.abs(circle_b.xmov - circle_b.ymov);
_local3 = (_local3 * 0.8) - 2;
if (_local6 <= ((circle_a.radius + circle_b.radius) + _local3)) {
PlaySound("hitPuck", _local3 * 10);
normalX = _local4 / _local6;
normalY = _local5 / _local6;
Vector1 = (circle_a.xmov * normalX) + (circle_a.ymov * normalY);
Vector2 = (circle_b.xmov * normalX) + (circle_b.ymov * normalY);
Vector3 = Vector1 - Vector2;
dv0 = -0.9 * Vector3;
dv1 = 0.9 * Vector3;
if (Vector3 >= 0) {
return(undefined);
}
circle_a.xmov = circle_a.xmov + ((normalX * dv0) / circle_a.mass);
circle_a.ymov = circle_a.ymov + ((normalY * dv0) / circle_a.mass);
}
}
function MoveCPU() {
paddleCPU.xGoal = puck.x;
paddleCPU.xMov = (paddleCPU.xGoal - paddleCPU.x) / _root[game.CPUlevel].xDiv;
if (paddleCPU.xMov > _root[game.CPUlevel].xSpeedMax) {
paddleCPU.xMov = _root[game.CPUlevel].xSpeedMax;
}
if (paddleCPU.xMov < (-_root[game.CPUlevel].xSpeedMax)) {
paddleCPU.xMov = -_root[game.CPUlevel].xSpeedMax;
}
paddleCPU.x = paddleCPU.x + paddleCPU.xMov;
if ((puck.y > table.yOffset) && (puck.y < (table.yOffset + (table.height / 2)))) {
paddleCPU.yGoal = puck.y - 15;
} else {
paddleCPU.yGoal = _root[game.CPUlevel].yDefault;
}
paddleCPU.yMov = (paddleCPU.yGoal - paddleCPU.y) / _root[game.CPUlevel].yDiv;
if (paddleCPU.yMov > _root[game.CPUlevel].ySpeedMax) {
paddleCPU.yMov = _root[game.CPUlevel].ySpeedMax;
}
if (paddleCPU.yMov < (-_root[game.CPUlevel].ySpeedMax)) {
paddleCPU.yMov = -_root[game.CPUlevel].ySpeedMax;
}
paddleCPU.y = paddleCPU.y + paddleCPU.yMov;
paddleCPU.clip._x = paddleCPU.x;
paddleCPU.clip._y = paddleCPU.y;
paddleCPU.xmov = paddleCPU.clip._x - paddleCPU.oldx2;
paddleCPU.oldx5 = paddleCPU.oldx4;
paddleCPU.oldx4 = paddleCPU.oldx3;
paddleCPU.oldx3 = paddleCPU.oldx2;
paddleCPU.oldx2 = paddleCPU.oldx1;
paddleCPU.oldx1 = paddleCPU.x;
paddleCPU.x = paddleCPU.clip._x;
paddleCPU.ymov = paddleCPU.clip._y - paddleCPU.oldy2;
paddleCPU.oldy5 = paddleCPU.oldy4;
paddleCPU.oldy4 = paddleCPU.oldy3;
paddleCPU.oldy3 = paddleCPU.oldy2;
paddleCPU.oldy2 = paddleCPU.oldy1;
paddleCPU.oldy1 = paddleCPU.y;
paddleCPU.y = paddleCPU.clip._y;
}
function ResetPuck() {
puck.x = table.xOffset + (table.width / 2);
puck.xmov = (Math.random() * 6) - 3;
if (game.lastGoal == "player") {
puck.y = (table.yOffset + (table.height / 2)) - 10;
puck.ymov = (Math.random() * 3) - 3;
} else if (game.lastGoal == "CPU") {
puck.y = (table.yOffset + (table.height / 2)) + 10;
puck.ymov = Math.random() * 3;
} else {
puck.ymov = (Math.random() * 6) - 3;
}
}
function PlaySound(soundName, soundVolume) {
if (soundVolume > 100) {
soundVolume = 100;
}
if (soundVolume < 50) {
soundVolume = 50;
}
switch (soundName) {
case "hitPuck" :
if (hitPuckPlaying == 0) {
hitPuckObj.setVolume(soundVolume);
hitPuckObj.onSoundComplete = function () {
hitPuckPlaying = 0;
};
hitPuckObj.start();
hitPuckPlaying = 1;
}
break;
case "hitWall" :
if (hitWallPlaying != 0) {
break;
}
hitWallObj.setVolume(soundVolume);
hitWallObj.onSoundComplete = function () {
hitWallPlaying = 0;
};
hitWallObj.start();
hitWallPlaying = 1;
case 3 :
}
}
function StartGame(difficulty) {
sndLoopObj.setVolume(20);
game.number++;
game.CPUlevel = difficulty;
game.state = "play";
if (game.number == 1) {
mcRings.gotoAndPlay("show");
}
ResetPuck();
mcTitleScreen._visible = false;
mcPaddle._alpha = 100;
mcPaddle._visible = true;
mcPaddleCPU._visible = true;
mcPaddle.circleButton2.enabled = true;
mcPuck._visible = true;
}
function ContinueGame() {
game.state = "play";
ResetPuck();
}
function RestartGame() {
puck.x = 200;
puck.y = 350;
puck.xmov = 0;
puck.ymov = 0;
game.state = "intro";
game.playerScore = 0;
game.CPUScore = 0;
game.lastGoal = 0;
mcScoreboards.mcGameover.gotoAndStop("hide");
mcScoreboards.mcScorePlayer.gotoAndStop("zero");
mcScoreboards.mcScoreCPU.gotoAndStop("zero");
mcScoreboards.mcGameover.gotoAndPlay("hide");
mcScoreboards.gotoAndPlay("hideScores");
mcPaddle._visible = false;
mcPaddleCPU._visible = false;
mcPaddle.circleButton2.enabled = false;
mcPuck._visible = false;
mcTitleScreen._visible = true;
fleasObj.stop();
sndLoopObj.setVolume(40);
sndLoopObj.start(0, 999);
}
fscommand ("allowscale", false);
throwFriction = 0.2;
collisionBoost = 1.6;
globalSound = new Sound();
globalSound.setVolume(100);
createEmptyMovieClip("mcSndLoop", getNextHighestDepth());
sndLoopObj = new Sound(mcSndLoop);
sndLoopObj.attachSound("sndLoop");
sndLoopObj.setVolume(40);
sndLoopObj.start(0, 999);
createEmptyMovieClip("mcScore", getNextHighestDepth());
scoreObj = new Sound(mcScore);
scoreObj.setVolume(40);
scoreObj.attachSound("score");
createEmptyMovieClip("mcSndWon", getNextHighestDepth());
sndWonObj = new Sound(mcSndGameover);
sndWonObj.setVolume(50);
sndWonObj.attachSound("sndWon");
sndWonObj.onSoundComplete = function () {
if (game.CPUScoreMax == game.CPUScore) {
_root.fleasObj.start(0, 999);
}
};
sndLostObj = new Sound(mcSndLost);
sndLostObj.setVolume(50);
sndLostObj.attachSound("sndLost");
sndLostObj.onSoundComplete = function () {
if (game.CPUScoreMax == game.CPUScore) {
_root.fleasObj.start(0, 999);
}
};
createEmptyMovieClip("mcFleas", getNextHighestDepth());
fleasObj = new Sound(mcFleas);
fleasObj.attachSound("fleas");
fleasObj.setVolume(30);
createEmptyMovieClip("mcHitPuck", getNextHighestDepth());
hitPuckObj = new Sound(mcHitPuck);
hitPuckObj.attachSound("hitPuck");
hitPuckPlaying = 0;
createEmptyMovieClip("mcHitWall", getNextHighestDepth());
hitWallObj = new Sound(mcHitWall);
hitWallObj.attachSound("hitWall");
hitWallPlaying = 0;
mcPaddle._visible = false;
mcPaddleCPU._visible = false;
mcPaddle.circleButton2.enabled = false;
mcPuck._visible = false;
game = {};
game.CPUlevel = "medium";
game.playerScoreMax = 7;
game.playerScore = 0;
game.CPUScoreMax = 7;
game.CPUScore = 0;
game.lastGoal = 0;
game.goalPause = 100;
game.pauseCounter = 0;
game.number = 0;
game.state = "intro";
easy = {};
easy.xDiv = 45;
easy.yDiv = 20;
easy.xSpeedMax = 2;
easy.ySpeedMax = 3;
easy.yDefault = 225;
medium = {};
medium.xDiv = 35;
medium.yDiv = 15;
medium.xSpeedMax = 2.5;
medium.ySpeedMax = 3.5;
medium.yDefault = 200;
hard = {};
hard.xDiv = 15;
hard.yDiv = 10;
hard.xSpeedMax = 3.5;
hard.ySpeedMax = 4;
hard.yDefault = 100;
table = {};
table.xOffset = 70;
table.yOffset = 40;
table.width = 356;
table.height = 500;
table.goalWidth = 100;
table.goalXstart = (table.xOffset + (table.width / 2)) - (table.goalWidth / 2);
table.goalXend = (table.xOffset + (table.width / 2)) + (table.goalWidth / 2);
puck = {};
puck.clip = mcPuck;
puck.name = "puck";
puck.x = puck.clip._x;
puck.y = puck.clip._y;
puck.radius = puck.clip._width / 2;
puck.xmov = 0;
puck.ymov = 0;
puck.friction = 0.99;
puck.wallBounce = 0.8;
puck.mass = 0.5;
puck.maxSpeed = 25;
paddle = {};
paddle.clip = mcPaddle;
paddle.objName = "paddle";
paddle.x = paddle.clip._x;
paddle.y = paddle.clip._y;
paddle.radius = (paddle.clip._width / 2) - 2;
paddle.xmov = 0;
paddle.ymov = 0;
paddle.friction = 0.98;
paddle.wallBounce = 0.6;
paddle.mass = 0.7;
paddle.maxSpeed = 25;
paddle.drag = false;
paddle.dragx1 = table.xOffset + paddle.radius;
paddle.dragy1 = (table.yOffset + (table.height / 2)) + paddle.radius;
paddle.dragx2 = (table.xOffset + table.width) - paddle.radius;
paddle.dragy2 = (table.yOffset + table.height) - paddle.radius;
paddleCPU = {};
paddleCPU.clip = mcPaddleCPU;
paddleCPU.objName = "paddleCPU";
paddleCPU.x = paddleCPU.clip._x;
paddleCPU.y = paddleCPU.clip._y;
paddleCPU.xGoal = paddleCPU.clip._x;
paddleCPU.yGoal = paddleCPU.clip._y;
paddleCPU.radius = paddleCPU.clip._width / 2;
paddleCPU.xmov = 0;
paddleCPU.ymov = 0;
paddleCPU.mass = 0.7;
_root.onEnterFrame = function () {
if (game.state == "goal") {
game.state = "showScores";
mcScoreboards.gotoAndPlay("showScores");
}
ApplyForces(puck, 0);
if (!paddle.drag) {
ApplyForces(paddle, 1);
}
if (game.state == "play") {
CheckWalls(puck);
}
if (game.state == "showScores") {
CheckGoalWalls(puck);
}
if (!paddle.drag) {
CheckWalls(paddle);
}
if (game.state == "play") {
MoveCPU();
}
UpdateCircle(puck);
if (!paddle.drag) {
UpdateCircle(paddle);
}
if (paddle.drag) {
paddle.xmov = throwFriction * (paddle.clip._x - paddle.oldx5);
paddle.oldx5 = paddle.oldx4;
paddle.oldx4 = paddle.oldx3;
paddle.oldx3 = paddle.oldx2;
paddle.oldx2 = paddle.oldx1;
paddle.oldx1 = paddle.x;
paddle.x = paddle.clip._x;
paddle.ymov = throwFriction * (paddle.clip._y - paddle.oldy5);
paddle.oldy5 = paddle.oldy4;
paddle.oldy4 = paddle.oldy3;
paddle.oldy3 = paddle.oldy2;
paddle.oldy2 = paddle.oldy1;
paddle.oldy1 = paddle.y;
paddle.y = paddle.clip._y;
}
CircleToCircleDetection(puck, paddle);
CircleToCircleDetection(puck, paddleCPU);
};
stop();
Symbol 16 MovieClip Frame 1
stop();
Symbol 16 MovieClip Frame 28
stop();
Symbol 23 Button
on (press) {
if (firstTouch == undefined) {
firstTouch = 1;
_root.mcRings.gotoAndPlay("hide");
}
if (_parent.paddle.y > (_parent.paddle.dragy1 - 2)) {
startDrag (this, true, _parent.paddle.dragx1, _parent.paddle.dragy1, _parent.paddle.dragx2, _parent.paddle.dragy2);
_parent.paddle.drag = true;
Mouse.hide();
}
}
on (release, releaseOutside) {
stopDrag();
Mouse.show();
_parent.paddle.drag = false;
}
Symbol 31 Button
on (release, releaseOutside) {
_root.StartGame("easy");
}
Symbol 36 MovieClip Frame 27
stop();
Symbol 38 Button
on (release) {
_root.StartGame("easy");
}
Symbol 40 Button
on (release) {
_root.StartGame("medium");
}
Symbol 42 Button
on (release, releaseOutside) {
_root.StartGame("hard");
}
Symbol 46 Button
on (press) {
getURL ("http://www.mediaphaaze.com", "_blank");
}
Symbol 67 MovieClip Frame 1
stop();
Symbol 67 MovieClip Frame 2
stop();
Symbol 67 MovieClip Frame 3
stop();
Symbol 67 MovieClip Frame 4
stop();
Symbol 67 MovieClip Frame 5
stop();
Symbol 67 MovieClip Frame 6
stop();
Symbol 67 MovieClip Frame 7
stop();
Symbol 67 MovieClip Frame 8
stop();
Symbol 70 Button
on (release, releaseOutside) {
getURL ("http://ahv2.mediaphaaze.com", "_self");
}
Symbol 71 MovieClip Frame 1
stop();
Symbol 71 MovieClip Frame 2
_root.sndLoopObj.setVolume(40);
Symbol 71 MovieClip Frame 25
stop();
Symbol 79 MovieClip Frame 1
stop();
Symbol 79 MovieClip Frame 2
_root.sndLoopObj.stop();
_root.sndWonObj.start();
Symbol 79 MovieClip Frame 134
_parent.mcPlayAgain.gotoAndPlay("show");
stop();
Symbol 79 MovieClip Frame 135
_root.sndLoopObj.stop();
_root.sndLostObj.start();
Symbol 79 MovieClip Frame 270
_parent.mcPlayAgain.gotoAndPlay("show");
stop();
Symbol 79 MovieClip Frame 420
stop();
Symbol 81 MovieClip Frame 1
stop();
Symbol 81 MovieClip Frame 75
if (_root.game.lastGoal == "player") {
mcScorePlayer.gotoAndPlay(_root.game.playerScore);
}
if (_root.game.lastGoal == "CPU") {
mcScoreCPU.gotoAndPlay(_root.game.CPUScore);
}
if ((_root.game.playerScore == _root.game.playerScoreMax) || (_root.game.CPUScore == _root.game.CPUScoreMax)) {
stop();
_root.game.state = "gameover";
if (_root.game.playerScore == _root.game.playerScoreMax) {
mcGameover.gotoAndPlay("crown");
} else {
mcGameover.gotoAndPlay("poo");
}
}
Symbol 81 MovieClip Frame 140
_root.ContinueGame();
Symbol 84 Button
on (release, releaseOutside) {
if (globalSound.getVolume() == 0) {
globalSound.setVolume(100);
} else {
globalSound.setVolume(0);
}
}