Frame 1
this.onEnterFrame = function () {
var _local2 = _root.getBytesLoaded();
var _local3 = _root.getBytesTotal();
if (_local2 >= _local3) {
gotoAndStop (101);
}
txtLoadPercentage.text = int((_local2 / _local3) * 100) + "%";
};
Frame 100
gotoAndPlay (1);
Frame 101
stop();
Stage.align = "LT";
Stage.scaleMode = "noScale";
btnPlay.onRelease = function () {
gotoAndStop (103);
};
btnInstructions.onRelease = function () {
gotoAndStop ("instructions");
};
var bgm = new Sound(soundmovieclip);
bgm.attachSound("croud");
bgm.setVolume(10);
bgm.start(0, 1000);
bgm.onSoundComplete = function () {
trace("here");
bgm.start(0, 10000);
};
var bgm9 = new Sound();
var rootMenu = new ContextMenu();
rootMenu.hideBuiltInItems();
_root.menu = rootMenu;
Frame 102
stop();
this.onEnterFrame = function () {
stop();
};
btnPlayButton.onRelease = function () {
_root.totalScore = 0;
_root.levelScore1 = 0;
_root.levelScore2 = 0;
_root.levelScore3 = 0;
_root.levelScore4 = 0;
_root.levelScore5 = 0;
_root.levelScore6 = 0;
_root.levelScore7 = 0;
_root.levelScore8 = 0;
_root.levelScore9 = 0;
_root.levelScore10 = 0;
gotoAndStop (103);
};
Frame 103
function KickBall() {
kicker_yspeed = (kickArea._y - mcKicker._y) / 6;
kicker_xspeed = (kickArea._x - mcKicker._x) / 6;
state_aiming = false;
player_running = true;
ball_accelup = 6 - (DistanceBetween(mcKicker._x, mcKicker._y, kickArea._x, kickArea._y) / 7);
mcKicker.kicker.Run();
if (ball_accelup < 0) {
ball_accelup = 1;
}
}
function DistanceBetween(x1, y1, x2, y2) {
return(Math.sqrt(((x2 - x1) * (x2 - x1)) + ((y2 - y1) * (y2 - y1))));
}
function GetObstacle(oid) {
return(_root["obstacle" + oid]);
}
function AdjustDepths() {
if (((ballShadow._y > (goalKeeper._y - 2)) && (ball.getDepth() < goalKeeper.getDepth())) || ((ballShadow._y < (goalKeeper._y - 2)) && (ball.getDepth() > goalKeeper.getDepth()))) {
goalKeeper.swapDepths(ball);
}
}
function ChanceDone() {
if (!chance_done) {
chance_done = true;
EndOfChance();
}
}
function ResetItems() {
ball._x = kickArea._x;
ball._y = kickArea._y;
ball._xscale = 100;
ball._yscale = 100;
ballMover._x = kickArea._x;
ballMover._y = kickArea._y;
ballShadow._x = kickArea._x;
ballShadow._y = kickArea._y;
ballMover._visible = false;
extremeborder._visible = false;
flashAlerts.gotoAndStop(1);
flashAlerts._visible = false;
goalKeeper._x = goalPost._x;
goalKeeper._y = goalPost._y + 4;
goalKeeper.gotoAndStop(1);
state_aiming = true;
if (!nosounds) {
bgm4.start(0, 1);
}
player_running = false;
ball_in_play = false;
kicker_xspeed = 0;
kicker_yspeed = 0;
ball_height = 0;
ball_accelup = 0;
goal_done = false;
save_done = false;
save_checked = false;
target_follow_phase = 0;
if ((DistanceBetween(_xmouse, _ymouse, kickArea._x, kickArea._y) < (kickArea._width / 2)) && (_ymouse > kickArea._y)) {
hoveringAbove = true;
} else {
hoveringAbove = false;
}
i = 0;
while (i < NUM_OBSTACLES) {
GetObstacle(i).gotoAndStop(1);
i++;
}
mcWindDirection._rotation = windDirection;
if ((mcWindDirection._rotation > 90) || (mcWindDirection._rotation < -90)) {
mcWindDirection._rotation = 180;
} else {
mcWindDirection._rotation = 0;
}
wind_y = 0 * Math.sin((windDirection * Math.PI) / 180);
wind_x = 0.5 * Math.cos((windDirection * Math.PI) / 180);
txtWindSpeed.text = int(Math.abs(wind_x * 2) * 10) / 10;
if (txtWindSpeed.text == "0") {
mcWindDirection._rotation = -90;
}
goalPost.gotoAndStop(1);
chance_done = false;
}
function EndOfChance() {
var _local2 = goal_done;
if (_local2) {
if (interval_goalDone == 0) {
}
if (!isDoingReplay) {
_root.totalScore = _root.totalScore + currentScore;
_root["levelScore" + _root.currentLevel] = currentScore;
}
toolBar._visible = true;
toolBar.toolbarButtons.btnNextLevel._visible = true;
toolBar.toolbarButtons.btnRetry._visible = false;
btnNextLevel._visible = true;
toolBar.gotoAndPlay(1);
} else {
if (!isDoingReplay) {
_root.numChances--;
}
if (_root.numChances <= 0) {
nosounds = true;
if (interval_gameOver == 0) {
interval_gameOver = setInterval(GameOver, 2000);
}
} else {
if (interval_retry != 0) {
clearInterval(interval_retry);
interval_retry = 0;
}
trace("Setting Retry...");
interval_retry = setInterval(DoRetry, 2000);
}
}
}
function CalculateTargetX(ballx, bally, ballxspeed, ballyspeed, ylimit) {
if (((ballyspeed < 0) && (bally < ylimit)) || ((ballyspeed > 0) && (bally > ylimit))) {
return(-100);
}
if (ballyspeed < 0) {
while (bally > ylimit) {
bally = bally + ballyspeed;
ballx = ballx + ballxspeed;
}
} else {
while (bally < ylimit) {
bally = bally + ballyspeed;
ballx = ballx + ballxspeed;
}
}
return(ballx);
}
function DoRetry() {
if (interval_retry != 0) {
clearInterval(interval_retry);
interval_retry = 0;
}
nosounds = false;
ResetItems();
}
function DoReplay() {
if (ball_in_play && (!goal_done)) {
return(true);
}
if ((save_playerX == 0) && (save_playerY == 0)) {
return(undefined);
}
if (interval_retry != 0) {
clearInterval(interval_retry);
interval_retry = 0;
}
toolBar.play();
ResetItems();
mcKicker._x = save_playerX;
mcKicker._y = save_playerY;
mcKicker.gotoAndStop(save_playerFrame);
UpdateAngle();
isDoingReplay = true;
KickBall();
}
function NextLevel() {
GoalDone();
}
function GoalDone() {
ResetItems();
nextFrame();
}
function GameOver() {
clearInterval(interval_gameOver);
interval_gameOver = 0;
gotoAndStop ("gameover");
}
function UpdateAngle() {
}
stop();
_root.totalScore = 0;
_root.levelScore1 = 0;
_root.levelScore2 = 0;
_root.levelScore3 = 0;
_root.levelScore4 = 0;
_root.levelScore5 = 0;
_root.levelScore6 = 0;
_root.levelScore7 = 0;
_root.levelScore8 = 0;
_root.levelScore9 = 0;
_root.levelScore10 = 0;
_root.numChances = 10;
NUM_OBSTACLES = 3;
_root.currentLevel = 1;
stopAllSounds();
var bgm = new Sound();
bgm.attachSound("cheer");
var bgm2 = new Sound();
bgm2.attachSound("miss");
var bgm3 = new Sound();
bgm3.attachSound("kick");
var bgm4 = new Sound();
bgm4.attachSound("whistle");
var bgm5 = new Sound(soundmovieclip2);
bgm5.attachSound("ballbounce");
var bgm6 = new Sound(soundmovieclip);
bgm6.attachSound("croud");
var firsttime = true;
var playedsound = false;
var nosounds = false;
bgm5.setVolume(30);
bgm6.setVolume(10);
bgm6.start(0, 1000);
bgm6.onSoundComplete = function () {
bgm6.start(0, 10000);
};
var state_aiming = true;
var player_running = false;
var ball_in_play = false;
var chance_done = false;
var hoveringAbove;
var kicker_xspeed = 0;
var kicker_yspeed = 0;
var ball_height = 0;
var ball_accelup = 0;
var goal_done = false;
var save_done = false;
var interval_ChanceTime = 0;
var target_follow_phase = 0;
var interval_goalDone = 0;
var interval_gameOver = 0;
var interval_retry = 0;
var save_checked = false;
scoreCard.gotoAndStop(1);
scoreCard._visible = false;
var currentScore = 0;
var r1 = 135;
var r2 = 65;
goalArea._x = goalPost._x;
goalArea._y = goalPost._y;
var keeper_speed = 1.5;
var gravity = 0.5;
var friction = 1.03;
var friction_gravity = 2;
var save_playerX = 0;
var save_playerY = 0;
var save_playerFrame = 0;
var isDoingReplay = false;
var windDirection = ((Math.random() * 360) - 180);
mcWindDirection._rotation = windDirection;
if ((mcWindDirection._rotation > 90) || (mcWindDirection._rotation < -90)) {
mcWindDirection._rotation = 180;
} else {
mcWindDirection._rotation = 0;
}
var wind_y = (0 * Math.sin((windDirection * Math.PI) / 180));
var wind_x = (0.5 * Math.cos((windDirection * Math.PI) / 180));
txtWindSpeed.text = int(Math.abs(wind_x * 2) * 10) / 10;
if (txtWindSpeed.text == "0") {
mcWindDirection._rotation = -90;
}
txtLevel.text = _root.currentLevel + "/10";
ball._x = kickArea._x;
ball._y = kickArea._y;
ballMover._visible = false;
extremeborder._visible = false;
flashAlerts.gotoAndStop(1);
flashAlerts._visible = false;
targetMarker._visible = false;
var mouseMoveLock = true;
toolBar.gotoAndStop(1);
btnNextLevel._visible = false;
i = 0;
while (i < NUM_OBSTACLES) {
GetObstacle(i).gotoAndStop(1);
i++;
}
goalPost.gotoAndStop(1);
kickArea.onRollOver = function () {
hoveringAbove = true;
};
kickArea.onDragOver = function () {
hoveringAbove = true;
};
ResetItems();
kickArea.onMouseMove = function () {
if (!mouseMoveLock) {
hoveringAbove = true;
mouseMoveLock = true;
}
};
kickArea.onRollOut = function () {
hoveringAbove = false;
};
kickArea.onDragOut = function () {
hoveringAbove = false;
};
kickArea.onRelease = function () {
if (state_aiming) {
save_playerX = mcKicker._x;
save_playerY = mcKicker._y;
save_playerFrame = mcKicker._currentframe;
isDoingReplay = false;
KickBall();
}
};
this.onEnterFrame = function () {
if (!state_aiming) {
if (player_running) {
mcKicker._x = mcKicker._x + kicker_xspeed;
mcKicker._y = mcKicker._y + kicker_yspeed;
if (DistanceBetween(mcKicker._x, mcKicker._y, kickArea._x, kickArea._y) <= 5) {
player_running = false;
mcKicker.kicker.gotoAndStop(1);
ball_in_play = true;
bgm3.start(0, 1);
ball_accelup = 6;
targetMarker._x = CalculateTargetX(ballMover._x, ballMover._y, kicker_xspeed, kicker_yspeed, targetMarker._y);
}
return(undefined);
}
if (ball_in_play) {
ballMover._x = ballMover._x + kicker_xspeed;
ballMover._y = ballMover._y + kicker_yspeed;
ball._rotation = ball._rotation + (kicker_xspeed * 10);
ball_height = ball_height + ball_accelup;
ball_accelup = ball_accelup - gravity;
if ((((ball_height > 3) && (ball_height < 8)) && (!playedsound)) && (ball_height < 6)) {
playedsound = true;
bgm5.start(0, 1);
}
if ((ball_accelup < 0) && (ball_height < 0)) {
playedsound = false;
ball_height = 0;
ball_accelup = -(ball_accelup / friction_gravity);
wind_x = wind_x / 5;
wind_y = wind_y / 5;
if (Math.abs(ball_accelup) <= 1) {
ball_accelup = 0;
ball_height = 0;
}
}
kicker_xspeed = kicker_xspeed / friction;
kicker_yspeed = kicker_yspeed / friction;
kicker_xspeed = kicker_xspeed + wind_x;
kicker_yspeed = kicker_yspeed + wind_y;
if (Math.abs(kicker_xspeed) < 0.1) {
kicker_xspeed = 0;
}
if (Math.abs(kicker_yspeed) < 0.1) {
kicker_yspeed = 0;
}
if ((Math.abs(kicker_xspeed) < 1) && (Math.abs(kicker_yspeed) < 1)) {
kicker_xspeed = 0;
kicker_yspeed = 0;
if (!chance_done) {
ChanceDone();
}
}
if (((ball._x > Stage.width) || (ball._x < 0)) || (ball._y > Stage.height)) {
if ((!chance_done) && (!goal_done)) {
ChanceDone();
}
}
ball._x = ballMover._x;
ball._y = ballMover._y - ball_height;
ball._xscale = ((ballMover._y - 30) / (mcKicker._y - 30)) * 100;
if (ball._xscale > 100) {
ball._xscale = 100;
}
ball._yscale = ball._xscale;
ballShadow._x = ballMover._x;
ballShadow._y = ballMover._y;
AdjustDepths();
if (kicker_yspeed < 0) {
jumpdetectrange = Math.abs(kicker_yspeed * 6);
if ((Math.abs(ballMover._y - goalKeeper._y) < jumpdetectrange) && (Math.abs(ballMover._x - goalKeeper._x) < 5)) {
if (ball_height > 10) {
goalKeeper.JumpDefend();
} else {
goalKeeper.Defend();
}
}
if ((target_follow_phase == 0) && (ballMover._y < (goalKeeper._y + (((mcKicker._y - goalKeeper._y) * 2) / 3)))) {
targetMarker._x = CalculateTargetX(ballMover._x, ballMover._y, kicker_xspeed, kicker_yspeed, targetMarker._y);
target_follow_phase = 1;
}
if ((target_follow_phase == 1) && (ballMover._y < (goalKeeper._y + ((mcKicker._y - goalKeeper._y) / 3)))) {
targetMarker._x = CalculateTargetX(ballMover._x, ballMover._y, kicker_xspeed, kicker_yspeed, targetMarker._y);
target_follow_phase = 2;
}
if (((target_follow_phase == 2) && (!goalKeeper.isJumping())) && (Math.abs(targetMarker._x - goalKeeper._x) > 20)) {
if (targetMarker._x < goalKeeper._x) {
goalKeeper.JumpLeft();
} else {
goalKeeper.JumpRight();
}
}
if (targetMarker._x < (goalKeeper._x - keeper_speed)) {
if (!goalKeeper.isJumping()) {
goalKeeper._x = goalKeeper._x - keeper_speed;
} else {
goalKeeper._x = goalKeeper._x - (keeper_speed / 2);
}
goalKeeper.Walk();
} else if (targetMarker._x > (goalKeeper._x + keeper_speed)) {
if (!goalKeeper.isJumping()) {
goalKeeper._x = goalKeeper._x + keeper_speed;
} else {
goalKeeper._x = goalKeeper._x + (keeper_speed / 2);
}
goalKeeper.Walk();
} else {
goalKeeper.StopMotion();
}
} else {
goalKeeper.StopMotion();
}
if (ballMover._y <= extremeborder._y) {
kicker_yspeed = Math.abs(kicker_yspeed);
kicker_yspeed = kicker_yspeed / 2;
if (kicker_yspeed > 2) {
kicker_yspeed = 2;
}
kicker_xspeed = kicker_xspeed / 2;
wind_x = wind_x / 8;
wind_y = wind_y / 8;
if (!nosounds) {
bgm2.start(0, 1);
nosounds = true;
}
}
if ((((!save_done) && (!goal_done)) && (ballMover._y >= goalKeeper._y)) && ((ballMover._y + kicker_yspeed) <= goalKeeper._y)) {
save_checked = true;
if (com.gskinner.sprites.CollisionDetection.checkForCollision(ball, goalKeeper)) {
kicker_yspeed = Math.abs(kicker_yspeed);
kicker_yspeed = kicker_yspeed / 7;
if (!flashAlerts._visible) {
flashAlerts._visible = true;
if (!nosounds) {
bgm2.start(0, 1);
nosounds = true;
}
flashAlerts.gotoAndPlay("save");
save_done = true;
}
wind_x = 0;
wind_y = 0;
}
}
if (((((save_checked && (!goal_done)) && (kicker_yspeed < 0)) && ((goalPost._y - ballMover._y) > 0)) && ((goalPost._y - ballMover._y) < 10)) && (ballMover.hitTest(goalArea))) {
flashAlerts._visible = true;
if (!nosounds) {
bgm.start(0, 1);
nosounds = true;
}
flashAlerts.gotoAndPlay("goal");
kicker_xspeed = 0;
kicker_yspeed = 0.2;
goalPost.gotoAndPlay(1);
goal_done = true;
currentScore = int(DistanceBetween(ball._x, ball._y, goalKeeper._x, goalKeeper._y));
scoreCard.scoreDisplay.txtScore.text = currentScore;
scoreCard._x = ball._x + 50;
scoreCard._y = ball._y;
scoreCard._visible = true;
scoreCard.gotoAndPlay(1);
wind_x = 0;
wind_y = 0;
}
if (kicker_yspeed < 0) {
i = 0;
while (i < NUM_OBSTACLES) {
if ((Math.abs(GetObstacle(i)._y - ballMover._y) < 2) && (com.gskinner.sprites.CollisionDetection.checkForCollision(ball, GetObstacle(i)))) {
kicker_yspeed = -kicker_yspeed;
GetObstacle(i).gotoAndPlay(1);
if (!nosounds) {
bgm2.start(0, 1);
nosounds = true;
}
break;
}
i++;
}
}
}
return(undefined);
}
var _local1 = Math.atan2(_ymouse - kickArea._y, _xmouse - kickArea._x);
var _local2 = _local1;
if (_local1 < 0) {
if (_local1 < -1.5707963267949) {
_local1 = -3.14159265358979;
} else {
_local1 = 0;
}
_local2 = -_local1;
}
mcArrow._rotation = (_local1 * 180) / Math.PI;
if (_local2 > 2.51327412287183) {
mcKicker.gotoAndStop(5);
} else if (_local2 > 1.88495559215388) {
mcKicker.gotoAndStop(4);
} else if (_local2 > 1.25663706143592) {
mcKicker.gotoAndStop(3);
} else if (_local2 > 0.628318530717959) {
mcKicker.gotoAndStop(2);
} else {
mcKicker.gotoAndStop(1);
}
if (hoveringAbove) {
mcKicker._x = _xmouse;
mcKicker._y = _ymouse;
} else {
posx = kickArea._x + (r1 * Math.cos(_local1));
posy = kickArea._y + (r2 * Math.sin(_local1));
if (Math.abs(posx - kickArea._x) < Math.abs(_xmouse - kickArea._x)) {
mcKicker._x = posx;
} else {
mcKicker._x = _xmouse;
}
mcKicker._y = posy;
}
};
btnReplay.onRelease = function () {
nosounds = true;
DoReplay();
};
btnNextLevel.onRelease = function () {
nosounds = false;
NextLevel();
};
Frame 104
function KickBall() {
kicker_yspeed = (kickArea._y - mcKicker._y) / 6;
kicker_xspeed = (kickArea._x - mcKicker._x) / 6;
state_aiming = false;
player_running = true;
ball_accelup = 6 - (DistanceBetween(mcKicker._x, mcKicker._y, kickArea._x, kickArea._y) / 7);
mcKicker.kicker.Run();
if (ball_accelup < 0) {
ball_accelup = 1;
}
}
function DistanceBetween(x1, y1, x2, y2) {
return(Math.sqrt(((x2 - x1) * (x2 - x1)) + ((y2 - y1) * (y2 - y1))));
}
function GetObstacle(oid) {
return(_root["obstacle" + oid]);
}
function AdjustDepths() {
if (((ballShadow._y > (goalKeeper._y - 2)) && (ball.getDepth() < goalKeeper.getDepth())) || ((ballShadow._y < (goalKeeper._y - 2)) && (ball.getDepth() > goalKeeper.getDepth()))) {
goalKeeper.swapDepths(ball);
}
}
function ChanceDone() {
if (!chance_done) {
chance_done = true;
EndOfChance();
}
}
function ResetItems() {
ball._x = kickArea._x;
ball._y = kickArea._y;
ball._xscale = 100;
ball._yscale = 100;
ballMover._x = kickArea._x;
ballMover._y = kickArea._y;
ballShadow._x = kickArea._x;
ballShadow._y = kickArea._y;
ballMover._visible = false;
extremeborder._visible = false;
flashAlerts.gotoAndStop(1);
flashAlerts._visible = false;
goalKeeper._x = goalPost._x;
goalKeeper._y = goalPost._y + 4;
goalKeeper.gotoAndStop(1);
state_aiming = true;
if (!nosounds) {
bgm4.start(0, 1);
}
player_running = false;
ball_in_play = false;
kicker_xspeed = 0;
kicker_yspeed = 0;
ball_height = 0;
ball_accelup = 0;
goal_done = false;
save_done = false;
save_checked = false;
target_follow_phase = 0;
if ((DistanceBetween(_xmouse, _ymouse, kickArea._x, kickArea._y) < (kickArea._width / 2)) && (_ymouse > kickArea._y)) {
hoveringAbove = true;
} else {
hoveringAbove = false;
}
i = 0;
while (i < NUM_OBSTACLES) {
GetObstacle(i).gotoAndStop(1);
i++;
}
mcWindDirection._rotation = windDirection;
if ((mcWindDirection._rotation > 90) || (mcWindDirection._rotation < -90)) {
mcWindDirection._rotation = 180;
} else {
mcWindDirection._rotation = 0;
}
wind_y = 0 * Math.sin((windDirection * Math.PI) / 180);
wind_x = 0.5 * Math.cos((windDirection * Math.PI) / 180);
txtWindSpeed.text = int(Math.abs(wind_x * 2) * 10) / 10;
if (txtWindSpeed.text == "0") {
mcWindDirection._rotation = -90;
}
goalPost.gotoAndStop(1);
chance_done = false;
}
function EndOfChance() {
var _local2 = goal_done;
if (_local2) {
if (interval_goalDone == 0) {
}
if (!isDoingReplay) {
_root.totalScore = _root.totalScore + currentScore;
_root["levelScore" + _root.currentLevel] = currentScore;
}
toolBar._visible = true;
toolBar.toolbarButtons.btnNextLevel._visible = true;
toolBar.toolbarButtons.btnRetry._visible = false;
btnNextLevel._visible = true;
toolBar.gotoAndPlay(1);
} else {
if (!isDoingReplay) {
_root.numChances--;
}
if (_root.numChances <= 0) {
nosounds = true;
if (interval_gameOver == 0) {
interval_gameOver = setInterval(GameOver, 2000);
}
} else {
if (interval_retry != 0) {
clearInterval(interval_retry);
interval_retry = 0;
}
trace("Setting Retry...");
interval_retry = setInterval(DoRetry, 2000);
}
}
}
function CalculateTargetX(ballx, bally, ballxspeed, ballyspeed, ylimit) {
if (((ballyspeed < 0) && (bally < ylimit)) || ((ballyspeed > 0) && (bally > ylimit))) {
return(-100);
}
if (ballyspeed < 0) {
while (bally > ylimit) {
bally = bally + ballyspeed;
ballx = ballx + ballxspeed;
}
} else {
while (bally < ylimit) {
bally = bally + ballyspeed;
ballx = ballx + ballxspeed;
}
}
return(ballx);
}
function DoRetry() {
if (interval_retry != 0) {
clearInterval(interval_retry);
interval_retry = 0;
}
nosounds = false;
ResetItems();
}
function DoReplay() {
if (ball_in_play && (!goal_done)) {
return(true);
}
if ((save_playerX == 0) && (save_playerY == 0)) {
return(undefined);
}
if (interval_retry != 0) {
clearInterval(interval_retry);
interval_retry = 0;
}
toolBar.play();
ResetItems();
mcKicker._x = save_playerX;
mcKicker._y = save_playerY;
mcKicker.gotoAndStop(save_playerFrame);
UpdateAngle();
isDoingReplay = true;
KickBall();
}
function NextLevel() {
GoalDone();
}
function GoalDone() {
ResetItems();
nextFrame();
}
function GameOver() {
clearInterval(interval_gameOver);
interval_gameOver = 0;
gotoAndStop ("gameover");
}
function UpdateAngle() {
}
stop();
NUM_OBSTACLES = 4;
_root.currentLevel = 2;
stopAllSounds();
var bgm = new Sound();
bgm.attachSound("cheer");
var bgm2 = new Sound();
bgm2.attachSound("miss");
var bgm3 = new Sound();
bgm3.attachSound("kick");
var bgm4 = new Sound();
bgm4.attachSound("whistle");
var bgm5 = new Sound(soundmovieclip2);
bgm5.attachSound("ballbounce");
var bgm6 = new Sound(soundmovieclip);
bgm6.attachSound("croud");
var firsttime = true;
var playedsound = false;
var nosounds = false;
bgm5.setVolume(30);
bgm6.setVolume(10);
bgm6.start(0, 1000);
bgm6.onSoundComplete = function () {
bgm6.start(0, 10000);
};
var state_aiming = true;
var player_running = false;
var ball_in_play = false;
var chance_done = false;
var hoveringAbove;
var kicker_xspeed = 0;
var kicker_yspeed = 0;
var ball_height = 0;
var ball_accelup = 0;
var goal_done = false;
var save_done = false;
var interval_ChanceTime = 0;
var target_follow_phase = 0;
var interval_goalDone = 0;
var interval_gameOver = 0;
var interval_retry = 0;
var save_checked = false;
scoreCard.gotoAndStop(1);
scoreCard._visible = false;
var currentScore = 0;
var r1 = 135;
var r2 = 65;
goalArea._x = goalPost._x;
goalArea._y = goalPost._y;
var keeper_speed = 1.5;
var gravity = 0.5;
var friction = 1.03;
var friction_gravity = 2;
var save_playerX = 0;
var save_playerY = 0;
var save_playerFrame = 0;
var isDoingReplay = false;
var windDirection = ((Math.random() * 360) - 180);
mcWindDirection._rotation = windDirection;
if ((mcWindDirection._rotation > 90) || (mcWindDirection._rotation < -90)) {
mcWindDirection._rotation = 180;
} else {
mcWindDirection._rotation = 0;
}
var wind_y = (0 * Math.sin((windDirection * Math.PI) / 180));
var wind_x = (0.5 * Math.cos((windDirection * Math.PI) / 180));
txtWindSpeed.text = int(Math.abs(wind_x * 2) * 10) / 10;
if (txtWindSpeed.text == "0") {
mcWindDirection._rotation = -90;
}
txtLevel.text = _root.currentLevel + "/10";
ball._x = kickArea._x;
ball._y = kickArea._y;
ballMover._visible = false;
extremeborder._visible = false;
flashAlerts.gotoAndStop(1);
flashAlerts._visible = false;
targetMarker._visible = false;
var mouseMoveLock = true;
toolBar.gotoAndStop(1);
btnNextLevel._visible = false;
i = 0;
while (i < NUM_OBSTACLES) {
GetObstacle(i).gotoAndStop(1);
i++;
}
goalPost.gotoAndStop(1);
kickArea.onRollOver = function () {
hoveringAbove = true;
};
kickArea.onDragOver = function () {
hoveringAbove = true;
};
ResetItems();
kickArea.onMouseMove = function () {
if (!mouseMoveLock) {
hoveringAbove = true;
mouseMoveLock = true;
}
};
kickArea.onRollOut = function () {
hoveringAbove = false;
};
kickArea.onDragOut = function () {
hoveringAbove = false;
};
kickArea.onRelease = function () {
if (state_aiming) {
save_playerX = mcKicker._x;
save_playerY = mcKicker._y;
save_playerFrame = mcKicker._currentframe;
isDoingReplay = false;
KickBall();
}
};
this.onEnterFrame = function () {
if (!state_aiming) {
if (player_running) {
mcKicker._x = mcKicker._x + kicker_xspeed;
mcKicker._y = mcKicker._y + kicker_yspeed;
if (DistanceBetween(mcKicker._x, mcKicker._y, kickArea._x, kickArea._y) <= 5) {
player_running = false;
mcKicker.kicker.gotoAndStop(1);
ball_in_play = true;
bgm3.start(0, 1);
ball_accelup = 6;
targetMarker._x = CalculateTargetX(ballMover._x, ballMover._y, kicker_xspeed, kicker_yspeed, targetMarker._y);
}
return(undefined);
}
if (ball_in_play) {
ballMover._x = ballMover._x + kicker_xspeed;
ballMover._y = ballMover._y + kicker_yspeed;
ball._rotation = ball._rotation + (kicker_xspeed * 10);
ball_height = ball_height + ball_accelup;
ball_accelup = ball_accelup - gravity;
if ((((ball_height > 3) && (ball_height < 8)) && (!playedsound)) && (ball_height < 6)) {
playedsound = true;
bgm5.start(0, 1);
}
if ((ball_accelup < 0) && (ball_height < 0)) {
playedsound = false;
ball_height = 0;
ball_accelup = -(ball_accelup / friction_gravity);
wind_x = wind_x / 5;
wind_y = wind_y / 5;
if (Math.abs(ball_accelup) <= 1) {
ball_accelup = 0;
ball_height = 0;
}
}
kicker_xspeed = kicker_xspeed / friction;
kicker_yspeed = kicker_yspeed / friction;
kicker_xspeed = kicker_xspeed + wind_x;
kicker_yspeed = kicker_yspeed + wind_y;
if (Math.abs(kicker_xspeed) < 0.1) {
kicker_xspeed = 0;
}
if (Math.abs(kicker_yspeed) < 0.1) {
kicker_yspeed = 0;
}
if ((Math.abs(kicker_xspeed) < 1) && (Math.abs(kicker_yspeed) < 1)) {
kicker_xspeed = 0;
kicker_yspeed = 0;
if (!chance_done) {
ChanceDone();
}
}
if (((ball._x > Stage.width) || (ball._x < 0)) || (ball._y > Stage.height)) {
if ((!chance_done) && (!goal_done)) {
ChanceDone();
}
}
ball._x = ballMover._x;
ball._y = ballMover._y - ball_height;
ball._xscale = ((ballMover._y - 30) / (mcKicker._y - 30)) * 100;
if (ball._xscale > 100) {
ball._xscale = 100;
}
ball._yscale = ball._xscale;
ballShadow._x = ballMover._x;
ballShadow._y = ballMover._y;
AdjustDepths();
if (kicker_yspeed < 0) {
jumpdetectrange = Math.abs(kicker_yspeed * 6);
if ((Math.abs(ballMover._y - goalKeeper._y) < jumpdetectrange) && (Math.abs(ballMover._x - goalKeeper._x) < 5)) {
if (ball_height > 10) {
goalKeeper.JumpDefend();
} else {
goalKeeper.Defend();
}
}
if ((target_follow_phase == 0) && (ballMover._y < (goalKeeper._y + (((mcKicker._y - goalKeeper._y) * 2) / 3)))) {
targetMarker._x = CalculateTargetX(ballMover._x, ballMover._y, kicker_xspeed, kicker_yspeed, targetMarker._y);
target_follow_phase = 1;
}
if ((target_follow_phase == 1) && (ballMover._y < (goalKeeper._y + ((mcKicker._y - goalKeeper._y) / 3)))) {
targetMarker._x = CalculateTargetX(ballMover._x, ballMover._y, kicker_xspeed, kicker_yspeed, targetMarker._y);
target_follow_phase = 2;
}
if (((target_follow_phase == 2) && (!goalKeeper.isJumping())) && (Math.abs(targetMarker._x - goalKeeper._x) > 20)) {
if (targetMarker._x < goalKeeper._x) {
goalKeeper.JumpLeft();
} else {
goalKeeper.JumpRight();
}
}
if (targetMarker._x < (goalKeeper._x - keeper_speed)) {
if (!goalKeeper.isJumping()) {
goalKeeper._x = goalKeeper._x - keeper_speed;
} else {
goalKeeper._x = goalKeeper._x - (keeper_speed / 2);
}
goalKeeper.Walk();
} else if (targetMarker._x > (goalKeeper._x + keeper_speed)) {
if (!goalKeeper.isJumping()) {
goalKeeper._x = goalKeeper._x + keeper_speed;
} else {
goalKeeper._x = goalKeeper._x + (keeper_speed / 2);
}
goalKeeper.Walk();
} else {
goalKeeper.StopMotion();
}
} else {
goalKeeper.StopMotion();
}
if (ballMover._y <= extremeborder._y) {
kicker_yspeed = Math.abs(kicker_yspeed);
kicker_yspeed = kicker_yspeed / 2;
if (kicker_yspeed > 2) {
kicker_yspeed = 2;
}
kicker_xspeed = kicker_xspeed / 2;
wind_x = wind_x / 8;
wind_y = wind_y / 8;
if (!nosounds) {
bgm2.start(0, 1);
nosounds = true;
}
}
if ((((!save_done) && (!goal_done)) && (ballMover._y >= goalKeeper._y)) && ((ballMover._y + kicker_yspeed) <= goalKeeper._y)) {
save_checked = true;
if (com.gskinner.sprites.CollisionDetection.checkForCollision(ball, goalKeeper)) {
kicker_yspeed = Math.abs(kicker_yspeed);
kicker_yspeed = kicker_yspeed / 7;
if (!flashAlerts._visible) {
flashAlerts._visible = true;
if (!nosounds) {
bgm2.start(0, 1);
nosounds = true;
}
flashAlerts.gotoAndPlay("save");
save_done = true;
}
wind_x = 0;
wind_y = 0;
}
}
if (((((save_checked && (!goal_done)) && (kicker_yspeed < 0)) && ((goalPost._y - ballMover._y) > 0)) && ((goalPost._y - ballMover._y) < 10)) && (ballMover.hitTest(goalArea))) {
flashAlerts._visible = true;
if (!nosounds) {
bgm.start(0, 1);
nosounds = true;
}
flashAlerts.gotoAndPlay("goal");
kicker_xspeed = 0;
kicker_yspeed = 0.2;
goalPost.gotoAndPlay(1);
goal_done = true;
currentScore = int(DistanceBetween(ball._x, ball._y, goalKeeper._x, goalKeeper._y));
scoreCard.scoreDisplay.txtScore.text = currentScore;
scoreCard._x = ball._x + 50;
scoreCard._y = ball._y;
scoreCard._visible = true;
scoreCard.gotoAndPlay(1);
wind_x = 0;
wind_y = 0;
}
if (kicker_yspeed < 0) {
i = 0;
while (i < NUM_OBSTACLES) {
if ((Math.abs(GetObstacle(i)._y - ballMover._y) < 2) && (com.gskinner.sprites.CollisionDetection.checkForCollision(ball, GetObstacle(i)))) {
kicker_yspeed = -kicker_yspeed;
GetObstacle(i).gotoAndPlay(1);
if (!nosounds) {
bgm2.start(0, 1);
nosounds = true;
}
break;
}
i++;
}
}
}
return(undefined);
}
var _local1 = Math.atan2(_ymouse - kickArea._y, _xmouse - kickArea._x);
var _local2 = _local1;
if (_local1 < 0) {
if (_local1 < -1.5707963267949) {
_local1 = -3.14159265358979;
} else {
_local1 = 0;
}
_local2 = -_local1;
}
mcArrow._rotation = (_local1 * 180) / Math.PI;
if (_local2 > 2.51327412287183) {
mcKicker.gotoAndStop(5);
} else if (_local2 > 1.88495559215388) {
mcKicker.gotoAndStop(4);
} else if (_local2 > 1.25663706143592) {
mcKicker.gotoAndStop(3);
} else if (_local2 > 0.628318530717959) {
mcKicker.gotoAndStop(2);
} else {
mcKicker.gotoAndStop(1);
}
if (hoveringAbove) {
mcKicker._x = _xmouse;
mcKicker._y = _ymouse;
} else {
posx = kickArea._x + (r1 * Math.cos(_local1));
posy = kickArea._y + (r2 * Math.sin(_local1));
if (Math.abs(posx - kickArea._x) < Math.abs(_xmouse - kickArea._x)) {
mcKicker._x = posx;
} else {
mcKicker._x = _xmouse;
}
mcKicker._y = posy;
}
};
btnReplay.onRelease = function () {
nosounds = true;
DoReplay();
};
btnNextLevel.onRelease = function () {
nosounds = false;
NextLevel();
};
Frame 105
function KickBall() {
kicker_yspeed = (kickArea._y - mcKicker._y) / 6;
kicker_xspeed = (kickArea._x - mcKicker._x) / 6;
state_aiming = false;
player_running = true;
ball_accelup = 6 - (DistanceBetween(mcKicker._x, mcKicker._y, kickArea._x, kickArea._y) / 7);
mcKicker.kicker.Run();
if (ball_accelup < 0) {
ball_accelup = 1;
}
}
function DistanceBetween(x1, y1, x2, y2) {
return(Math.sqrt(((x2 - x1) * (x2 - x1)) + ((y2 - y1) * (y2 - y1))));
}
function GetObstacle(oid) {
return(_root["obstacle" + oid]);
}
function AdjustDepths() {
if (((ballShadow._y > (goalKeeper._y - 2)) && (ball.getDepth() < goalKeeper.getDepth())) || ((ballShadow._y < (goalKeeper._y - 2)) && (ball.getDepth() > goalKeeper.getDepth()))) {
goalKeeper.swapDepths(ball);
}
}
function ChanceDone() {
if (!chance_done) {
chance_done = true;
EndOfChance();
}
}
function ResetItems() {
ball._x = kickArea._x;
ball._y = kickArea._y;
ball._xscale = 100;
ball._yscale = 100;
ballMover._x = kickArea._x;
ballMover._y = kickArea._y;
ballShadow._x = kickArea._x;
ballShadow._y = kickArea._y;
ballMover._visible = false;
extremeborder._visible = false;
flashAlerts.gotoAndStop(1);
flashAlerts._visible = false;
goalKeeper._x = goalPost._x;
goalKeeper._y = goalPost._y + 4;
goalKeeper.gotoAndStop(1);
state_aiming = true;
if (!nosounds) {
bgm4.start(0, 1);
}
player_running = false;
ball_in_play = false;
kicker_xspeed = 0;
kicker_yspeed = 0;
ball_height = 0;
ball_accelup = 0;
goal_done = false;
save_done = false;
save_checked = false;
target_follow_phase = 0;
if ((DistanceBetween(_xmouse, _ymouse, kickArea._x, kickArea._y) < (kickArea._width / 2)) && (_ymouse > kickArea._y)) {
hoveringAbove = true;
} else {
hoveringAbove = false;
}
i = 0;
while (i < NUM_OBSTACLES) {
GetObstacle(i).gotoAndStop(1);
i++;
}
mcWindDirection._rotation = windDirection;
if ((mcWindDirection._rotation > 90) || (mcWindDirection._rotation < -90)) {
mcWindDirection._rotation = 180;
} else {
mcWindDirection._rotation = 0;
}
wind_y = 0 * Math.sin((windDirection * Math.PI) / 180);
wind_x = 0.5 * Math.cos((windDirection * Math.PI) / 180);
txtWindSpeed.text = int(Math.abs(wind_x * 2) * 10) / 10;
if (txtWindSpeed.text == "0") {
mcWindDirection._rotation = -90;
}
goalPost.gotoAndStop(1);
chance_done = false;
}
function EndOfChance() {
var _local2 = goal_done;
if (_local2) {
if (interval_goalDone == 0) {
}
if (!isDoingReplay) {
_root.totalScore = _root.totalScore + currentScore;
_root["levelScore" + _root.currentLevel] = currentScore;
}
toolBar._visible = true;
toolBar.toolbarButtons.btnNextLevel._visible = true;
toolBar.toolbarButtons.btnRetry._visible = false;
btnNextLevel._visible = true;
toolBar.gotoAndPlay(1);
} else {
if (!isDoingReplay) {
_root.numChances--;
}
if (_root.numChances <= 0) {
nosounds = true;
if (interval_gameOver == 0) {
interval_gameOver = setInterval(GameOver, 2000);
}
} else {
if (interval_retry != 0) {
clearInterval(interval_retry);
interval_retry = 0;
}
trace("Setting Retry...");
interval_retry = setInterval(DoRetry, 2000);
}
}
}
function CalculateTargetX(ballx, bally, ballxspeed, ballyspeed, ylimit) {
if (((ballyspeed < 0) && (bally < ylimit)) || ((ballyspeed > 0) && (bally > ylimit))) {
return(-100);
}
if (ballyspeed < 0) {
while (bally > ylimit) {
bally = bally + ballyspeed;
ballx = ballx + ballxspeed;
}
} else {
while (bally < ylimit) {
bally = bally + ballyspeed;
ballx = ballx + ballxspeed;
}
}
return(ballx);
}
function DoRetry() {
if (interval_retry != 0) {
clearInterval(interval_retry);
interval_retry = 0;
}
nosounds = false;
ResetItems();
}
function DoReplay() {
if (ball_in_play && (!goal_done)) {
return(true);
}
if ((save_playerX == 0) && (save_playerY == 0)) {
return(undefined);
}
if (interval_retry != 0) {
clearInterval(interval_retry);
interval_retry = 0;
}
toolBar.play();
ResetItems();
mcKicker._x = save_playerX;
mcKicker._y = save_playerY;
mcKicker.gotoAndStop(save_playerFrame);
UpdateAngle();
isDoingReplay = true;
KickBall();
}
function NextLevel() {
GoalDone();
}
function GoalDone() {
ResetItems();
nextFrame();
}
function GameOver() {
clearInterval(interval_gameOver);
interval_gameOver = 0;
gotoAndStop ("gameover");
}
function UpdateAngle() {
}
stop();
NUM_OBSTACLES = 4;
_root.currentLevel = 3;
stopAllSounds();
var bgm = new Sound();
bgm.attachSound("cheer");
var bgm2 = new Sound();
bgm2.attachSound("miss");
var bgm3 = new Sound();
bgm3.attachSound("kick");
var bgm4 = new Sound();
bgm4.attachSound("whistle");
var bgm5 = new Sound(soundmovieclip2);
bgm5.attachSound("ballbounce");
var bgm6 = new Sound(soundmovieclip);
bgm6.attachSound("croud");
var firsttime = true;
var playedsound = false;
var nosounds = false;
bgm5.setVolume(30);
bgm6.setVolume(10);
bgm6.start(0, 1000);
bgm6.onSoundComplete = function () {
bgm6.start(0, 10000);
};
var state_aiming = true;
var player_running = false;
var ball_in_play = false;
var chance_done = false;
var hoveringAbove;
var kicker_xspeed = 0;
var kicker_yspeed = 0;
var ball_height = 0;
var ball_accelup = 0;
var goal_done = false;
var save_done = false;
var interval_ChanceTime = 0;
var target_follow_phase = 0;
var interval_goalDone = 0;
var interval_gameOver = 0;
var interval_retry = 0;
var save_checked = false;
scoreCard.gotoAndStop(1);
scoreCard._visible = false;
var currentScore = 0;
var r1 = 135;
var r2 = 65;
goalArea._x = goalPost._x;
goalArea._y = goalPost._y;
var keeper_speed = 1.5;
var gravity = 0.5;
var friction = 1.03;
var friction_gravity = 2;
var save_playerX = 0;
var save_playerY = 0;
var save_playerFrame = 0;
var isDoingReplay = false;
var windDirection = ((Math.random() * 360) - 180);
mcWindDirection._rotation = windDirection;
if ((mcWindDirection._rotation > 90) || (mcWindDirection._rotation < -90)) {
mcWindDirection._rotation = 180;
} else {
mcWindDirection._rotation = 0;
}
var wind_y = (0 * Math.sin((windDirection * Math.PI) / 180));
var wind_x = (0.5 * Math.cos((windDirection * Math.PI) / 180));
txtWindSpeed.text = int(Math.abs(wind_x * 2) * 10) / 10;
if (txtWindSpeed.text == "0") {
mcWindDirection._rotation = -90;
}
txtLevel.text = _root.currentLevel + "/10";
ball._x = kickArea._x;
ball._y = kickArea._y;
ballMover._visible = false;
extremeborder._visible = false;
flashAlerts.gotoAndStop(1);
flashAlerts._visible = false;
targetMarker._visible = false;
var mouseMoveLock = true;
toolBar.gotoAndStop(1);
btnNextLevel._visible = false;
i = 0;
while (i < NUM_OBSTACLES) {
GetObstacle(i).gotoAndStop(1);
i++;
}
goalPost.gotoAndStop(1);
kickArea.onRollOver = function () {
hoveringAbove = true;
};
kickArea.onDragOver = function () {
hoveringAbove = true;
};
ResetItems();
kickArea.onMouseMove = function () {
if (!mouseMoveLock) {
hoveringAbove = true;
mouseMoveLock = true;
}
};
kickArea.onRollOut = function () {
hoveringAbove = false;
};
kickArea.onDragOut = function () {
hoveringAbove = false;
};
kickArea.onRelease = function () {
if (state_aiming) {
save_playerX = mcKicker._x;
save_playerY = mcKicker._y;
save_playerFrame = mcKicker._currentframe;
isDoingReplay = false;
KickBall();
}
};
this.onEnterFrame = function () {
if (!state_aiming) {
if (player_running) {
mcKicker._x = mcKicker._x + kicker_xspeed;
mcKicker._y = mcKicker._y + kicker_yspeed;
if (DistanceBetween(mcKicker._x, mcKicker._y, kickArea._x, kickArea._y) <= 5) {
player_running = false;
mcKicker.kicker.gotoAndStop(1);
ball_in_play = true;
bgm3.start(0, 1);
ball_accelup = 6;
targetMarker._x = CalculateTargetX(ballMover._x, ballMover._y, kicker_xspeed, kicker_yspeed, targetMarker._y);
}
return(undefined);
}
if (ball_in_play) {
ballMover._x = ballMover._x + kicker_xspeed;
ballMover._y = ballMover._y + kicker_yspeed;
ball._rotation = ball._rotation + (kicker_xspeed * 10);
ball_height = ball_height + ball_accelup;
ball_accelup = ball_accelup - gravity;
if ((((ball_height > 3) && (ball_height < 8)) && (!playedsound)) && (ball_height < 6)) {
playedsound = true;
bgm5.start(0, 1);
}
if ((ball_accelup < 0) && (ball_height < 0)) {
playedsound = false;
ball_height = 0;
ball_accelup = -(ball_accelup / friction_gravity);
wind_x = wind_x / 5;
wind_y = wind_y / 5;
if (Math.abs(ball_accelup) <= 1) {
ball_accelup = 0;
ball_height = 0;
}
}
kicker_xspeed = kicker_xspeed / friction;
kicker_yspeed = kicker_yspeed / friction;
kicker_xspeed = kicker_xspeed + wind_x;
kicker_yspeed = kicker_yspeed + wind_y;
if (Math.abs(kicker_xspeed) < 0.1) {
kicker_xspeed = 0;
}
if (Math.abs(kicker_yspeed) < 0.1) {
kicker_yspeed = 0;
}
if ((Math.abs(kicker_xspeed) < 1) && (Math.abs(kicker_yspeed) < 1)) {
kicker_xspeed = 0;
kicker_yspeed = 0;
if (!chance_done) {
ChanceDone();
}
}
if (((ball._x > Stage.width) || (ball._x < 0)) || (ball._y > Stage.height)) {
if ((!chance_done) && (!goal_done)) {
ChanceDone();
}
}
ball._x = ballMover._x;
ball._y = ballMover._y - ball_height;
ball._xscale = ((ballMover._y - 30) / (mcKicker._y - 30)) * 100;
if (ball._xscale > 100) {
ball._xscale = 100;
}
ball._yscale = ball._xscale;
ballShadow._x = ballMover._x;
ballShadow._y = ballMover._y;
AdjustDepths();
if (kicker_yspeed < 0) {
jumpdetectrange = Math.abs(kicker_yspeed * 6);
if ((Math.abs(ballMover._y - goalKeeper._y) < jumpdetectrange) && (Math.abs(ballMover._x - goalKeeper._x) < 5)) {
if (ball_height > 10) {
goalKeeper.JumpDefend();
} else {
goalKeeper.Defend();
}
}
if ((target_follow_phase == 0) && (ballMover._y < (goalKeeper._y + (((mcKicker._y - goalKeeper._y) * 2) / 3)))) {
targetMarker._x = CalculateTargetX(ballMover._x, ballMover._y, kicker_xspeed, kicker_yspeed, targetMarker._y);
target_follow_phase = 1;
}
if ((target_follow_phase == 1) && (ballMover._y < (goalKeeper._y + ((mcKicker._y - goalKeeper._y) / 3)))) {
targetMarker._x = CalculateTargetX(ballMover._x, ballMover._y, kicker_xspeed, kicker_yspeed, targetMarker._y);
target_follow_phase = 2;
}
if (((target_follow_phase == 2) && (!goalKeeper.isJumping())) && (Math.abs(targetMarker._x - goalKeeper._x) > 20)) {
if (targetMarker._x < goalKeeper._x) {
goalKeeper.JumpLeft();
} else {
goalKeeper.JumpRight();
}
}
if (targetMarker._x < (goalKeeper._x - keeper_speed)) {
if (!goalKeeper.isJumping()) {
goalKeeper._x = goalKeeper._x - keeper_speed;
} else {
goalKeeper._x = goalKeeper._x - (keeper_speed / 2);
}
goalKeeper.Walk();
} else if (targetMarker._x > (goalKeeper._x + keeper_speed)) {
if (!goalKeeper.isJumping()) {
goalKeeper._x = goalKeeper._x + keeper_speed;
} else {
goalKeeper._x = goalKeeper._x + (keeper_speed / 2);
}
goalKeeper.Walk();
} else {
goalKeeper.StopMotion();
}
} else {
goalKeeper.StopMotion();
}
if (ballMover._y <= extremeborder._y) {
kicker_yspeed = Math.abs(kicker_yspeed);
kicker_yspeed = kicker_yspeed / 2;
if (kicker_yspeed > 2) {
kicker_yspeed = 2;
}
kicker_xspeed = kicker_xspeed / 2;
wind_x = wind_x / 8;
wind_y = wind_y / 8;
if (!nosounds) {
bgm2.start(0, 1);
nosounds = true;
}
}
if ((((!save_done) && (!goal_done)) && (ballMover._y >= goalKeeper._y)) && ((ballMover._y + kicker_yspeed) <= goalKeeper._y)) {
save_checked = true;
if (com.gskinner.sprites.CollisionDetection.checkForCollision(ball, goalKeeper)) {
kicker_yspeed = Math.abs(kicker_yspeed);
kicker_yspeed = kicker_yspeed / 7;
if (!flashAlerts._visible) {
flashAlerts._visible = true;
if (!nosounds) {
bgm2.start(0, 1);
nosounds = true;
}
flashAlerts.gotoAndPlay("save");
save_done = true;
}
wind_x = 0;
wind_y = 0;
}
}
if (((((save_checked && (!goal_done)) && (kicker_yspeed < 0)) && ((goalPost._y - ballMover._y) > 0)) && ((goalPost._y - ballMover._y) < 10)) && (ballMover.hitTest(goalArea))) {
flashAlerts._visible = true;
if (!nosounds) {
bgm.start(0, 1);
nosounds = true;
}
flashAlerts.gotoAndPlay("goal");
kicker_xspeed = 0;
kicker_yspeed = 0.2;
goalPost.gotoAndPlay(1);
goal_done = true;
currentScore = int(DistanceBetween(ball._x, ball._y, goalKeeper._x, goalKeeper._y));
scoreCard.scoreDisplay.txtScore.text = currentScore;
scoreCard._x = ball._x + 50;
scoreCard._y = ball._y;
scoreCard._visible = true;
scoreCard.gotoAndPlay(1);
wind_x = 0;
wind_y = 0;
}
if (kicker_yspeed < 0) {
i = 0;
while (i < NUM_OBSTACLES) {
if ((Math.abs(GetObstacle(i)._y - ballMover._y) < 2) && (com.gskinner.sprites.CollisionDetection.checkForCollision(ball, GetObstacle(i)))) {
kicker_yspeed = -kicker_yspeed;
GetObstacle(i).gotoAndPlay(1);
if (!nosounds) {
bgm2.start(0, 1);
nosounds = true;
}
break;
}
i++;
}
}
}
return(undefined);
}
var _local1 = Math.atan2(_ymouse - kickArea._y, _xmouse - kickArea._x);
var _local2 = _local1;
if (_local1 < 0) {
if (_local1 < -1.5707963267949) {
_local1 = -3.14159265358979;
} else {
_local1 = 0;
}
_local2 = -_local1;
}
mcArrow._rotation = (_local1 * 180) / Math.PI;
if (_local2 > 2.51327412287183) {
mcKicker.gotoAndStop(5);
} else if (_local2 > 1.88495559215388) {
mcKicker.gotoAndStop(4);
} else if (_local2 > 1.25663706143592) {
mcKicker.gotoAndStop(3);
} else if (_local2 > 0.628318530717959) {
mcKicker.gotoAndStop(2);
} else {
mcKicker.gotoAndStop(1);
}
if (hoveringAbove) {
mcKicker._x = _xmouse;
mcKicker._y = _ymouse;
} else {
posx = kickArea._x + (r1 * Math.cos(_local1));
posy = kickArea._y + (r2 * Math.sin(_local1));
if (Math.abs(posx - kickArea._x) < Math.abs(_xmouse - kickArea._x)) {
mcKicker._x = posx;
} else {
mcKicker._x = _xmouse;
}
mcKicker._y = posy;
}
};
btnReplay.onRelease = function () {
nosounds = true;
DoReplay();
};
btnNextLevel.onRelease = function () {
nosounds = false;
NextLevel();
};
Frame 106
function KickBall() {
kicker_yspeed = (kickArea._y - mcKicker._y) / 6;
kicker_xspeed = (kickArea._x - mcKicker._x) / 6;
state_aiming = false;
player_running = true;
ball_accelup = 6 - (DistanceBetween(mcKicker._x, mcKicker._y, kickArea._x, kickArea._y) / 7);
mcKicker.kicker.Run();
if (ball_accelup < 0) {
ball_accelup = 1;
}
}
function DistanceBetween(x1, y1, x2, y2) {
return(Math.sqrt(((x2 - x1) * (x2 - x1)) + ((y2 - y1) * (y2 - y1))));
}
function GetObstacle(oid) {
return(_root["obstacle" + oid]);
}
function AdjustDepths() {
if (((ballShadow._y > (goalKeeper._y - 2)) && (ball.getDepth() < goalKeeper.getDepth())) || ((ballShadow._y < (goalKeeper._y - 2)) && (ball.getDepth() > goalKeeper.getDepth()))) {
goalKeeper.swapDepths(ball);
}
}
function ChanceDone() {
if (!chance_done) {
chance_done = true;
EndOfChance();
}
}
function ResetItems() {
ball._x = kickArea._x;
ball._y = kickArea._y;
ball._xscale = 100;
ball._yscale = 100;
ballMover._x = kickArea._x;
ballMover._y = kickArea._y;
ballShadow._x = kickArea._x;
ballShadow._y = kickArea._y;
ballMover._visible = false;
extremeborder._visible = false;
flashAlerts.gotoAndStop(1);
flashAlerts._visible = false;
goalKeeper._x = goalPost._x;
goalKeeper._y = goalPost._y + 4;
goalKeeper.gotoAndStop(1);
state_aiming = true;
if (!nosounds) {
bgm4.start(0, 1);
}
player_running = false;
ball_in_play = false;
kicker_xspeed = 0;
kicker_yspeed = 0;
ball_height = 0;
ball_accelup = 0;
goal_done = false;
save_done = false;
save_checked = false;
target_follow_phase = 0;
if ((DistanceBetween(_xmouse, _ymouse, kickArea._x, kickArea._y) < (kickArea._width / 2)) && (_ymouse > kickArea._y)) {
hoveringAbove = true;
} else {
hoveringAbove = false;
}
i = 0;
while (i < NUM_OBSTACLES) {
GetObstacle(i).gotoAndStop(1);
i++;
}
mcWindDirection._rotation = windDirection;
if ((mcWindDirection._rotation > 90) || (mcWindDirection._rotation < -90)) {
mcWindDirection._rotation = 180;
} else {
mcWindDirection._rotation = 0;
}
wind_y = 0 * Math.sin((windDirection * Math.PI) / 180);
wind_x = 0.5 * Math.cos((windDirection * Math.PI) / 180);
txtWindSpeed.text = int(Math.abs(wind_x * 2) * 10) / 10;
if (txtWindSpeed.text == "0") {
mcWindDirection._rotation = -90;
}
goalPost.gotoAndStop(1);
chance_done = false;
}
function EndOfChance() {
var _local2 = goal_done;
if (_local2) {
if (interval_goalDone == 0) {
}
if (!isDoingReplay) {
_root.totalScore = _root.totalScore + currentScore;
_root["levelScore" + _root.currentLevel] = currentScore;
}
toolBar._visible = true;
toolBar.toolbarButtons.btnNextLevel._visible = true;
toolBar.toolbarButtons.btnRetry._visible = false;
btnNextLevel._visible = true;
toolBar.gotoAndPlay(1);
} else {
if (!isDoingReplay) {
_root.numChances--;
}
if (_root.numChances <= 0) {
nosounds = true;
if (interval_gameOver == 0) {
interval_gameOver = setInterval(GameOver, 2000);
}
} else {
if (interval_retry != 0) {
clearInterval(interval_retry);
interval_retry = 0;
}
trace("Setting Retry...");
interval_retry = setInterval(DoRetry, 2000);
}
}
}
function CalculateTargetX(ballx, bally, ballxspeed, ballyspeed, ylimit) {
if (((ballyspeed < 0) && (bally < ylimit)) || ((ballyspeed > 0) && (bally > ylimit))) {
return(-100);
}
if (ballyspeed < 0) {
while (bally > ylimit) {
bally = bally + ballyspeed;
ballx = ballx + ballxspeed;
}
} else {
while (bally < ylimit) {
bally = bally + ballyspeed;
ballx = ballx + ballxspeed;
}
}
return(ballx);
}
function DoRetry() {
if (interval_retry != 0) {
clearInterval(interval_retry);
interval_retry = 0;
}
nosounds = false;
ResetItems();
}
function DoReplay() {
if (ball_in_play && (!goal_done)) {
return(true);
}
if ((save_playerX == 0) && (save_playerY == 0)) {
return(undefined);
}
if (interval_retry != 0) {
clearInterval(interval_retry);
interval_retry = 0;
}
toolBar.play();
ResetItems();
mcKicker._x = save_playerX;
mcKicker._y = save_playerY;
mcKicker.gotoAndStop(save_playerFrame);
UpdateAngle();
isDoingReplay = true;
KickBall();
}
function NextLevel() {
GoalDone();
}
function GoalDone() {
ResetItems();
nextFrame();
}
function GameOver() {
clearInterval(interval_gameOver);
interval_gameOver = 0;
gotoAndStop ("gameover");
}
function UpdateAngle() {
}
stop();
NUM_OBSTACLES = 4;
_root.currentLevel = 4;
stopAllSounds();
var bgm = new Sound();
bgm.attachSound("cheer");
var bgm2 = new Sound();
bgm2.attachSound("miss");
var bgm3 = new Sound();
bgm3.attachSound("kick");
var bgm4 = new Sound();
bgm4.attachSound("whistle");
var bgm5 = new Sound(soundmovieclip2);
bgm5.attachSound("ballbounce");
var bgm6 = new Sound(soundmovieclip);
bgm6.attachSound("croud");
var firsttime = true;
var playedsound = false;
var nosounds = false;
bgm5.setVolume(30);
bgm6.setVolume(10);
bgm6.start(0, 1000);
bgm6.onSoundComplete = function () {
bgm6.start(0, 10000);
};
var state_aiming = true;
var player_running = false;
var ball_in_play = false;
var chance_done = false;
var hoveringAbove;
var kicker_xspeed = 0;
var kicker_yspeed = 0;
var ball_height = 0;
var ball_accelup = 0;
var goal_done = false;
var save_done = false;
var interval_ChanceTime = 0;
var target_follow_phase = 0;
var interval_goalDone = 0;
var interval_gameOver = 0;
var interval_retry = 0;
var save_checked = false;
scoreCard.gotoAndStop(1);
scoreCard._visible = false;
var currentScore = 0;
var r1 = 135;
var r2 = 65;
goalArea._x = goalPost._x;
goalArea._y = goalPost._y;
var keeper_speed = 1.5;
var gravity = 0.5;
var friction = 1.03;
var friction_gravity = 2;
var save_playerX = 0;
var save_playerY = 0;
var save_playerFrame = 0;
var isDoingReplay = false;
var windDirection = ((Math.random() * 360) - 180);
mcWindDirection._rotation = windDirection;
if ((mcWindDirection._rotation > 90) || (mcWindDirection._rotation < -90)) {
mcWindDirection._rotation = 180;
} else {
mcWindDirection._rotation = 0;
}
var wind_y = (0 * Math.sin((windDirection * Math.PI) / 180));
var wind_x = (0.5 * Math.cos((windDirection * Math.PI) / 180));
txtWindSpeed.text = int(Math.abs(wind_x * 2) * 10) / 10;
if (txtWindSpeed.text == "0") {
mcWindDirection._rotation = -90;
}
txtLevel.text = _root.currentLevel + "/10";
ball._x = kickArea._x;
ball._y = kickArea._y;
ballMover._visible = false;
extremeborder._visible = false;
flashAlerts.gotoAndStop(1);
flashAlerts._visible = false;
targetMarker._visible = false;
var mouseMoveLock = true;
toolBar.gotoAndStop(1);
btnNextLevel._visible = false;
i = 0;
while (i < NUM_OBSTACLES) {
GetObstacle(i).gotoAndStop(1);
i++;
}
goalPost.gotoAndStop(1);
kickArea.onRollOver = function () {
hoveringAbove = true;
};
kickArea.onDragOver = function () {
hoveringAbove = true;
};
ResetItems();
kickArea.onMouseMove = function () {
if (!mouseMoveLock) {
hoveringAbove = true;
mouseMoveLock = true;
}
};
kickArea.onRollOut = function () {
hoveringAbove = false;
};
kickArea.onDragOut = function () {
hoveringAbove = false;
};
kickArea.onRelease = function () {
if (state_aiming) {
save_playerX = mcKicker._x;
save_playerY = mcKicker._y;
save_playerFrame = mcKicker._currentframe;
isDoingReplay = false;
KickBall();
}
};
this.onEnterFrame = function () {
if (!state_aiming) {
if (player_running) {
mcKicker._x = mcKicker._x + kicker_xspeed;
mcKicker._y = mcKicker._y + kicker_yspeed;
if (DistanceBetween(mcKicker._x, mcKicker._y, kickArea._x, kickArea._y) <= 5) {
player_running = false;
mcKicker.kicker.gotoAndStop(1);
ball_in_play = true;
bgm3.start(0, 1);
ball_accelup = 6;
targetMarker._x = CalculateTargetX(ballMover._x, ballMover._y, kicker_xspeed, kicker_yspeed, targetMarker._y);
}
return(undefined);
}
if (ball_in_play) {
ballMover._x = ballMover._x + kicker_xspeed;
ballMover._y = ballMover._y + kicker_yspeed;
ball._rotation = ball._rotation + (kicker_xspeed * 10);
ball_height = ball_height + ball_accelup;
ball_accelup = ball_accelup - gravity;
if ((((ball_height > 3) && (ball_height < 8)) && (!playedsound)) && (ball_height < 6)) {
playedsound = true;
bgm5.start(0, 1);
}
if ((ball_accelup < 0) && (ball_height < 0)) {
playedsound = false;
ball_height = 0;
ball_accelup = -(ball_accelup / friction_gravity);
wind_x = wind_x / 5;
wind_y = wind_y / 5;
if (Math.abs(ball_accelup) <= 1) {
ball_accelup = 0;
ball_height = 0;
}
}
kicker_xspeed = kicker_xspeed / friction;
kicker_yspeed = kicker_yspeed / friction;
kicker_xspeed = kicker_xspeed + wind_x;
kicker_yspeed = kicker_yspeed + wind_y;
if (Math.abs(kicker_xspeed) < 0.1) {
kicker_xspeed = 0;
}
if (Math.abs(kicker_yspeed) < 0.1) {
kicker_yspeed = 0;
}
if ((Math.abs(kicker_xspeed) < 1) && (Math.abs(kicker_yspeed) < 1)) {
kicker_xspeed = 0;
kicker_yspeed = 0;
if (!chance_done) {
ChanceDone();
}
}
if (((ball._x > Stage.width) || (ball._x < 0)) || (ball._y > Stage.height)) {
if ((!chance_done) && (!goal_done)) {
ChanceDone();
}
}
ball._x = ballMover._x;
ball._y = ballMover._y - ball_height;
ball._xscale = ((ballMover._y - 30) / (mcKicker._y - 30)) * 100;
if (ball._xscale > 100) {
ball._xscale = 100;
}
ball._yscale = ball._xscale;
ballShadow._x = ballMover._x;
ballShadow._y = ballMover._y;
AdjustDepths();
if (kicker_yspeed < 0) {
jumpdetectrange = Math.abs(kicker_yspeed * 6);
if ((Math.abs(ballMover._y - goalKeeper._y) < jumpdetectrange) && (Math.abs(ballMover._x - goalKeeper._x) < 5)) {
if (ball_height > 10) {
goalKeeper.JumpDefend();
} else {
goalKeeper.Defend();
}
}
if ((target_follow_phase == 0) && (ballMover._y < (goalKeeper._y + (((mcKicker._y - goalKeeper._y) * 2) / 3)))) {
targetMarker._x = CalculateTargetX(ballMover._x, ballMover._y, kicker_xspeed, kicker_yspeed, targetMarker._y);
target_follow_phase = 1;
}
if ((target_follow_phase == 1) && (ballMover._y < (goalKeeper._y + ((mcKicker._y - goalKeeper._y) / 3)))) {
targetMarker._x = CalculateTargetX(ballMover._x, ballMover._y, kicker_xspeed, kicker_yspeed, targetMarker._y);
target_follow_phase = 2;
}
if (((target_follow_phase == 2) && (!goalKeeper.isJumping())) && (Math.abs(targetMarker._x - goalKeeper._x) > 20)) {
if (targetMarker._x < goalKeeper._x) {
goalKeeper.JumpLeft();
} else {
goalKeeper.JumpRight();
}
}
if (targetMarker._x < (goalKeeper._x - keeper_speed)) {
if (!goalKeeper.isJumping()) {
goalKeeper._x = goalKeeper._x - keeper_speed;
} else {
goalKeeper._x = goalKeeper._x - (keeper_speed / 2);
}
goalKeeper.Walk();
} else if (targetMarker._x > (goalKeeper._x + keeper_speed)) {
if (!goalKeeper.isJumping()) {
goalKeeper._x = goalKeeper._x + keeper_speed;
} else {
goalKeeper._x = goalKeeper._x + (keeper_speed / 2);
}
goalKeeper.Walk();
} else {
goalKeeper.StopMotion();
}
} else {
goalKeeper.StopMotion();
}
if (ballMover._y <= extremeborder._y) {
kicker_yspeed = Math.abs(kicker_yspeed);
kicker_yspeed = kicker_yspeed / 2;
if (kicker_yspeed > 2) {
kicker_yspeed = 2;
}
kicker_xspeed = kicker_xspeed / 2;
wind_x = wind_x / 8;
wind_y = wind_y / 8;
if (!nosounds) {
bgm2.start(0, 1);
nosounds = true;
}
}
if ((((!save_done) && (!goal_done)) && (ballMover._y >= goalKeeper._y)) && ((ballMover._y + kicker_yspeed) <= goalKeeper._y)) {
save_checked = true;
if (com.gskinner.sprites.CollisionDetection.checkForCollision(ball, goalKeeper)) {
kicker_yspeed = Math.abs(kicker_yspeed);
kicker_yspeed = kicker_yspeed / 7;
if (!flashAlerts._visible) {
flashAlerts._visible = true;
if (!nosounds) {
bgm2.start(0, 1);
nosounds = true;
}
flashAlerts.gotoAndPlay("save");
save_done = true;
}
wind_x = 0;
wind_y = 0;
}
}
if (((((save_checked && (!goal_done)) && (kicker_yspeed < 0)) && ((goalPost._y - ballMover._y) > 0)) && ((goalPost._y - ballMover._y) < 10)) && (ballMover.hitTest(goalArea))) {
flashAlerts._visible = true;
if (!nosounds) {
bgm.start(0, 1);
nosounds = true;
}
flashAlerts.gotoAndPlay("goal");
kicker_xspeed = 0;
kicker_yspeed = 0.2;
goalPost.gotoAndPlay(1);
goal_done = true;
currentScore = int(DistanceBetween(ball._x, ball._y, goalKeeper._x, goalKeeper._y));
scoreCard.scoreDisplay.txtScore.text = currentScore;
scoreCard._x = ball._x + 50;
scoreCard._y = ball._y;
scoreCard._visible = true;
scoreCard.gotoAndPlay(1);
wind_x = 0;
wind_y = 0;
}
if (kicker_yspeed < 0) {
i = 0;
while (i < NUM_OBSTACLES) {
if ((Math.abs(GetObstacle(i)._y - ballMover._y) < 2) && (com.gskinner.sprites.CollisionDetection.checkForCollision(ball, GetObstacle(i)))) {
kicker_yspeed = -kicker_yspeed;
GetObstacle(i).gotoAndPlay(1);
if (!nosounds) {
bgm2.start(0, 1);
nosounds = true;
}
break;
}
i++;
}
}
}
return(undefined);
}
var _local1 = Math.atan2(_ymouse - kickArea._y, _xmouse - kickArea._x);
var _local2 = _local1;
if (_local1 < 0) {
if (_local1 < -1.5707963267949) {
_local1 = -3.14159265358979;
} else {
_local1 = 0;
}
_local2 = -_local1;
}
mcArrow._rotation = (_local1 * 180) / Math.PI;
if (_local2 > 2.51327412287183) {
mcKicker.gotoAndStop(5);
} else if (_local2 > 1.88495559215388) {
mcKicker.gotoAndStop(4);
} else if (_local2 > 1.25663706143592) {
mcKicker.gotoAndStop(3);
} else if (_local2 > 0.628318530717959) {
mcKicker.gotoAndStop(2);
} else {
mcKicker.gotoAndStop(1);
}
if (hoveringAbove) {
mcKicker._x = _xmouse;
mcKicker._y = _ymouse;
} else {
posx = kickArea._x + (r1 * Math.cos(_local1));
posy = kickArea._y + (r2 * Math.sin(_local1));
if (Math.abs(posx - kickArea._x) < Math.abs(_xmouse - kickArea._x)) {
mcKicker._x = posx;
} else {
mcKicker._x = _xmouse;
}
mcKicker._y = posy;
}
};
btnReplay.onRelease = function () {
nosounds = true;
DoReplay();
};
btnNextLevel.onRelease = function () {
nosounds = false;
NextLevel();
};
Frame 107
function KickBall() {
kicker_yspeed = (kickArea._y - mcKicker._y) / 6;
kicker_xspeed = (kickArea._x - mcKicker._x) / 6;
state_aiming = false;
player_running = true;
ball_accelup = 6 - (DistanceBetween(mcKicker._x, mcKicker._y, kickArea._x, kickArea._y) / 7);
mcKicker.kicker.Run();
if (ball_accelup < 0) {
ball_accelup = 1;
}
}
function DistanceBetween(x1, y1, x2, y2) {
return(Math.sqrt(((x2 - x1) * (x2 - x1)) + ((y2 - y1) * (y2 - y1))));
}
function GetObstacle(oid) {
return(_root["obstacle" + oid]);
}
function AdjustDepths() {
if (((ballShadow._y > (goalKeeper._y - 2)) && (ball.getDepth() < goalKeeper.getDepth())) || ((ballShadow._y < (goalKeeper._y - 2)) && (ball.getDepth() > goalKeeper.getDepth()))) {
goalKeeper.swapDepths(ball);
}
}
function ChanceDone() {
if (!chance_done) {
chance_done = true;
EndOfChance();
}
}
function ResetItems() {
ball._x = kickArea._x;
ball._y = kickArea._y;
ball._xscale = 100;
ball._yscale = 100;
ballMover._x = kickArea._x;
ballMover._y = kickArea._y;
ballShadow._x = kickArea._x;
ballShadow._y = kickArea._y;
ballMover._visible = false;
extremeborder._visible = false;
flashAlerts.gotoAndStop(1);
flashAlerts._visible = false;
goalKeeper._x = goalPost._x;
goalKeeper._y = goalPost._y + 4;
goalKeeper.gotoAndStop(1);
state_aiming = true;
if (!nosounds) {
bgm4.start(0, 1);
}
player_running = false;
ball_in_play = false;
kicker_xspeed = 0;
kicker_yspeed = 0;
ball_height = 0;
ball_accelup = 0;
goal_done = false;
save_done = false;
save_checked = false;
target_follow_phase = 0;
if ((DistanceBetween(_xmouse, _ymouse, kickArea._x, kickArea._y) < (kickArea._width / 2)) && (_ymouse > kickArea._y)) {
hoveringAbove = true;
} else {
hoveringAbove = false;
}
i = 0;
while (i < NUM_OBSTACLES) {
GetObstacle(i).gotoAndStop(1);
i++;
}
mcWindDirection._rotation = windDirection;
if ((mcWindDirection._rotation > 90) || (mcWindDirection._rotation < -90)) {
mcWindDirection._rotation = 180;
} else {
mcWindDirection._rotation = 0;
}
wind_y = 0 * Math.sin((windDirection * Math.PI) / 180);
wind_x = 0.5 * Math.cos((windDirection * Math.PI) / 180);
txtWindSpeed.text = int(Math.abs(wind_x * 2) * 10) / 10;
if (txtWindSpeed.text == "0") {
mcWindDirection._rotation = -90;
}
goalPost.gotoAndStop(1);
chance_done = false;
}
function EndOfChance() {
var _local2 = goal_done;
if (_local2) {
if (interval_goalDone == 0) {
}
if (!isDoingReplay) {
_root.totalScore = _root.totalScore + currentScore;
_root["levelScore" + _root.currentLevel] = currentScore;
}
toolBar._visible = true;
toolBar.toolbarButtons.btnNextLevel._visible = true;
toolBar.toolbarButtons.btnRetry._visible = false;
btnNextLevel._visible = true;
toolBar.gotoAndPlay(1);
} else {
if (!isDoingReplay) {
_root.numChances--;
}
if (_root.numChances <= 0) {
nosounds = true;
if (interval_gameOver == 0) {
interval_gameOver = setInterval(GameOver, 2000);
}
} else {
if (interval_retry != 0) {
clearInterval(interval_retry);
interval_retry = 0;
}
trace("Setting Retry...");
interval_retry = setInterval(DoRetry, 2000);
}
}
}
function CalculateTargetX(ballx, bally, ballxspeed, ballyspeed, ylimit) {
if (((ballyspeed < 0) && (bally < ylimit)) || ((ballyspeed > 0) && (bally > ylimit))) {
return(-100);
}
if (ballyspeed < 0) {
while (bally > ylimit) {
bally = bally + ballyspeed;
ballx = ballx + ballxspeed;
}
} else {
while (bally < ylimit) {
bally = bally + ballyspeed;
ballx = ballx + ballxspeed;
}
}
return(ballx);
}
function DoRetry() {
if (interval_retry != 0) {
clearInterval(interval_retry);
interval_retry = 0;
}
nosounds = false;
ResetItems();
}
function DoReplay() {
if (ball_in_play && (!goal_done)) {
return(true);
}
if ((save_playerX == 0) && (save_playerY == 0)) {
return(undefined);
}
if (interval_retry != 0) {
clearInterval(interval_retry);
interval_retry = 0;
}
toolBar.play();
ResetItems();
mcKicker._x = save_playerX;
mcKicker._y = save_playerY;
mcKicker.gotoAndStop(save_playerFrame);
UpdateAngle();
isDoingReplay = true;
KickBall();
}
function NextLevel() {
GoalDone();
}
function GoalDone() {
ResetItems();
nextFrame();
}
function GameOver() {
clearInterval(interval_gameOver);
interval_gameOver = 0;
gotoAndStop ("gameover");
}
function UpdateAngle() {
}
stop();
NUM_OBSTACLES = 5;
_root.currentLevel = 5;
stopAllSounds();
var bgm = new Sound();
bgm.attachSound("cheer");
var bgm2 = new Sound();
bgm2.attachSound("miss");
var bgm3 = new Sound();
bgm3.attachSound("kick");
var bgm4 = new Sound();
bgm4.attachSound("whistle");
var bgm5 = new Sound(soundmovieclip2);
bgm5.attachSound("ballbounce");
var bgm6 = new Sound(soundmovieclip);
bgm6.attachSound("croud");
var firsttime = true;
var playedsound = false;
var nosounds = false;
bgm5.setVolume(30);
bgm6.setVolume(10);
bgm6.start(0, 1000);
bgm6.onSoundComplete = function () {
bgm6.start(0, 10000);
};
var state_aiming = true;
var player_running = false;
var ball_in_play = false;
var chance_done = false;
var hoveringAbove;
var kicker_xspeed = 0;
var kicker_yspeed = 0;
var ball_height = 0;
var ball_accelup = 0;
var goal_done = false;
var save_done = false;
var interval_ChanceTime = 0;
var target_follow_phase = 0;
var interval_goalDone = 0;
var interval_gameOver = 0;
var interval_retry = 0;
var save_checked = false;
scoreCard.gotoAndStop(1);
scoreCard._visible = false;
var currentScore = 0;
var r1 = 135;
var r2 = 65;
goalArea._x = goalPost._x;
goalArea._y = goalPost._y;
var keeper_speed = 1.5;
var gravity = 0.5;
var friction = 1.03;
var friction_gravity = 2;
var save_playerX = 0;
var save_playerY = 0;
var save_playerFrame = 0;
var isDoingReplay = false;
var windDirection = ((Math.random() * 360) - 180);
mcWindDirection._rotation = windDirection;
if ((mcWindDirection._rotation > 90) || (mcWindDirection._rotation < -90)) {
mcWindDirection._rotation = 180;
} else {
mcWindDirection._rotation = 0;
}
var wind_y = (0 * Math.sin((windDirection * Math.PI) / 180));
var wind_x = (0.5 * Math.cos((windDirection * Math.PI) / 180));
txtWindSpeed.text = int(Math.abs(wind_x * 2) * 10) / 10;
if (txtWindSpeed.text == "0") {
mcWindDirection._rotation = -90;
}
txtLevel.text = _root.currentLevel + "/10";
ball._x = kickArea._x;
ball._y = kickArea._y;
ballMover._visible = false;
extremeborder._visible = false;
flashAlerts.gotoAndStop(1);
flashAlerts._visible = false;
targetMarker._visible = false;
var mouseMoveLock = true;
toolBar.gotoAndStop(1);
btnNextLevel._visible = false;
i = 0;
while (i < NUM_OBSTACLES) {
GetObstacle(i).gotoAndStop(1);
i++;
}
goalPost.gotoAndStop(1);
kickArea.onRollOver = function () {
hoveringAbove = true;
};
kickArea.onDragOver = function () {
hoveringAbove = true;
};
ResetItems();
kickArea.onMouseMove = function () {
if (!mouseMoveLock) {
hoveringAbove = true;
mouseMoveLock = true;
}
};
kickArea.onRollOut = function () {
hoveringAbove = false;
};
kickArea.onDragOut = function () {
hoveringAbove = false;
};
kickArea.onRelease = function () {
if (state_aiming) {
save_playerX = mcKicker._x;
save_playerY = mcKicker._y;
save_playerFrame = mcKicker._currentframe;
isDoingReplay = false;
KickBall();
}
};
this.onEnterFrame = function () {
if (!state_aiming) {
if (player_running) {
mcKicker._x = mcKicker._x + kicker_xspeed;
mcKicker._y = mcKicker._y + kicker_yspeed;
if (DistanceBetween(mcKicker._x, mcKicker._y, kickArea._x, kickArea._y) <= 5) {
player_running = false;
mcKicker.kicker.gotoAndStop(1);
ball_in_play = true;
bgm3.start(0, 1);
ball_accelup = 6;
targetMarker._x = CalculateTargetX(ballMover._x, ballMover._y, kicker_xspeed, kicker_yspeed, targetMarker._y);
}
return(undefined);
}
if (ball_in_play) {
ballMover._x = ballMover._x + kicker_xspeed;
ballMover._y = ballMover._y + kicker_yspeed;
ball._rotation = ball._rotation + (kicker_xspeed * 10);
ball_height = ball_height + ball_accelup;
ball_accelup = ball_accelup - gravity;
if ((((ball_height > 3) && (ball_height < 8)) && (!playedsound)) && (ball_height < 6)) {
playedsound = true;
bgm5.start(0, 1);
}
if ((ball_accelup < 0) && (ball_height < 0)) {
playedsound = false;
ball_height = 0;
ball_accelup = -(ball_accelup / friction_gravity);
wind_x = wind_x / 5;
wind_y = wind_y / 5;
if (Math.abs(ball_accelup) <= 1) {
ball_accelup = 0;
ball_height = 0;
}
}
kicker_xspeed = kicker_xspeed / friction;
kicker_yspeed = kicker_yspeed / friction;
kicker_xspeed = kicker_xspeed + wind_x;
kicker_yspeed = kicker_yspeed + wind_y;
if (Math.abs(kicker_xspeed) < 0.1) {
kicker_xspeed = 0;
}
if (Math.abs(kicker_yspeed) < 0.1) {
kicker_yspeed = 0;
}
if ((Math.abs(kicker_xspeed) < 1) && (Math.abs(kicker_yspeed) < 1)) {
kicker_xspeed = 0;
kicker_yspeed = 0;
if (!chance_done) {
ChanceDone();
}
}
if (((ball._x > Stage.width) || (ball._x < 0)) || (ball._y > Stage.height)) {
if ((!chance_done) && (!goal_done)) {
ChanceDone();
}
}
ball._x = ballMover._x;
ball._y = ballMover._y - ball_height;
ball._xscale = ((ballMover._y - 30) / (mcKicker._y - 30)) * 100;
if (ball._xscale > 100) {
ball._xscale = 100;
}
ball._yscale = ball._xscale;
ballShadow._x = ballMover._x;
ballShadow._y = ballMover._y;
AdjustDepths();
if (kicker_yspeed < 0) {
jumpdetectrange = Math.abs(kicker_yspeed * 6);
if ((Math.abs(ballMover._y - goalKeeper._y) < jumpdetectrange) && (Math.abs(ballMover._x - goalKeeper._x) < 5)) {
if (ball_height > 10) {
goalKeeper.JumpDefend();
} else {
goalKeeper.Defend();
}
}
if ((target_follow_phase == 0) && (ballMover._y < (goalKeeper._y + (((mcKicker._y - goalKeeper._y) * 2) / 3)))) {
targetMarker._x = CalculateTargetX(ballMover._x, ballMover._y, kicker_xspeed, kicker_yspeed, targetMarker._y);
target_follow_phase = 1;
}
if ((target_follow_phase == 1) && (ballMover._y < (goalKeeper._y + ((mcKicker._y - goalKeeper._y) / 3)))) {
targetMarker._x = CalculateTargetX(ballMover._x, ballMover._y, kicker_xspeed, kicker_yspeed, targetMarker._y);
target_follow_phase = 2;
}
if (((target_follow_phase == 2) && (!goalKeeper.isJumping())) && (Math.abs(targetMarker._x - goalKeeper._x) > 20)) {
if (targetMarker._x < goalKeeper._x) {
goalKeeper.JumpLeft();
} else {
goalKeeper.JumpRight();
}
}
if (targetMarker._x < (goalKeeper._x - keeper_speed)) {
if (!goalKeeper.isJumping()) {
goalKeeper._x = goalKeeper._x - keeper_speed;
} else {
goalKeeper._x = goalKeeper._x - (keeper_speed / 2);
}
goalKeeper.Walk();
} else if (targetMarker._x > (goalKeeper._x + keeper_speed)) {
if (!goalKeeper.isJumping()) {
goalKeeper._x = goalKeeper._x + keeper_speed;
} else {
goalKeeper._x = goalKeeper._x + (keeper_speed / 2);
}
goalKeeper.Walk();
} else {
goalKeeper.StopMotion();
}
} else {
goalKeeper.StopMotion();
}
if (ballMover._y <= extremeborder._y) {
kicker_yspeed = Math.abs(kicker_yspeed);
kicker_yspeed = kicker_yspeed / 2;
if (kicker_yspeed > 2) {
kicker_yspeed = 2;
}
kicker_xspeed = kicker_xspeed / 2;
wind_x = wind_x / 8;
wind_y = wind_y / 8;
if (!nosounds) {
bgm2.start(0, 1);
nosounds = true;
}
}
if ((((!save_done) && (!goal_done)) && (ballMover._y >= goalKeeper._y)) && ((ballMover._y + kicker_yspeed) <= goalKeeper._y)) {
save_checked = true;
if (com.gskinner.sprites.CollisionDetection.checkForCollision(ball, goalKeeper)) {
kicker_yspeed = Math.abs(kicker_yspeed);
kicker_yspeed = kicker_yspeed / 7;
if (!flashAlerts._visible) {
flashAlerts._visible = true;
if (!nosounds) {
bgm2.start(0, 1);
nosounds = true;
}
flashAlerts.gotoAndPlay("save");
save_done = true;
}
wind_x = 0;
wind_y = 0;
}
}
if (((((save_checked && (!goal_done)) && (kicker_yspeed < 0)) && ((goalPost._y - ballMover._y) > 0)) && ((goalPost._y - ballMover._y) < 10)) && (ballMover.hitTest(goalArea))) {
flashAlerts._visible = true;
if (!nosounds) {
bgm.start(0, 1);
nosounds = true;
}
flashAlerts.gotoAndPlay("goal");
kicker_xspeed = 0;
kicker_yspeed = 0.2;
goalPost.gotoAndPlay(1);
goal_done = true;
currentScore = int(DistanceBetween(ball._x, ball._y, goalKeeper._x, goalKeeper._y));
scoreCard.scoreDisplay.txtScore.text = currentScore;
scoreCard._x = ball._x + 50;
scoreCard._y = ball._y;
scoreCard._visible = true;
scoreCard.gotoAndPlay(1);
wind_x = 0;
wind_y = 0;
}
if (kicker_yspeed < 0) {
i = 0;
while (i < NUM_OBSTACLES) {
if ((Math.abs(GetObstacle(i)._y - ballMover._y) < 2) && (com.gskinner.sprites.CollisionDetection.checkForCollision(ball, GetObstacle(i)))) {
kicker_yspeed = -kicker_yspeed;
GetObstacle(i).gotoAndPlay(1);
if (!nosounds) {
bgm2.start(0, 1);
nosounds = true;
}
break;
}
i++;
}
}
}
return(undefined);
}
var _local1 = Math.atan2(_ymouse - kickArea._y, _xmouse - kickArea._x);
var _local2 = _local1;
if (_local1 < 0) {
if (_local1 < -1.5707963267949) {
_local1 = -3.14159265358979;
} else {
_local1 = 0;
}
_local2 = -_local1;
}
mcArrow._rotation = (_local1 * 180) / Math.PI;
if (_local2 > 2.51327412287183) {
mcKicker.gotoAndStop(5);
} else if (_local2 > 1.88495559215388) {
mcKicker.gotoAndStop(4);
} else if (_local2 > 1.25663706143592) {
mcKicker.gotoAndStop(3);
} else if (_local2 > 0.628318530717959) {
mcKicker.gotoAndStop(2);
} else {
mcKicker.gotoAndStop(1);
}
if (hoveringAbove) {
mcKicker._x = _xmouse;
mcKicker._y = _ymouse;
} else {
posx = kickArea._x + (r1 * Math.cos(_local1));
posy = kickArea._y + (r2 * Math.sin(_local1));
if (Math.abs(posx - kickArea._x) < Math.abs(_xmouse - kickArea._x)) {
mcKicker._x = posx;
} else {
mcKicker._x = _xmouse;
}
mcKicker._y = posy;
}
};
btnReplay.onRelease = function () {
nosounds = true;
DoReplay();
};
btnNextLevel.onRelease = function () {
nosounds = false;
NextLevel();
};
Frame 108
function KickBall() {
kicker_yspeed = (kickArea._y - mcKicker._y) / 6;
kicker_xspeed = (kickArea._x - mcKicker._x) / 6;
state_aiming = false;
player_running = true;
ball_accelup = 6 - (DistanceBetween(mcKicker._x, mcKicker._y, kickArea._x, kickArea._y) / 7);
mcKicker.kicker.Run();
if (ball_accelup < 0) {
ball_accelup = 1;
}
}
function DistanceBetween(x1, y1, x2, y2) {
return(Math.sqrt(((x2 - x1) * (x2 - x1)) + ((y2 - y1) * (y2 - y1))));
}
function GetObstacle(oid) {
return(_root["obstacle" + oid]);
}
function AdjustDepths() {
if (((ballShadow._y > (goalKeeper._y - 2)) && (ball.getDepth() < goalKeeper.getDepth())) || ((ballShadow._y < (goalKeeper._y - 2)) && (ball.getDepth() > goalKeeper.getDepth()))) {
goalKeeper.swapDepths(ball);
}
}
function ChanceDone() {
if (!chance_done) {
chance_done = true;
EndOfChance();
}
}
function ResetItems() {
ball._x = kickArea._x;
ball._y = kickArea._y;
ball._xscale = 100;
ball._yscale = 100;
ballMover._x = kickArea._x;
ballMover._y = kickArea._y;
ballShadow._x = kickArea._x;
ballShadow._y = kickArea._y;
ballMover._visible = false;
extremeborder._visible = false;
flashAlerts.gotoAndStop(1);
flashAlerts._visible = false;
goalKeeper._x = goalPost._x;
goalKeeper._y = goalPost._y + 4;
goalKeeper.gotoAndStop(1);
state_aiming = true;
if (!nosounds) {
bgm4.start(0, 1);
}
player_running = false;
ball_in_play = false;
kicker_xspeed = 0;
kicker_yspeed = 0;
ball_height = 0;
ball_accelup = 0;
goal_done = false;
save_done = false;
save_checked = false;
target_follow_phase = 0;
if ((DistanceBetween(_xmouse, _ymouse, kickArea._x, kickArea._y) < (kickArea._width / 2)) && (_ymouse > kickArea._y)) {
hoveringAbove = true;
} else {
hoveringAbove = false;
}
i = 0;
while (i < NUM_OBSTACLES) {
GetObstacle(i).gotoAndStop(1);
i++;
}
mcWindDirection._rotation = windDirection;
if ((mcWindDirection._rotation > 90) || (mcWindDirection._rotation < -90)) {
mcWindDirection._rotation = 180;
} else {
mcWindDirection._rotation = 0;
}
wind_y = 0 * Math.sin((windDirection * Math.PI) / 180);
wind_x = 0.5 * Math.cos((windDirection * Math.PI) / 180);
txtWindSpeed.text = int(Math.abs(wind_x * 2) * 10) / 10;
if (txtWindSpeed.text == "0") {
mcWindDirection._rotation = -90;
}
goalPost.gotoAndStop(1);
chance_done = false;
}
function EndOfChance() {
var _local2 = goal_done;
if (_local2) {
if (interval_goalDone == 0) {
}
if (!isDoingReplay) {
_root.totalScore = _root.totalScore + currentScore;
_root["levelScore" + _root.currentLevel] = currentScore;
}
toolBar._visible = true;
toolBar.toolbarButtons.btnNextLevel._visible = true;
toolBar.toolbarButtons.btnRetry._visible = false;
btnNextLevel._visible = true;
toolBar.gotoAndPlay(1);
} else {
if (!isDoingReplay) {
_root.numChances--;
}
if (_root.numChances <= 0) {
nosounds = true;
if (interval_gameOver == 0) {
interval_gameOver = setInterval(GameOver, 2000);
}
} else {
if (interval_retry != 0) {
clearInterval(interval_retry);
interval_retry = 0;
}
trace("Setting Retry...");
interval_retry = setInterval(DoRetry, 2000);
}
}
}
function CalculateTargetX(ballx, bally, ballxspeed, ballyspeed, ylimit) {
if (((ballyspeed < 0) && (bally < ylimit)) || ((ballyspeed > 0) && (bally > ylimit))) {
return(-100);
}
if (ballyspeed < 0) {
while (bally > ylimit) {
bally = bally + ballyspeed;
ballx = ballx + ballxspeed;
}
} else {
while (bally < ylimit) {
bally = bally + ballyspeed;
ballx = ballx + ballxspeed;
}
}
return(ballx);
}
function DoRetry() {
if (interval_retry != 0) {
clearInterval(interval_retry);
interval_retry = 0;
}
nosounds = false;
ResetItems();
}
function DoReplay() {
if (ball_in_play && (!goal_done)) {
return(true);
}
if ((save_playerX == 0) && (save_playerY == 0)) {
return(undefined);
}
if (interval_retry != 0) {
clearInterval(interval_retry);
interval_retry = 0;
}
toolBar.play();
ResetItems();
mcKicker._x = save_playerX;
mcKicker._y = save_playerY;
mcKicker.gotoAndStop(save_playerFrame);
UpdateAngle();
isDoingReplay = true;
KickBall();
}
function NextLevel() {
GoalDone();
}
function GoalDone() {
ResetItems();
nextFrame();
}
function GameOver() {
clearInterval(interval_gameOver);
interval_gameOver = 0;
gotoAndStop ("gameover");
}
function UpdateAngle() {
}
stop();
NUM_OBSTACLES = 4;
_root.currentLevel = 6;
stopAllSounds();
var bgm = new Sound();
bgm.attachSound("cheer");
var bgm2 = new Sound();
bgm2.attachSound("miss");
var bgm3 = new Sound();
bgm3.attachSound("kick");
var bgm4 = new Sound();
bgm4.attachSound("whistle");
var bgm5 = new Sound(soundmovieclip2);
bgm5.attachSound("ballbounce");
var bgm6 = new Sound(soundmovieclip);
bgm6.attachSound("croud");
var firsttime = true;
var playedsound = false;
var nosounds = false;
bgm5.setVolume(30);
bgm6.setVolume(10);
bgm6.start(0, 1000);
bgm6.onSoundComplete = function () {
bgm6.start(0, 10000);
};
var state_aiming = true;
var player_running = false;
var ball_in_play = false;
var chance_done = false;
var hoveringAbove;
var kicker_xspeed = 0;
var kicker_yspeed = 0;
var ball_height = 0;
var ball_accelup = 0;
var goal_done = false;
var save_done = false;
var interval_ChanceTime = 0;
var target_follow_phase = 0;
var interval_goalDone = 0;
var interval_gameOver = 0;
var interval_retry = 0;
var save_checked = false;
scoreCard.gotoAndStop(1);
scoreCard._visible = false;
var currentScore = 0;
var r1 = 135;
var r2 = 65;
goalArea._x = goalPost._x;
goalArea._y = goalPost._y;
var keeper_speed = 1.5;
var gravity = 0.5;
var friction = 1.03;
var friction_gravity = 2;
var save_playerX = 0;
var save_playerY = 0;
var save_playerFrame = 0;
var isDoingReplay = false;
var windDirection = ((Math.random() * 360) - 180);
mcWindDirection._rotation = windDirection;
if ((mcWindDirection._rotation > 90) || (mcWindDirection._rotation < -90)) {
mcWindDirection._rotation = 180;
} else {
mcWindDirection._rotation = 0;
}
var wind_y = (0 * Math.sin((windDirection * Math.PI) / 180));
var wind_x = (0.5 * Math.cos((windDirection * Math.PI) / 180));
txtWindSpeed.text = int(Math.abs(wind_x * 2) * 10) / 10;
if (txtWindSpeed.text == "0") {
mcWindDirection._rotation = -90;
}
txtLevel.text = _root.currentLevel + "/10";
ball._x = kickArea._x;
ball._y = kickArea._y;
ballMover._visible = false;
extremeborder._visible = false;
flashAlerts.gotoAndStop(1);
flashAlerts._visible = false;
targetMarker._visible = false;
var mouseMoveLock = true;
toolBar.gotoAndStop(1);
btnNextLevel._visible = false;
i = 0;
while (i < NUM_OBSTACLES) {
GetObstacle(i).gotoAndStop(1);
i++;
}
goalPost.gotoAndStop(1);
kickArea.onRollOver = function () {
hoveringAbove = true;
};
kickArea.onDragOver = function () {
hoveringAbove = true;
};
ResetItems();
kickArea.onMouseMove = function () {
if (!mouseMoveLock) {
hoveringAbove = true;
mouseMoveLock = true;
}
};
kickArea.onRollOut = function () {
hoveringAbove = false;
};
kickArea.onDragOut = function () {
hoveringAbove = false;
};
kickArea.onRelease = function () {
if (state_aiming) {
save_playerX = mcKicker._x;
save_playerY = mcKicker._y;
save_playerFrame = mcKicker._currentframe;
isDoingReplay = false;
KickBall();
}
};
this.onEnterFrame = function () {
if (!state_aiming) {
if (player_running) {
mcKicker._x = mcKicker._x + kicker_xspeed;
mcKicker._y = mcKicker._y + kicker_yspeed;
if (DistanceBetween(mcKicker._x, mcKicker._y, kickArea._x, kickArea._y) <= 5) {
player_running = false;
mcKicker.kicker.gotoAndStop(1);
ball_in_play = true;
bgm3.start(0, 1);
ball_accelup = 6;
targetMarker._x = CalculateTargetX(ballMover._x, ballMover._y, kicker_xspeed, kicker_yspeed, targetMarker._y);
}
return(undefined);
}
if (ball_in_play) {
ballMover._x = ballMover._x + kicker_xspeed;
ballMover._y = ballMover._y + kicker_yspeed;
ball._rotation = ball._rotation + (kicker_xspeed * 10);
ball_height = ball_height + ball_accelup;
ball_accelup = ball_accelup - gravity;
if ((((ball_height > 3) && (ball_height < 8)) && (!playedsound)) && (ball_height < 6)) {
playedsound = true;
bgm5.start(0, 1);
}
if ((ball_accelup < 0) && (ball_height < 0)) {
playedsound = false;
ball_height = 0;
ball_accelup = -(ball_accelup / friction_gravity);
wind_x = wind_x / 5;
wind_y = wind_y / 5;
if (Math.abs(ball_accelup) <= 1) {
ball_accelup = 0;
ball_height = 0;
}
}
kicker_xspeed = kicker_xspeed / friction;
kicker_yspeed = kicker_yspeed / friction;
kicker_xspeed = kicker_xspeed + wind_x;
kicker_yspeed = kicker_yspeed + wind_y;
if (Math.abs(kicker_xspeed) < 0.1) {
kicker_xspeed = 0;
}
if (Math.abs(kicker_yspeed) < 0.1) {
kicker_yspeed = 0;
}
if ((Math.abs(kicker_xspeed) < 1) && (Math.abs(kicker_yspeed) < 1)) {
kicker_xspeed = 0;
kicker_yspeed = 0;
if (!chance_done) {
ChanceDone();
}
}
if (((ball._x > Stage.width) || (ball._x < 0)) || (ball._y > Stage.height)) {
if ((!chance_done) && (!goal_done)) {
ChanceDone();
}
}
ball._x = ballMover._x;
ball._y = ballMover._y - ball_height;
ball._xscale = ((ballMover._y - 30) / (mcKicker._y - 30)) * 100;
if (ball._xscale > 100) {
ball._xscale = 100;
}
ball._yscale = ball._xscale;
ballShadow._x = ballMover._x;
ballShadow._y = ballMover._y;
AdjustDepths();
if (kicker_yspeed < 0) {
jumpdetectrange = Math.abs(kicker_yspeed * 6);
if ((Math.abs(ballMover._y - goalKeeper._y) < jumpdetectrange) && (Math.abs(ballMover._x - goalKeeper._x) < 5)) {
if (ball_height > 10) {
goalKeeper.JumpDefend();
} else {
goalKeeper.Defend();
}
}
if ((target_follow_phase == 0) && (ballMover._y < (goalKeeper._y + (((mcKicker._y - goalKeeper._y) * 2) / 3)))) {
targetMarker._x = CalculateTargetX(ballMover._x, ballMover._y, kicker_xspeed, kicker_yspeed, targetMarker._y);
target_follow_phase = 1;
}
if ((target_follow_phase == 1) && (ballMover._y < (goalKeeper._y + ((mcKicker._y - goalKeeper._y) / 3)))) {
targetMarker._x = CalculateTargetX(ballMover._x, ballMover._y, kicker_xspeed, kicker_yspeed, targetMarker._y);
target_follow_phase = 2;
}
if (((target_follow_phase == 2) && (!goalKeeper.isJumping())) && (Math.abs(targetMarker._x - goalKeeper._x) > 20)) {
if (targetMarker._x < goalKeeper._x) {
goalKeeper.JumpLeft();
} else {
goalKeeper.JumpRight();
}
}
if (targetMarker._x < (goalKeeper._x - keeper_speed)) {
if (!goalKeeper.isJumping()) {
goalKeeper._x = goalKeeper._x - keeper_speed;
} else {
goalKeeper._x = goalKeeper._x - (keeper_speed / 2);
}
goalKeeper.Walk();
} else if (targetMarker._x > (goalKeeper._x + keeper_speed)) {
if (!goalKeeper.isJumping()) {
goalKeeper._x = goalKeeper._x + keeper_speed;
} else {
goalKeeper._x = goalKeeper._x + (keeper_speed / 2);
}
goalKeeper.Walk();
} else {
goalKeeper.StopMotion();
}
} else {
goalKeeper.StopMotion();
}
if (ballMover._y <= extremeborder._y) {
kicker_yspeed = Math.abs(kicker_yspeed);
kicker_yspeed = kicker_yspeed / 2;
if (kicker_yspeed > 2) {
kicker_yspeed = 2;
}
kicker_xspeed = kicker_xspeed / 2;
wind_x = wind_x / 8;
wind_y = wind_y / 8;
if (!nosounds) {
bgm2.start(0, 1);
nosounds = true;
}
}
if ((((!save_done) && (!goal_done)) && (ballMover._y >= goalKeeper._y)) && ((ballMover._y + kicker_yspeed) <= goalKeeper._y)) {
save_checked = true;
if (com.gskinner.sprites.CollisionDetection.checkForCollision(ball, goalKeeper)) {
kicker_yspeed = Math.abs(kicker_yspeed);
kicker_yspeed = kicker_yspeed / 7;
if (!flashAlerts._visible) {
flashAlerts._visible = true;
if (!nosounds) {
bgm2.start(0, 1);
nosounds = true;
}
flashAlerts.gotoAndPlay("save");
save_done = true;
}
wind_x = 0;
wind_y = 0;
}
}
if (((((save_checked && (!goal_done)) && (kicker_yspeed < 0)) && ((goalPost._y - ballMover._y) > 0)) && ((goalPost._y - ballMover._y) < 10)) && (ballMover.hitTest(goalArea))) {
flashAlerts._visible = true;
if (!nosounds) {
bgm.start(0, 1);
nosounds = true;
}
flashAlerts.gotoAndPlay("goal");
kicker_xspeed = 0;
kicker_yspeed = 0.2;
goalPost.gotoAndPlay(1);
goal_done = true;
currentScore = int(DistanceBetween(ball._x, ball._y, goalKeeper._x, goalKeeper._y));
scoreCard.scoreDisplay.txtScore.text = currentScore;
scoreCard._x = ball._x + 50;
scoreCard._y = ball._y;
scoreCard._visible = true;
scoreCard.gotoAndPlay(1);
wind_x = 0;
wind_y = 0;
}
if (kicker_yspeed < 0) {
i = 0;
while (i < NUM_OBSTACLES) {
if ((Math.abs(GetObstacle(i)._y - ballMover._y) < 2) && (com.gskinner.sprites.CollisionDetection.checkForCollision(ball, GetObstacle(i)))) {
kicker_yspeed = -kicker_yspeed;
GetObstacle(i).gotoAndPlay(1);
if (!nosounds) {
bgm2.start(0, 1);
nosounds = true;
}
break;
}
i++;
}
}
}
return(undefined);
}
var _local1 = Math.atan2(_ymouse - kickArea._y, _xmouse - kickArea._x);
var _local2 = _local1;
if (_local1 < 0) {
if (_local1 < -1.5707963267949) {
_local1 = -3.14159265358979;
} else {
_local1 = 0;
}
_local2 = -_local1;
}
mcArrow._rotation = (_local1 * 180) / Math.PI;
if (_local2 > 2.51327412287183) {
mcKicker.gotoAndStop(5);
} else if (_local2 > 1.88495559215388) {
mcKicker.gotoAndStop(4);
} else if (_local2 > 1.25663706143592) {
mcKicker.gotoAndStop(3);
} else if (_local2 > 0.628318530717959) {
mcKicker.gotoAndStop(2);
} else {
mcKicker.gotoAndStop(1);
}
if (hoveringAbove) {
mcKicker._x = _xmouse;
mcKicker._y = _ymouse;
} else {
posx = kickArea._x + (r1 * Math.cos(_local1));
posy = kickArea._y + (r2 * Math.sin(_local1));
if (Math.abs(posx - kickArea._x) < Math.abs(_xmouse - kickArea._x)) {
mcKicker._x = posx;
} else {
mcKicker._x = _xmouse;
}
mcKicker._y = posy;
}
};
btnReplay.onRelease = function () {
nosounds = true;
DoReplay();
};
btnNextLevel.onRelease = function () {
nosounds = false;
NextLevel();
};
Frame 109
function KickBall() {
kicker_yspeed = (kickArea._y - mcKicker._y) / 6;
kicker_xspeed = (kickArea._x - mcKicker._x) / 6;
state_aiming = false;
player_running = true;
ball_accelup = 6 - (DistanceBetween(mcKicker._x, mcKicker._y, kickArea._x, kickArea._y) / 7);
mcKicker.kicker.Run();
if (ball_accelup < 0) {
ball_accelup = 1;
}
}
function DistanceBetween(x1, y1, x2, y2) {
return(Math.sqrt(((x2 - x1) * (x2 - x1)) + ((y2 - y1) * (y2 - y1))));
}
function GetObstacle(oid) {
return(_root["obstacle" + oid]);
}
function AdjustDepths() {
if (((ballShadow._y > (goalKeeper._y - 2)) && (ball.getDepth() < goalKeeper.getDepth())) || ((ballShadow._y < (goalKeeper._y - 2)) && (ball.getDepth() > goalKeeper.getDepth()))) {
goalKeeper.swapDepths(ball);
}
}
function ChanceDone() {
if (!chance_done) {
chance_done = true;
EndOfChance();
}
}
function ResetItems() {
ball._x = kickArea._x;
ball._y = kickArea._y;
ball._xscale = 100;
ball._yscale = 100;
ballMover._x = kickArea._x;
ballMover._y = kickArea._y;
ballShadow._x = kickArea._x;
ballShadow._y = kickArea._y;
ballMover._visible = false;
extremeborder._visible = false;
flashAlerts.gotoAndStop(1);
flashAlerts._visible = false;
goalKeeper._x = goalPost._x;
goalKeeper._y = goalPost._y + 4;
goalKeeper.gotoAndStop(1);
state_aiming = true;
if (!nosounds) {
bgm4.start(0, 1);
}
player_running = false;
ball_in_play = false;
kicker_xspeed = 0;
kicker_yspeed = 0;
ball_height = 0;
ball_accelup = 0;
goal_done = false;
save_done = false;
save_checked = false;
target_follow_phase = 0;
if ((DistanceBetween(_xmouse, _ymouse, kickArea._x, kickArea._y) < (kickArea._width / 2)) && (_ymouse > kickArea._y)) {
hoveringAbove = true;
} else {
hoveringAbove = false;
}
i = 0;
while (i < NUM_OBSTACLES) {
GetObstacle(i).gotoAndStop(1);
i++;
}
mcWindDirection._rotation = windDirection;
if ((mcWindDirection._rotation > 90) || (mcWindDirection._rotation < -90)) {
mcWindDirection._rotation = 180;
} else {
mcWindDirection._rotation = 0;
}
wind_y = 0 * Math.sin((windDirection * Math.PI) / 180);
wind_x = 0.5 * Math.cos((windDirection * Math.PI) / 180);
txtWindSpeed.text = int(Math.abs(wind_x * 2) * 10) / 10;
if (txtWindSpeed.text == "0") {
mcWindDirection._rotation = -90;
}
goalPost.gotoAndStop(1);
chance_done = false;
}
function EndOfChance() {
var _local2 = goal_done;
if (_local2) {
if (interval_goalDone == 0) {
}
if (!isDoingReplay) {
_root.totalScore = _root.totalScore + currentScore;
_root["levelScore" + _root.currentLevel] = currentScore;
}
toolBar._visible = true;
toolBar.toolbarButtons.btnNextLevel._visible = true;
toolBar.toolbarButtons.btnRetry._visible = false;
btnNextLevel._visible = true;
toolBar.gotoAndPlay(1);
} else {
if (!isDoingReplay) {
_root.numChances--;
}
if (_root.numChances <= 0) {
nosounds = true;
if (interval_gameOver == 0) {
interval_gameOver = setInterval(GameOver, 2000);
}
} else {
if (interval_retry != 0) {
clearInterval(interval_retry);
interval_retry = 0;
}
trace("Setting Retry...");
interval_retry = setInterval(DoRetry, 2000);
}
}
}
function CalculateTargetX(ballx, bally, ballxspeed, ballyspeed, ylimit) {
if (((ballyspeed < 0) && (bally < ylimit)) || ((ballyspeed > 0) && (bally > ylimit))) {
return(-100);
}
if (ballyspeed < 0) {
while (bally > ylimit) {
bally = bally + ballyspeed;
ballx = ballx + ballxspeed;
}
} else {
while (bally < ylimit) {
bally = bally + ballyspeed;
ballx = ballx + ballxspeed;
}
}
return(ballx);
}
function DoRetry() {
if (interval_retry != 0) {
clearInterval(interval_retry);
interval_retry = 0;
}
nosounds = false;
ResetItems();
}
function DoReplay() {
if (ball_in_play && (!goal_done)) {
return(true);
}
if ((save_playerX == 0) && (save_playerY == 0)) {
return(undefined);
}
if (interval_retry != 0) {
clearInterval(interval_retry);
interval_retry = 0;
}
toolBar.play();
ResetItems();
mcKicker._x = save_playerX;
mcKicker._y = save_playerY;
mcKicker.gotoAndStop(save_playerFrame);
UpdateAngle();
isDoingReplay = true;
KickBall();
}
function NextLevel() {
GoalDone();
}
function GoalDone() {
ResetItems();
nextFrame();
}
function GameOver() {
clearInterval(interval_gameOver);
interval_gameOver = 0;
gotoAndStop ("gameover");
}
function UpdateAngle() {
}
stop();
NUM_OBSTACLES = 5;
_root.currentLevel = 7;
stopAllSounds();
var bgm = new Sound();
bgm.attachSound("cheer");
var bgm2 = new Sound();
bgm2.attachSound("miss");
var bgm3 = new Sound();
bgm3.attachSound("kick");
var bgm4 = new Sound();
bgm4.attachSound("whistle");
var bgm5 = new Sound(soundmovieclip2);
bgm5.attachSound("ballbounce");
var bgm6 = new Sound(soundmovieclip);
bgm6.attachSound("croud");
var firsttime = true;
var playedsound = false;
var nosounds = false;
bgm5.setVolume(30);
bgm6.setVolume(10);
bgm6.start(0, 1000);
bgm6.onSoundComplete = function () {
bgm6.start(0, 10000);
};
var state_aiming = true;
var player_running = false;
var ball_in_play = false;
var chance_done = false;
var hoveringAbove;
var kicker_xspeed = 0;
var kicker_yspeed = 0;
var ball_height = 0;
var ball_accelup = 0;
var goal_done = false;
var save_done = false;
var interval_ChanceTime = 0;
var target_follow_phase = 0;
var interval_goalDone = 0;
var interval_gameOver = 0;
var interval_retry = 0;
var save_checked = false;
scoreCard.gotoAndStop(1);
scoreCard._visible = false;
var currentScore = 0;
var r1 = 135;
var r2 = 65;
goalArea._x = goalPost._x;
goalArea._y = goalPost._y;
var keeper_speed = 1.5;
var gravity = 0.5;
var friction = 1.03;
var friction_gravity = 2;
var save_playerX = 0;
var save_playerY = 0;
var save_playerFrame = 0;
var isDoingReplay = false;
var windDirection = ((Math.random() * 360) - 180);
mcWindDirection._rotation = windDirection;
if ((mcWindDirection._rotation > 90) || (mcWindDirection._rotation < -90)) {
mcWindDirection._rotation = 180;
} else {
mcWindDirection._rotation = 0;
}
var wind_y = (0 * Math.sin((windDirection * Math.PI) / 180));
var wind_x = (0.5 * Math.cos((windDirection * Math.PI) / 180));
txtWindSpeed.text = int(Math.abs(wind_x * 2) * 10) / 10;
if (txtWindSpeed.text == "0") {
mcWindDirection._rotation = -90;
}
txtLevel.text = _root.currentLevel + "/10";
ball._x = kickArea._x;
ball._y = kickArea._y;
ballMover._visible = false;
extremeborder._visible = false;
flashAlerts.gotoAndStop(1);
flashAlerts._visible = false;
targetMarker._visible = false;
var mouseMoveLock = true;
toolBar.gotoAndStop(1);
btnNextLevel._visible = false;
i = 0;
while (i < NUM_OBSTACLES) {
GetObstacle(i).gotoAndStop(1);
i++;
}
goalPost.gotoAndStop(1);
kickArea.onRollOver = function () {
hoveringAbove = true;
};
kickArea.onDragOver = function () {
hoveringAbove = true;
};
ResetItems();
kickArea.onMouseMove = function () {
if (!mouseMoveLock) {
hoveringAbove = true;
mouseMoveLock = true;
}
};
kickArea.onRollOut = function () {
hoveringAbove = false;
};
kickArea.onDragOut = function () {
hoveringAbove = false;
};
kickArea.onRelease = function () {
if (state_aiming) {
save_playerX = mcKicker._x;
save_playerY = mcKicker._y;
save_playerFrame = mcKicker._currentframe;
isDoingReplay = false;
KickBall();
}
};
this.onEnterFrame = function () {
if (!state_aiming) {
if (player_running) {
mcKicker._x = mcKicker._x + kicker_xspeed;
mcKicker._y = mcKicker._y + kicker_yspeed;
if (DistanceBetween(mcKicker._x, mcKicker._y, kickArea._x, kickArea._y) <= 5) {
player_running = false;
mcKicker.kicker.gotoAndStop(1);
ball_in_play = true;
bgm3.start(0, 1);
ball_accelup = 6;
targetMarker._x = CalculateTargetX(ballMover._x, ballMover._y, kicker_xspeed, kicker_yspeed, targetMarker._y);
}
return(undefined);
}
if (ball_in_play) {
ballMover._x = ballMover._x + kicker_xspeed;
ballMover._y = ballMover._y + kicker_yspeed;
ball._rotation = ball._rotation + (kicker_xspeed * 10);
ball_height = ball_height + ball_accelup;
ball_accelup = ball_accelup - gravity;
if ((((ball_height > 3) && (ball_height < 8)) && (!playedsound)) && (ball_height < 6)) {
playedsound = true;
bgm5.start(0, 1);
}
if ((ball_accelup < 0) && (ball_height < 0)) {
playedsound = false;
ball_height = 0;
ball_accelup = -(ball_accelup / friction_gravity);
wind_x = wind_x / 5;
wind_y = wind_y / 5;
if (Math.abs(ball_accelup) <= 1) {
ball_accelup = 0;
ball_height = 0;
}
}
kicker_xspeed = kicker_xspeed / friction;
kicker_yspeed = kicker_yspeed / friction;
kicker_xspeed = kicker_xspeed + wind_x;
kicker_yspeed = kicker_yspeed + wind_y;
if (Math.abs(kicker_xspeed) < 0.1) {
kicker_xspeed = 0;
}
if (Math.abs(kicker_yspeed) < 0.1) {
kicker_yspeed = 0;
}
if ((Math.abs(kicker_xspeed) < 1) && (Math.abs(kicker_yspeed) < 1)) {
kicker_xspeed = 0;
kicker_yspeed = 0;
if (!chance_done) {
ChanceDone();
}
}
if (((ball._x > Stage.width) || (ball._x < 0)) || (ball._y > Stage.height)) {
if ((!chance_done) && (!goal_done)) {
ChanceDone();
}
}
ball._x = ballMover._x;
ball._y = ballMover._y - ball_height;
ball._xscale = ((ballMover._y - 30) / (mcKicker._y - 30)) * 100;
if (ball._xscale > 100) {
ball._xscale = 100;
}
ball._yscale = ball._xscale;
ballShadow._x = ballMover._x;
ballShadow._y = ballMover._y;
AdjustDepths();
if (kicker_yspeed < 0) {
jumpdetectrange = Math.abs(kicker_yspeed * 6);
if ((Math.abs(ballMover._y - goalKeeper._y) < jumpdetectrange) && (Math.abs(ballMover._x - goalKeeper._x) < 5)) {
if (ball_height > 10) {
goalKeeper.JumpDefend();
} else {
goalKeeper.Defend();
}
}
if ((target_follow_phase == 0) && (ballMover._y < (goalKeeper._y + (((mcKicker._y - goalKeeper._y) * 2) / 3)))) {
targetMarker._x = CalculateTargetX(ballMover._x, ballMover._y, kicker_xspeed, kicker_yspeed, targetMarker._y);
target_follow_phase = 1;
}
if ((target_follow_phase == 1) && (ballMover._y < (goalKeeper._y + ((mcKicker._y - goalKeeper._y) / 3)))) {
targetMarker._x = CalculateTargetX(ballMover._x, ballMover._y, kicker_xspeed, kicker_yspeed, targetMarker._y);
target_follow_phase = 2;
}
if (((target_follow_phase == 2) && (!goalKeeper.isJumping())) && (Math.abs(targetMarker._x - goalKeeper._x) > 20)) {
if (targetMarker._x < goalKeeper._x) {
goalKeeper.JumpLeft();
} else {
goalKeeper.JumpRight();
}
}
if (targetMarker._x < (goalKeeper._x - keeper_speed)) {
if (!goalKeeper.isJumping()) {
goalKeeper._x = goalKeeper._x - keeper_speed;
} else {
goalKeeper._x = goalKeeper._x - (keeper_speed / 2);
}
goalKeeper.Walk();
} else if (targetMarker._x > (goalKeeper._x + keeper_speed)) {
if (!goalKeeper.isJumping()) {
goalKeeper._x = goalKeeper._x + keeper_speed;
} else {
goalKeeper._x = goalKeeper._x + (keeper_speed / 2);
}
goalKeeper.Walk();
} else {
goalKeeper.StopMotion();
}
} else {
goalKeeper.StopMotion();
}
if (ballMover._y <= extremeborder._y) {
kicker_yspeed = Math.abs(kicker_yspeed);
kicker_yspeed = kicker_yspeed / 2;
if (kicker_yspeed > 2) {
kicker_yspeed = 2;
}
kicker_xspeed = kicker_xspeed / 2;
wind_x = wind_x / 8;
wind_y = wind_y / 8;
if (!nosounds) {
bgm2.start(0, 1);
nosounds = true;
}
}
if ((((!save_done) && (!goal_done)) && (ballMover._y >= goalKeeper._y)) && ((ballMover._y + kicker_yspeed) <= goalKeeper._y)) {
save_checked = true;
if (com.gskinner.sprites.CollisionDetection.checkForCollision(ball, goalKeeper)) {
kicker_yspeed = Math.abs(kicker_yspeed);
kicker_yspeed = kicker_yspeed / 7;
if (!flashAlerts._visible) {
flashAlerts._visible = true;
if (!nosounds) {
bgm2.start(0, 1);
nosounds = true;
}
flashAlerts.gotoAndPlay("save");
save_done = true;
}
wind_x = 0;
wind_y = 0;
}
}
if (((((save_checked && (!goal_done)) && (kicker_yspeed < 0)) && ((goalPost._y - ballMover._y) > 0)) && ((goalPost._y - ballMover._y) < 10)) && (ballMover.hitTest(goalArea))) {
flashAlerts._visible = true;
if (!nosounds) {
bgm.start(0, 1);
nosounds = true;
}
flashAlerts.gotoAndPlay("goal");
kicker_xspeed = 0;
kicker_yspeed = 0.2;
goalPost.gotoAndPlay(1);
goal_done = true;
currentScore = int(DistanceBetween(ball._x, ball._y, goalKeeper._x, goalKeeper._y));
scoreCard.scoreDisplay.txtScore.text = currentScore;
scoreCard._x = ball._x + 50;
scoreCard._y = ball._y;
scoreCard._visible = true;
scoreCard.gotoAndPlay(1);
wind_x = 0;
wind_y = 0;
}
if (kicker_yspeed < 0) {
i = 0;
while (i < NUM_OBSTACLES) {
if ((Math.abs(GetObstacle(i)._y - ballMover._y) < 2) && (com.gskinner.sprites.CollisionDetection.checkForCollision(ball, GetObstacle(i)))) {
kicker_yspeed = -kicker_yspeed;
GetObstacle(i).gotoAndPlay(1);
if (!nosounds) {
bgm2.start(0, 1);
nosounds = true;
}
break;
}
i++;
}
}
}
return(undefined);
}
var _local1 = Math.atan2(_ymouse - kickArea._y, _xmouse - kickArea._x);
var _local2 = _local1;
if (_local1 < 0) {
if (_local1 < -1.5707963267949) {
_local1 = -3.14159265358979;
} else {
_local1 = 0;
}
_local2 = -_local1;
}
mcArrow._rotation = (_local1 * 180) / Math.PI;
if (_local2 > 2.51327412287183) {
mcKicker.gotoAndStop(5);
} else if (_local2 > 1.88495559215388) {
mcKicker.gotoAndStop(4);
} else if (_local2 > 1.25663706143592) {
mcKicker.gotoAndStop(3);
} else if (_local2 > 0.628318530717959) {
mcKicker.gotoAndStop(2);
} else {
mcKicker.gotoAndStop(1);
}
if (hoveringAbove) {
mcKicker._x = _xmouse;
mcKicker._y = _ymouse;
} else {
posx = kickArea._x + (r1 * Math.cos(_local1));
posy = kickArea._y + (r2 * Math.sin(_local1));
if (Math.abs(posx - kickArea._x) < Math.abs(_xmouse - kickArea._x)) {
mcKicker._x = posx;
} else {
mcKicker._x = _xmouse;
}
mcKicker._y = posy;
}
};
btnReplay.onRelease = function () {
nosounds = true;
DoReplay();
};
btnNextLevel.onRelease = function () {
nosounds = false;
NextLevel();
};
Frame 110
function KickBall() {
kicker_yspeed = (kickArea._y - mcKicker._y) / 6;
kicker_xspeed = (kickArea._x - mcKicker._x) / 6;
state_aiming = false;
player_running = true;
ball_accelup = 6 - (DistanceBetween(mcKicker._x, mcKicker._y, kickArea._x, kickArea._y) / 7);
mcKicker.kicker.Run();
if (ball_accelup < 0) {
ball_accelup = 1;
}
}
function DistanceBetween(x1, y1, x2, y2) {
return(Math.sqrt(((x2 - x1) * (x2 - x1)) + ((y2 - y1) * (y2 - y1))));
}
function GetObstacle(oid) {
return(_root["obstacle" + oid]);
}
function AdjustDepths() {
if (((ballShadow._y > (goalKeeper._y - 2)) && (ball.getDepth() < goalKeeper.getDepth())) || ((ballShadow._y < (goalKeeper._y - 2)) && (ball.getDepth() > goalKeeper.getDepth()))) {
goalKeeper.swapDepths(ball);
}
}
function ChanceDone() {
if (!chance_done) {
chance_done = true;
EndOfChance();
}
}
function ResetItems() {
ball._x = kickArea._x;
ball._y = kickArea._y;
ball._xscale = 100;
ball._yscale = 100;
ballMover._x = kickArea._x;
ballMover._y = kickArea._y;
ballShadow._x = kickArea._x;
ballShadow._y = kickArea._y;
ballMover._visible = false;
extremeborder._visible = false;
flashAlerts.gotoAndStop(1);
flashAlerts._visible = false;
goalKeeper._x = goalPost._x;
goalKeeper._y = goalPost._y + 4;
goalKeeper.gotoAndStop(1);
state_aiming = true;
if (!nosounds) {
bgm4.start(0, 1);
}
player_running = false;
ball_in_play = false;
kicker_xspeed = 0;
kicker_yspeed = 0;
ball_height = 0;
ball_accelup = 0;
goal_done = false;
save_done = false;
save_checked = false;
target_follow_phase = 0;
if ((DistanceBetween(_xmouse, _ymouse, kickArea._x, kickArea._y) < (kickArea._width / 2)) && (_ymouse > kickArea._y)) {
hoveringAbove = true;
} else {
hoveringAbove = false;
}
i = 0;
while (i < NUM_OBSTACLES) {
GetObstacle(i).gotoAndStop(1);
i++;
}
mcWindDirection._rotation = windDirection;
if ((mcWindDirection._rotation > 90) || (mcWindDirection._rotation < -90)) {
mcWindDirection._rotation = 180;
} else {
mcWindDirection._rotation = 0;
}
wind_y = 0 * Math.sin((windDirection * Math.PI) / 180);
wind_x = 0.5 * Math.cos((windDirection * Math.PI) / 180);
txtWindSpeed.text = int(Math.abs(wind_x * 2) * 10) / 10;
if (txtWindSpeed.text == "0") {
mcWindDirection._rotation = -90;
}
goalPost.gotoAndStop(1);
chance_done = false;
}
function EndOfChance() {
var _local2 = goal_done;
if (_local2) {
if (interval_goalDone == 0) {
}
if (!isDoingReplay) {
_root.totalScore = _root.totalScore + currentScore;
_root["levelScore" + _root.currentLevel] = currentScore;
}
toolBar._visible = true;
toolBar.toolbarButtons.btnNextLevel._visible = true;
toolBar.toolbarButtons.btnRetry._visible = false;
btnNextLevel._visible = true;
toolBar.gotoAndPlay(1);
} else {
if (!isDoingReplay) {
_root.numChances--;
}
if (_root.numChances <= 0) {
nosounds = true;
if (interval_gameOver == 0) {
interval_gameOver = setInterval(GameOver, 2000);
}
} else {
if (interval_retry != 0) {
clearInterval(interval_retry);
interval_retry = 0;
}
trace("Setting Retry...");
interval_retry = setInterval(DoRetry, 2000);
}
}
}
function CalculateTargetX(ballx, bally, ballxspeed, ballyspeed, ylimit) {
if (((ballyspeed < 0) && (bally < ylimit)) || ((ballyspeed > 0) && (bally > ylimit))) {
return(-100);
}
if (ballyspeed < 0) {
while (bally > ylimit) {
bally = bally + ballyspeed;
ballx = ballx + ballxspeed;
}
} else {
while (bally < ylimit) {
bally = bally + ballyspeed;
ballx = ballx + ballxspeed;
}
}
return(ballx);
}
function DoRetry() {
if (interval_retry != 0) {
clearInterval(interval_retry);
interval_retry = 0;
}
nosounds = false;
ResetItems();
}
function DoReplay() {
if (ball_in_play && (!goal_done)) {
return(true);
}
if ((save_playerX == 0) && (save_playerY == 0)) {
return(undefined);
}
if (interval_retry != 0) {
clearInterval(interval_retry);
interval_retry = 0;
}
toolBar.play();
ResetItems();
mcKicker._x = save_playerX;
mcKicker._y = save_playerY;
mcKicker.gotoAndStop(save_playerFrame);
UpdateAngle();
isDoingReplay = true;
KickBall();
}
function NextLevel() {
GoalDone();
}
function GoalDone() {
ResetItems();
nextFrame();
}
function GameOver() {
clearInterval(interval_gameOver);
interval_gameOver = 0;
gotoAndStop ("gameover");
}
function UpdateAngle() {
}
stop();
NUM_OBSTACLES = 6;
_root.currentLevel = 8;
stopAllSounds();
var bgm = new Sound();
bgm.attachSound("cheer");
var bgm2 = new Sound();
bgm2.attachSound("miss");
var bgm3 = new Sound();
bgm3.attachSound("kick");
var bgm4 = new Sound();
bgm4.attachSound("whistle");
var bgm5 = new Sound(soundmovieclip2);
bgm5.attachSound("ballbounce");
var bgm6 = new Sound(soundmovieclip);
bgm6.attachSound("croud");
var firsttime = true;
var playedsound = false;
var nosounds = false;
bgm5.setVolume(30);
bgm6.setVolume(10);
bgm6.start(0, 1000);
bgm6.onSoundComplete = function () {
bgm6.start(0, 10000);
};
var state_aiming = true;
var player_running = false;
var ball_in_play = false;
var chance_done = false;
var hoveringAbove;
var kicker_xspeed = 0;
var kicker_yspeed = 0;
var ball_height = 0;
var ball_accelup = 0;
var goal_done = false;
var save_done = false;
var interval_ChanceTime = 0;
var target_follow_phase = 0;
var interval_goalDone = 0;
var interval_gameOver = 0;
var interval_retry = 0;
var save_checked = false;
scoreCard.gotoAndStop(1);
scoreCard._visible = false;
var currentScore = 0;
var r1 = 135;
var r2 = 65;
goalArea._x = goalPost._x;
goalArea._y = goalPost._y;
var keeper_speed = 1.5;
var gravity = 0.5;
var friction = 1.03;
var friction_gravity = 2;
var save_playerX = 0;
var save_playerY = 0;
var save_playerFrame = 0;
var isDoingReplay = false;
var windDirection = ((Math.random() * 360) - 180);
mcWindDirection._rotation = windDirection;
if ((mcWindDirection._rotation > 90) || (mcWindDirection._rotation < -90)) {
mcWindDirection._rotation = 180;
} else {
mcWindDirection._rotation = 0;
}
var wind_y = (0 * Math.sin((windDirection * Math.PI) / 180));
var wind_x = (0.5 * Math.cos((windDirection * Math.PI) / 180));
txtWindSpeed.text = int(Math.abs(wind_x * 2) * 10) / 10;
if (txtWindSpeed.text == "0") {
mcWindDirection._rotation = -90;
}
txtLevel.text = _root.currentLevel + "/10";
ball._x = kickArea._x;
ball._y = kickArea._y;
ballMover._visible = false;
extremeborder._visible = false;
flashAlerts.gotoAndStop(1);
flashAlerts._visible = false;
targetMarker._visible = false;
var mouseMoveLock = true;
toolBar.gotoAndStop(1);
btnNextLevel._visible = false;
i = 0;
while (i < NUM_OBSTACLES) {
GetObstacle(i).gotoAndStop(1);
i++;
}
goalPost.gotoAndStop(1);
kickArea.onRollOver = function () {
hoveringAbove = true;
};
kickArea.onDragOver = function () {
hoveringAbove = true;
};
ResetItems();
kickArea.onMouseMove = function () {
if (!mouseMoveLock) {
hoveringAbove = true;
mouseMoveLock = true;
}
};
kickArea.onRollOut = function () {
hoveringAbove = false;
};
kickArea.onDragOut = function () {
hoveringAbove = false;
};
kickArea.onRelease = function () {
if (state_aiming) {
save_playerX = mcKicker._x;
save_playerY = mcKicker._y;
save_playerFrame = mcKicker._currentframe;
isDoingReplay = false;
KickBall();
}
};
this.onEnterFrame = function () {
if (!state_aiming) {
if (player_running) {
mcKicker._x = mcKicker._x + kicker_xspeed;
mcKicker._y = mcKicker._y + kicker_yspeed;
if (DistanceBetween(mcKicker._x, mcKicker._y, kickArea._x, kickArea._y) <= 5) {
player_running = false;
mcKicker.kicker.gotoAndStop(1);
ball_in_play = true;
bgm3.start(0, 1);
ball_accelup = 6;
targetMarker._x = CalculateTargetX(ballMover._x, ballMover._y, kicker_xspeed, kicker_yspeed, targetMarker._y);
}
return(undefined);
}
if (ball_in_play) {
ballMover._x = ballMover._x + kicker_xspeed;
ballMover._y = ballMover._y + kicker_yspeed;
ball._rotation = ball._rotation + (kicker_xspeed * 10);
ball_height = ball_height + ball_accelup;
ball_accelup = ball_accelup - gravity;
if ((((ball_height > 3) && (ball_height < 8)) && (!playedsound)) && (ball_height < 6)) {
playedsound = true;
bgm5.start(0, 1);
}
if ((ball_accelup < 0) && (ball_height < 0)) {
playedsound = false;
ball_height = 0;
ball_accelup = -(ball_accelup / friction_gravity);
wind_x = wind_x / 5;
wind_y = wind_y / 5;
if (Math.abs(ball_accelup) <= 1) {
ball_accelup = 0;
ball_height = 0;
}
}
kicker_xspeed = kicker_xspeed / friction;
kicker_yspeed = kicker_yspeed / friction;
kicker_xspeed = kicker_xspeed + wind_x;
kicker_yspeed = kicker_yspeed + wind_y;
if (Math.abs(kicker_xspeed) < 0.1) {
kicker_xspeed = 0;
}
if (Math.abs(kicker_yspeed) < 0.1) {
kicker_yspeed = 0;
}
if ((Math.abs(kicker_xspeed) < 1) && (Math.abs(kicker_yspeed) < 1)) {
kicker_xspeed = 0;
kicker_yspeed = 0;
if (!chance_done) {
ChanceDone();
}
}
if (((ball._x > Stage.width) || (ball._x < 0)) || (ball._y > Stage.height)) {
if ((!chance_done) && (!goal_done)) {
ChanceDone();
}
}
ball._x = ballMover._x;
ball._y = ballMover._y - ball_height;
ball._xscale = ((ballMover._y - 30) / (mcKicker._y - 30)) * 100;
if (ball._xscale > 100) {
ball._xscale = 100;
}
ball._yscale = ball._xscale;
ballShadow._x = ballMover._x;
ballShadow._y = ballMover._y;
AdjustDepths();
if (kicker_yspeed < 0) {
jumpdetectrange = Math.abs(kicker_yspeed * 6);
if ((Math.abs(ballMover._y - goalKeeper._y) < jumpdetectrange) && (Math.abs(ballMover._x - goalKeeper._x) < 5)) {
if (ball_height > 10) {
goalKeeper.JumpDefend();
} else {
goalKeeper.Defend();
}
}
if ((target_follow_phase == 0) && (ballMover._y < (goalKeeper._y + (((mcKicker._y - goalKeeper._y) * 2) / 3)))) {
targetMarker._x = CalculateTargetX(ballMover._x, ballMover._y, kicker_xspeed, kicker_yspeed, targetMarker._y);
target_follow_phase = 1;
}
if ((target_follow_phase == 1) && (ballMover._y < (goalKeeper._y + ((mcKicker._y - goalKeeper._y) / 3)))) {
targetMarker._x = CalculateTargetX(ballMover._x, ballMover._y, kicker_xspeed, kicker_yspeed, targetMarker._y);
target_follow_phase = 2;
}
if (((target_follow_phase == 2) && (!goalKeeper.isJumping())) && (Math.abs(targetMarker._x - goalKeeper._x) > 20)) {
if (targetMarker._x < goalKeeper._x) {
goalKeeper.JumpLeft();
} else {
goalKeeper.JumpRight();
}
}
if (targetMarker._x < (goalKeeper._x - keeper_speed)) {
if (!goalKeeper.isJumping()) {
goalKeeper._x = goalKeeper._x - keeper_speed;
} else {
goalKeeper._x = goalKeeper._x - (keeper_speed / 2);
}
goalKeeper.Walk();
} else if (targetMarker._x > (goalKeeper._x + keeper_speed)) {
if (!goalKeeper.isJumping()) {
goalKeeper._x = goalKeeper._x + keeper_speed;
} else {
goalKeeper._x = goalKeeper._x + (keeper_speed / 2);
}
goalKeeper.Walk();
} else {
goalKeeper.StopMotion();
}
} else {
goalKeeper.StopMotion();
}
if (ballMover._y <= extremeborder._y) {
kicker_yspeed = Math.abs(kicker_yspeed);
kicker_yspeed = kicker_yspeed / 2;
if (kicker_yspeed > 2) {
kicker_yspeed = 2;
}
kicker_xspeed = kicker_xspeed / 2;
wind_x = wind_x / 8;
wind_y = wind_y / 8;
if (!nosounds) {
bgm2.start(0, 1);
nosounds = true;
}
}
if ((((!save_done) && (!goal_done)) && (ballMover._y >= goalKeeper._y)) && ((ballMover._y + kicker_yspeed) <= goalKeeper._y)) {
save_checked = true;
if (com.gskinner.sprites.CollisionDetection.checkForCollision(ball, goalKeeper)) {
kicker_yspeed = Math.abs(kicker_yspeed);
kicker_yspeed = kicker_yspeed / 7;
if (!flashAlerts._visible) {
flashAlerts._visible = true;
if (!nosounds) {
bgm2.start(0, 1);
nosounds = true;
}
flashAlerts.gotoAndPlay("save");
save_done = true;
}
wind_x = 0;
wind_y = 0;
}
}
if (((((save_checked && (!goal_done)) && (kicker_yspeed < 0)) && ((goalPost._y - ballMover._y) > 0)) && ((goalPost._y - ballMover._y) < 10)) && (ballMover.hitTest(goalArea))) {
flashAlerts._visible = true;
if (!nosounds) {
bgm.start(0, 1);
nosounds = true;
}
flashAlerts.gotoAndPlay("goal");
kicker_xspeed = 0;
kicker_yspeed = 0.2;
goalPost.gotoAndPlay(1);
goal_done = true;
currentScore = int(DistanceBetween(ball._x, ball._y, goalKeeper._x, goalKeeper._y));
scoreCard.scoreDisplay.txtScore.text = currentScore;
scoreCard._x = ball._x + 50;
scoreCard._y = ball._y;
scoreCard._visible = true;
scoreCard.gotoAndPlay(1);
wind_x = 0;
wind_y = 0;
}
if (kicker_yspeed < 0) {
i = 0;
while (i < NUM_OBSTACLES) {
if ((Math.abs(GetObstacle(i)._y - ballMover._y) < 2) && (com.gskinner.sprites.CollisionDetection.checkForCollision(ball, GetObstacle(i)))) {
kicker_yspeed = -kicker_yspeed;
GetObstacle(i).gotoAndPlay(1);
if (!nosounds) {
bgm2.start(0, 1);
nosounds = true;
}
break;
}
i++;
}
}
}
return(undefined);
}
var _local1 = Math.atan2(_ymouse - kickArea._y, _xmouse - kickArea._x);
var _local2 = _local1;
if (_local1 < 0) {
if (_local1 < -1.5707963267949) {
_local1 = -3.14159265358979;
} else {
_local1 = 0;
}
_local2 = -_local1;
}
mcArrow._rotation = (_local1 * 180) / Math.PI;
if (_local2 > 2.51327412287183) {
mcKicker.gotoAndStop(5);
} else if (_local2 > 1.88495559215388) {
mcKicker.gotoAndStop(4);
} else if (_local2 > 1.25663706143592) {
mcKicker.gotoAndStop(3);
} else if (_local2 > 0.628318530717959) {
mcKicker.gotoAndStop(2);
} else {
mcKicker.gotoAndStop(1);
}
if (hoveringAbove) {
mcKicker._x = _xmouse;
mcKicker._y = _ymouse;
} else {
posx = kickArea._x + (r1 * Math.cos(_local1));
posy = kickArea._y + (r2 * Math.sin(_local1));
if (Math.abs(posx - kickArea._x) < Math.abs(_xmouse - kickArea._x)) {
mcKicker._x = posx;
} else {
mcKicker._x = _xmouse;
}
mcKicker._y = posy;
}
};
btnReplay.onRelease = function () {
nosounds = true;
DoReplay();
};
btnNextLevel.onRelease = function () {
nosounds = false;
NextLevel();
};
Frame 111
function KickBall() {
kicker_yspeed = (kickArea._y - mcKicker._y) / 6;
kicker_xspeed = (kickArea._x - mcKicker._x) / 6;
state_aiming = false;
player_running = true;
ball_accelup = 6 - (DistanceBetween(mcKicker._x, mcKicker._y, kickArea._x, kickArea._y) / 7);
mcKicker.kicker.Run();
if (ball_accelup < 0) {
ball_accelup = 1;
}
}
function DistanceBetween(x1, y1, x2, y2) {
return(Math.sqrt(((x2 - x1) * (x2 - x1)) + ((y2 - y1) * (y2 - y1))));
}
function GetObstacle(oid) {
return(_root["obstacle" + oid]);
}
function AdjustDepths() {
if (((ballShadow._y > (goalKeeper._y - 2)) && (ball.getDepth() < goalKeeper.getDepth())) || ((ballShadow._y < (goalKeeper._y - 2)) && (ball.getDepth() > goalKeeper.getDepth()))) {
goalKeeper.swapDepths(ball);
}
}
function ChanceDone() {
if (!chance_done) {
chance_done = true;
EndOfChance();
}
}
function ResetItems() {
ball._x = kickArea._x;
ball._y = kickArea._y;
ball._xscale = 100;
ball._yscale = 100;
ballMover._x = kickArea._x;
ballMover._y = kickArea._y;
ballShadow._x = kickArea._x;
ballShadow._y = kickArea._y;
ballMover._visible = false;
extremeborder._visible = false;
flashAlerts.gotoAndStop(1);
flashAlerts._visible = false;
goalKeeper._x = goalPost._x;
goalKeeper._y = goalPost._y + 4;
goalKeeper.gotoAndStop(1);
state_aiming = true;
if (!nosounds) {
bgm4.start(0, 1);
}
player_running = false;
ball_in_play = false;
kicker_xspeed = 0;
kicker_yspeed = 0;
ball_height = 0;
ball_accelup = 0;
goal_done = false;
save_done = false;
save_checked = false;
target_follow_phase = 0;
if ((DistanceBetween(_xmouse, _ymouse, kickArea._x, kickArea._y) < (kickArea._width / 2)) && (_ymouse > kickArea._y)) {
hoveringAbove = true;
} else {
hoveringAbove = false;
}
i = 0;
while (i < NUM_OBSTACLES) {
GetObstacle(i).gotoAndStop(1);
i++;
}
mcWindDirection._rotation = windDirection;
if ((mcWindDirection._rotation > 90) || (mcWindDirection._rotation < -90)) {
mcWindDirection._rotation = 180;
} else {
mcWindDirection._rotation = 0;
}
wind_y = 0 * Math.sin((windDirection * Math.PI) / 180);
wind_x = 0.5 * Math.cos((windDirection * Math.PI) / 180);
txtWindSpeed.text = int(Math.abs(wind_x * 2) * 10) / 10;
if (txtWindSpeed.text == "0") {
mcWindDirection._rotation = -90;
}
goalPost.gotoAndStop(1);
chance_done = false;
}
function EndOfChance() {
var _local2 = goal_done;
if (_local2) {
if (interval_goalDone == 0) {
}
if (!isDoingReplay) {
_root.totalScore = _root.totalScore + currentScore;
_root["levelScore" + _root.currentLevel] = currentScore;
}
toolBar._visible = true;
toolBar.toolbarButtons.btnNextLevel._visible = true;
toolBar.toolbarButtons.btnRetry._visible = false;
btnNextLevel._visible = true;
toolBar.gotoAndPlay(1);
} else {
if (!isDoingReplay) {
_root.numChances--;
}
if (_root.numChances <= 0) {
nosounds = true;
if (interval_gameOver == 0) {
interval_gameOver = setInterval(GameOver, 2000);
}
} else {
if (interval_retry != 0) {
clearInterval(interval_retry);
interval_retry = 0;
}
trace("Setting Retry...");
interval_retry = setInterval(DoRetry, 2000);
}
}
}
function CalculateTargetX(ballx, bally, ballxspeed, ballyspeed, ylimit) {
if (((ballyspeed < 0) && (bally < ylimit)) || ((ballyspeed > 0) && (bally > ylimit))) {
return(-100);
}
if (ballyspeed < 0) {
while (bally > ylimit) {
bally = bally + ballyspeed;
ballx = ballx + ballxspeed;
}
} else {
while (bally < ylimit) {
bally = bally + ballyspeed;
ballx = ballx + ballxspeed;
}
}
return(ballx);
}
function DoRetry() {
if (interval_retry != 0) {
clearInterval(interval_retry);
interval_retry = 0;
}
nosounds = false;
ResetItems();
}
function DoReplay() {
if (ball_in_play && (!goal_done)) {
return(true);
}
if ((save_playerX == 0) && (save_playerY == 0)) {
return(undefined);
}
if (interval_retry != 0) {
clearInterval(interval_retry);
interval_retry = 0;
}
toolBar.play();
ResetItems();
mcKicker._x = save_playerX;
mcKicker._y = save_playerY;
mcKicker.gotoAndStop(save_playerFrame);
UpdateAngle();
isDoingReplay = true;
KickBall();
}
function NextLevel() {
GoalDone();
}
function GoalDone() {
ResetItems();
nextFrame();
}
function GameOver() {
clearInterval(interval_gameOver);
interval_gameOver = 0;
gotoAndStop ("gameover");
}
function UpdateAngle() {
}
stop();
NUM_OBSTACLES = 6;
_root.currentLevel = 9;
stopAllSounds();
var bgm = new Sound();
bgm.attachSound("cheer");
var bgm2 = new Sound();
bgm2.attachSound("miss");
var bgm3 = new Sound();
bgm3.attachSound("kick");
var bgm4 = new Sound();
bgm4.attachSound("whistle");
var bgm5 = new Sound(soundmovieclip2);
bgm5.attachSound("ballbounce");
var bgm6 = new Sound(soundmovieclip);
bgm6.attachSound("croud");
var firsttime = true;
var playedsound = false;
var nosounds = false;
bgm5.setVolume(30);
bgm6.setVolume(10);
bgm6.start(0, 1000);
bgm6.onSoundComplete = function () {
bgm6.start(0, 10000);
};
var state_aiming = true;
var player_running = false;
var ball_in_play = false;
var chance_done = false;
var hoveringAbove;
var kicker_xspeed = 0;
var kicker_yspeed = 0;
var ball_height = 0;
var ball_accelup = 0;
var goal_done = false;
var save_done = false;
var interval_ChanceTime = 0;
var target_follow_phase = 0;
var interval_goalDone = 0;
var interval_gameOver = 0;
var interval_retry = 0;
var save_checked = false;
scoreCard.gotoAndStop(1);
scoreCard._visible = false;
var currentScore = 0;
var r1 = 135;
var r2 = 65;
goalArea._x = goalPost._x;
goalArea._y = goalPost._y;
var keeper_speed = 1.5;
var gravity = 0.5;
var friction = 1.03;
var friction_gravity = 2;
var save_playerX = 0;
var save_playerY = 0;
var save_playerFrame = 0;
var isDoingReplay = false;
var windDirection = ((Math.random() * 360) - 180);
mcWindDirection._rotation = windDirection;
if ((mcWindDirection._rotation > 90) || (mcWindDirection._rotation < -90)) {
mcWindDirection._rotation = 180;
} else {
mcWindDirection._rotation = 0;
}
var wind_y = (0 * Math.sin((windDirection * Math.PI) / 180));
var wind_x = (0.5 * Math.cos((windDirection * Math.PI) / 180));
txtWindSpeed.text = int(Math.abs(wind_x * 2) * 10) / 10;
if (txtWindSpeed.text == "0") {
mcWindDirection._rotation = -90;
}
txtLevel.text = _root.currentLevel + "/10";
ball._x = kickArea._x;
ball._y = kickArea._y;
ballMover._visible = false;
extremeborder._visible = false;
flashAlerts.gotoAndStop(1);
flashAlerts._visible = false;
targetMarker._visible = false;
var mouseMoveLock = true;
toolBar.gotoAndStop(1);
btnNextLevel._visible = false;
i = 0;
while (i < NUM_OBSTACLES) {
GetObstacle(i).gotoAndStop(1);
i++;
}
goalPost.gotoAndStop(1);
kickArea.onRollOver = function () {
hoveringAbove = true;
};
kickArea.onDragOver = function () {
hoveringAbove = true;
};
ResetItems();
kickArea.onMouseMove = function () {
if (!mouseMoveLock) {
hoveringAbove = true;
mouseMoveLock = true;
}
};
kickArea.onRollOut = function () {
hoveringAbove = false;
};
kickArea.onDragOut = function () {
hoveringAbove = false;
};
kickArea.onRelease = function () {
if (state_aiming) {
save_playerX = mcKicker._x;
save_playerY = mcKicker._y;
save_playerFrame = mcKicker._currentframe;
isDoingReplay = false;
KickBall();
}
};
this.onEnterFrame = function () {
if (!state_aiming) {
if (player_running) {
mcKicker._x = mcKicker._x + kicker_xspeed;
mcKicker._y = mcKicker._y + kicker_yspeed;
if (DistanceBetween(mcKicker._x, mcKicker._y, kickArea._x, kickArea._y) <= 5) {
player_running = false;
mcKicker.kicker.gotoAndStop(1);
ball_in_play = true;
bgm3.start(0, 1);
ball_accelup = 6;
targetMarker._x = CalculateTargetX(ballMover._x, ballMover._y, kicker_xspeed, kicker_yspeed, targetMarker._y);
}
return(undefined);
}
if (ball_in_play) {
ballMover._x = ballMover._x + kicker_xspeed;
ballMover._y = ballMover._y + kicker_yspeed;
ball._rotation = ball._rotation + (kicker_xspeed * 10);
ball_height = ball_height + ball_accelup;
ball_accelup = ball_accelup - gravity;
if ((((ball_height > 3) && (ball_height < 8)) && (!playedsound)) && (ball_height < 6)) {
playedsound = true;
bgm5.start(0, 1);
}
if ((ball_accelup < 0) && (ball_height < 0)) {
playedsound = false;
ball_height = 0;
ball_accelup = -(ball_accelup / friction_gravity);
wind_x = wind_x / 5;
wind_y = wind_y / 5;
if (Math.abs(ball_accelup) <= 1) {
ball_accelup = 0;
ball_height = 0;
}
}
kicker_xspeed = kicker_xspeed / friction;
kicker_yspeed = kicker_yspeed / friction;
kicker_xspeed = kicker_xspeed + wind_x;
kicker_yspeed = kicker_yspeed + wind_y;
if (Math.abs(kicker_xspeed) < 0.1) {
kicker_xspeed = 0;
}
if (Math.abs(kicker_yspeed) < 0.1) {
kicker_yspeed = 0;
}
if ((Math.abs(kicker_xspeed) < 1) && (Math.abs(kicker_yspeed) < 1)) {
kicker_xspeed = 0;
kicker_yspeed = 0;
if (!chance_done) {
ChanceDone();
}
}
if (((ball._x > Stage.width) || (ball._x < 0)) || (ball._y > Stage.height)) {
if ((!chance_done) && (!goal_done)) {
ChanceDone();
}
}
ball._x = ballMover._x;
ball._y = ballMover._y - ball_height;
ball._xscale = ((ballMover._y - 30) / (mcKicker._y - 30)) * 100;
if (ball._xscale > 100) {
ball._xscale = 100;
}
ball._yscale = ball._xscale;
ballShadow._x = ballMover._x;
ballShadow._y = ballMover._y;
AdjustDepths();
if (kicker_yspeed < 0) {
jumpdetectrange = Math.abs(kicker_yspeed * 6);
if ((Math.abs(ballMover._y - goalKeeper._y) < jumpdetectrange) && (Math.abs(ballMover._x - goalKeeper._x) < 5)) {
if (ball_height > 10) {
goalKeeper.JumpDefend();
} else {
goalKeeper.Defend();
}
}
if ((target_follow_phase == 0) && (ballMover._y < (goalKeeper._y + (((mcKicker._y - goalKeeper._y) * 2) / 3)))) {
targetMarker._x = CalculateTargetX(ballMover._x, ballMover._y, kicker_xspeed, kicker_yspeed, targetMarker._y);
target_follow_phase = 1;
}
if ((target_follow_phase == 1) && (ballMover._y < (goalKeeper._y + ((mcKicker._y - goalKeeper._y) / 3)))) {
targetMarker._x = CalculateTargetX(ballMover._x, ballMover._y, kicker_xspeed, kicker_yspeed, targetMarker._y);
target_follow_phase = 2;
}
if (((target_follow_phase == 2) && (!goalKeeper.isJumping())) && (Math.abs(targetMarker._x - goalKeeper._x) > 20)) {
if (targetMarker._x < goalKeeper._x) {
goalKeeper.JumpLeft();
} else {
goalKeeper.JumpRight();
}
}
if (targetMarker._x < (goalKeeper._x - keeper_speed)) {
if (!goalKeeper.isJumping()) {
goalKeeper._x = goalKeeper._x - keeper_speed;
} else {
goalKeeper._x = goalKeeper._x - (keeper_speed / 2);
}
goalKeeper.Walk();
} else if (targetMarker._x > (goalKeeper._x + keeper_speed)) {
if (!goalKeeper.isJumping()) {
goalKeeper._x = goalKeeper._x + keeper_speed;
} else {
goalKeeper._x = goalKeeper._x + (keeper_speed / 2);
}
goalKeeper.Walk();
} else {
goalKeeper.StopMotion();
}
} else {
goalKeeper.StopMotion();
}
if (ballMover._y <= extremeborder._y) {
kicker_yspeed = Math.abs(kicker_yspeed);
kicker_yspeed = kicker_yspeed / 2;
if (kicker_yspeed > 2) {
kicker_yspeed = 2;
}
kicker_xspeed = kicker_xspeed / 2;
wind_x = wind_x / 8;
wind_y = wind_y / 8;
if (!nosounds) {
bgm2.start(0, 1);
nosounds = true;
}
}
if ((((!save_done) && (!goal_done)) && (ballMover._y >= goalKeeper._y)) && ((ballMover._y + kicker_yspeed) <= goalKeeper._y)) {
save_checked = true;
if (com.gskinner.sprites.CollisionDetection.checkForCollision(ball, goalKeeper)) {
kicker_yspeed = Math.abs(kicker_yspeed);
kicker_yspeed = kicker_yspeed / 7;
if (!flashAlerts._visible) {
flashAlerts._visible = true;
if (!nosounds) {
bgm2.start(0, 1);
nosounds = true;
}
flashAlerts.gotoAndPlay("save");
save_done = true;
}
wind_x = 0;
wind_y = 0;
}
}
if (((((save_checked && (!goal_done)) && (kicker_yspeed < 0)) && ((goalPost._y - ballMover._y) > 0)) && ((goalPost._y - ballMover._y) < 10)) && (ballMover.hitTest(goalArea))) {
flashAlerts._visible = true;
if (!nosounds) {
bgm.start(0, 1);
nosounds = true;
}
flashAlerts.gotoAndPlay("goal");
kicker_xspeed = 0;
kicker_yspeed = 0.2;
goalPost.gotoAndPlay(1);
goal_done = true;
currentScore = int(DistanceBetween(ball._x, ball._y, goalKeeper._x, goalKeeper._y));
scoreCard.scoreDisplay.txtScore.text = currentScore;
scoreCard._x = ball._x + 50;
scoreCard._y = ball._y;
scoreCard._visible = true;
scoreCard.gotoAndPlay(1);
wind_x = 0;
wind_y = 0;
}
if (kicker_yspeed < 0) {
i = 0;
while (i < NUM_OBSTACLES) {
if ((Math.abs(GetObstacle(i)._y - ballMover._y) < 2) && (com.gskinner.sprites.CollisionDetection.checkForCollision(ball, GetObstacle(i)))) {
kicker_yspeed = -kicker_yspeed;
GetObstacle(i).gotoAndPlay(1);
if (!nosounds) {
bgm2.start(0, 1);
nosounds = true;
}
break;
}
i++;
}
}
}
return(undefined);
}
var _local1 = Math.atan2(_ymouse - kickArea._y, _xmouse - kickArea._x);
var _local2 = _local1;
if (_local1 < 0) {
if (_local1 < -1.5707963267949) {
_local1 = -3.14159265358979;
} else {
_local1 = 0;
}
_local2 = -_local1;
}
mcArrow._rotation = (_local1 * 180) / Math.PI;
if (_local2 > 2.51327412287183) {
mcKicker.gotoAndStop(5);
} else if (_local2 > 1.88495559215388) {
mcKicker.gotoAndStop(4);
} else if (_local2 > 1.25663706143592) {
mcKicker.gotoAndStop(3);
} else if (_local2 > 0.628318530717959) {
mcKicker.gotoAndStop(2);
} else {
mcKicker.gotoAndStop(1);
}
if (hoveringAbove) {
mcKicker._x = _xmouse;
mcKicker._y = _ymouse;
} else {
posx = kickArea._x + (r1 * Math.cos(_local1));
posy = kickArea._y + (r2 * Math.sin(_local1));
if (Math.abs(posx - kickArea._x) < Math.abs(_xmouse - kickArea._x)) {
mcKicker._x = posx;
} else {
mcKicker._x = _xmouse;
}
mcKicker._y = posy;
}
};
btnReplay.onRelease = function () {
nosounds = true;
DoReplay();
};
btnNextLevel.onRelease = function () {
nosounds = false;
NextLevel();
};
Frame 112
function KickBall() {
kicker_yspeed = (kickArea._y - mcKicker._y) / 6;
kicker_xspeed = (kickArea._x - mcKicker._x) / 6;
state_aiming = false;
player_running = true;
ball_accelup = 6 - (DistanceBetween(mcKicker._x, mcKicker._y, kickArea._x, kickArea._y) / 7);
mcKicker.kicker.Run();
if (ball_accelup < 0) {
ball_accelup = 1;
}
}
function DistanceBetween(x1, y1, x2, y2) {
return(Math.sqrt(((x2 - x1) * (x2 - x1)) + ((y2 - y1) * (y2 - y1))));
}
function GetObstacle(oid) {
return(_root["obstacle" + oid]);
}
function AdjustDepths() {
if (((ballShadow._y > (goalKeeper._y - 2)) && (ball.getDepth() < goalKeeper.getDepth())) || ((ballShadow._y < (goalKeeper._y - 2)) && (ball.getDepth() > goalKeeper.getDepth()))) {
goalKeeper.swapDepths(ball);
}
}
function ChanceDone() {
if (!chance_done) {
chance_done = true;
EndOfChance();
}
}
function ResetItems() {
ball._x = kickArea._x;
ball._y = kickArea._y;
ball._xscale = 100;
ball._yscale = 100;
ballMover._x = kickArea._x;
ballMover._y = kickArea._y;
ballShadow._x = kickArea._x;
ballShadow._y = kickArea._y;
ballMover._visible = false;
extremeborder._visible = false;
flashAlerts.gotoAndStop(1);
flashAlerts._visible = false;
goalKeeper._x = goalPost._x;
goalKeeper._y = goalPost._y + 4;
goalKeeper.gotoAndStop(1);
state_aiming = true;
if (!nosounds) {
bgm4.start(0, 1);
}
player_running = false;
ball_in_play = false;
kicker_xspeed = 0;
kicker_yspeed = 0;
ball_height = 0;
ball_accelup = 0;
goal_done = false;
save_done = false;
save_checked = false;
target_follow_phase = 0;
if ((DistanceBetween(_xmouse, _ymouse, kickArea._x, kickArea._y) < (kickArea._width / 2)) && (_ymouse > kickArea._y)) {
hoveringAbove = true;
} else {
hoveringAbove = false;
}
i = 0;
while (i < NUM_OBSTACLES) {
GetObstacle(i).gotoAndStop(1);
i++;
}
mcWindDirection._rotation = windDirection;
if ((mcWindDirection._rotation > 90) || (mcWindDirection._rotation < -90)) {
mcWindDirection._rotation = 180;
} else {
mcWindDirection._rotation = 0;
}
wind_y = 0 * Math.sin((windDirection * Math.PI) / 180);
wind_x = 0.5 * Math.cos((windDirection * Math.PI) / 180);
txtWindSpeed.text = int(Math.abs(wind_x * 2) * 10) / 10;
if (txtWindSpeed.text == "0") {
mcWindDirection._rotation = -90;
}
goalPost.gotoAndStop(1);
chance_done = false;
}
function EndOfChance() {
var _local2 = goal_done;
if (_local2) {
if (interval_goalDone == 0) {
}
if (!isDoingReplay) {
_root.totalScore = _root.totalScore + currentScore;
_root["levelScore" + _root.currentLevel] = currentScore;
}
toolBar._visible = true;
toolBar.toolbarButtons.btnNextLevel._visible = true;
toolBar.toolbarButtons.btnRetry._visible = false;
btnNextLevel._visible = true;
toolBar.gotoAndPlay(1);
} else {
if (!isDoingReplay) {
_root.numChances--;
}
if (_root.numChances <= 0) {
nosounds = true;
if (interval_gameOver == 0) {
interval_gameOver = setInterval(GameOver, 2000);
}
} else {
if (interval_retry != 0) {
clearInterval(interval_retry);
interval_retry = 0;
}
trace("Setting Retry...");
interval_retry = setInterval(DoRetry, 2000);
}
}
}
function CalculateTargetX(ballx, bally, ballxspeed, ballyspeed, ylimit) {
if (((ballyspeed < 0) && (bally < ylimit)) || ((ballyspeed > 0) && (bally > ylimit))) {
return(-100);
}
if (ballyspeed < 0) {
while (bally > ylimit) {
bally = bally + ballyspeed;
ballx = ballx + ballxspeed;
}
} else {
while (bally < ylimit) {
bally = bally + ballyspeed;
ballx = ballx + ballxspeed;
}
}
return(ballx);
}
function DoRetry() {
if (interval_retry != 0) {
clearInterval(interval_retry);
interval_retry = 0;
}
nosounds = false;
ResetItems();
}
function DoReplay() {
if (ball_in_play && (!goal_done)) {
return(true);
}
if ((save_playerX == 0) && (save_playerY == 0)) {
return(undefined);
}
if (interval_retry != 0) {
clearInterval(interval_retry);
interval_retry = 0;
}
toolBar.play();
ResetItems();
mcKicker._x = save_playerX;
mcKicker._y = save_playerY;
mcKicker.gotoAndStop(save_playerFrame);
UpdateAngle();
isDoingReplay = true;
KickBall();
}
function NextLevel() {
GoalDone();
}
function GoalDone() {
ResetItems();
nextFrame();
}
function GameOver() {
clearInterval(interval_gameOver);
interval_gameOver = 0;
gotoAndStop ("gameover");
}
function UpdateAngle() {
}
stop();
NUM_OBSTACLES = 5;
_root.currentLevel = 10;
stopAllSounds();
var bgm = new Sound();
bgm.attachSound("cheer");
var bgm2 = new Sound();
bgm2.attachSound("miss");
var bgm3 = new Sound();
bgm3.attachSound("kick");
var bgm4 = new Sound();
bgm4.attachSound("whistle");
var bgm5 = new Sound(soundmovieclip2);
bgm5.attachSound("ballbounce");
var bgm6 = new Sound(soundmovieclip);
bgm6.attachSound("croud");
var firsttime = true;
var playedsound = false;
var nosounds = false;
bgm5.setVolume(30);
bgm6.setVolume(10);
bgm6.start(0, 1000);
bgm6.onSoundComplete = function () {
bgm6.start(0, 10000);
};
var state_aiming = true;
var player_running = false;
var ball_in_play = false;
var chance_done = false;
var hoveringAbove;
var kicker_xspeed = 0;
var kicker_yspeed = 0;
var ball_height = 0;
var ball_accelup = 0;
var goal_done = false;
var save_done = false;
var interval_ChanceTime = 0;
var target_follow_phase = 0;
var interval_goalDone = 0;
var interval_gameOver = 0;
var interval_retry = 0;
var save_checked = false;
scoreCard.gotoAndStop(1);
scoreCard._visible = false;
var currentScore = 0;
var r1 = 135;
var r2 = 65;
goalArea._x = goalPost._x;
goalArea._y = goalPost._y;
var keeper_speed = 1.5;
var gravity = 0.5;
var friction = 1.03;
var friction_gravity = 2;
var save_playerX = 0;
var save_playerY = 0;
var save_playerFrame = 0;
var isDoingReplay = false;
var windDirection = ((Math.random() * 360) - 180);
mcWindDirection._rotation = windDirection;
if ((mcWindDirection._rotation > 90) || (mcWindDirection._rotation < -90)) {
mcWindDirection._rotation = 180;
} else {
mcWindDirection._rotation = 0;
}
var wind_y = (0 * Math.sin((windDirection * Math.PI) / 180));
var wind_x = (0.5 * Math.cos((windDirection * Math.PI) / 180));
txtWindSpeed.text = int(Math.abs(wind_x * 2) * 10) / 10;
if (txtWindSpeed.text == "0") {
mcWindDirection._rotation = -90;
}
txtLevel.text = _root.currentLevel + "/10";
ball._x = kickArea._x;
ball._y = kickArea._y;
ballMover._visible = false;
extremeborder._visible = false;
flashAlerts.gotoAndStop(1);
flashAlerts._visible = false;
targetMarker._visible = false;
var mouseMoveLock = true;
toolBar.gotoAndStop(1);
btnNextLevel._visible = false;
i = 0;
while (i < NUM_OBSTACLES) {
GetObstacle(i).gotoAndStop(1);
i++;
}
goalPost.gotoAndStop(1);
kickArea.onRollOver = function () {
hoveringAbove = true;
};
kickArea.onDragOver = function () {
hoveringAbove = true;
};
ResetItems();
kickArea.onMouseMove = function () {
if (!mouseMoveLock) {
hoveringAbove = true;
mouseMoveLock = true;
}
};
kickArea.onRollOut = function () {
hoveringAbove = false;
};
kickArea.onDragOut = function () {
hoveringAbove = false;
};
kickArea.onRelease = function () {
if (state_aiming) {
save_playerX = mcKicker._x;
save_playerY = mcKicker._y;
save_playerFrame = mcKicker._currentframe;
isDoingReplay = false;
KickBall();
}
};
this.onEnterFrame = function () {
if (!state_aiming) {
if (player_running) {
mcKicker._x = mcKicker._x + kicker_xspeed;
mcKicker._y = mcKicker._y + kicker_yspeed;
if (DistanceBetween(mcKicker._x, mcKicker._y, kickArea._x, kickArea._y) <= 5) {
player_running = false;
mcKicker.kicker.gotoAndStop(1);
ball_in_play = true;
bgm3.start(0, 1);
ball_accelup = 6;
targetMarker._x = CalculateTargetX(ballMover._x, ballMover._y, kicker_xspeed, kicker_yspeed, targetMarker._y);
}
return(undefined);
}
if (ball_in_play) {
ballMover._x = ballMover._x + kicker_xspeed;
ballMover._y = ballMover._y + kicker_yspeed;
ball._rotation = ball._rotation + (kicker_xspeed * 10);
ball_height = ball_height + ball_accelup;
ball_accelup = ball_accelup - gravity;
if ((((ball_height > 3) && (ball_height < 8)) && (!playedsound)) && (ball_height < 6)) {
playedsound = true;
bgm5.start(0, 1);
}
if ((ball_accelup < 0) && (ball_height < 0)) {
playedsound = false;
ball_height = 0;
ball_accelup = -(ball_accelup / friction_gravity);
wind_x = wind_x / 5;
wind_y = wind_y / 5;
if (Math.abs(ball_accelup) <= 1) {
ball_accelup = 0;
ball_height = 0;
}
}
kicker_xspeed = kicker_xspeed / friction;
kicker_yspeed = kicker_yspeed / friction;
kicker_xspeed = kicker_xspeed + wind_x;
kicker_yspeed = kicker_yspeed + wind_y;
if (Math.abs(kicker_xspeed) < 0.1) {
kicker_xspeed = 0;
}
if (Math.abs(kicker_yspeed) < 0.1) {
kicker_yspeed = 0;
}
if ((Math.abs(kicker_xspeed) < 1) && (Math.abs(kicker_yspeed) < 1)) {
kicker_xspeed = 0;
kicker_yspeed = 0;
if (!chance_done) {
ChanceDone();
}
}
if (((ball._x > Stage.width) || (ball._x < 0)) || (ball._y > Stage.height)) {
if ((!chance_done) && (!goal_done)) {
ChanceDone();
}
}
ball._x = ballMover._x;
ball._y = ballMover._y - ball_height;
ball._xscale = ((ballMover._y - 30) / (mcKicker._y - 30)) * 100;
if (ball._xscale > 100) {
ball._xscale = 100;
}
ball._yscale = ball._xscale;
ballShadow._x = ballMover._x;
ballShadow._y = ballMover._y;
AdjustDepths();
if (kicker_yspeed < 0) {
jumpdetectrange = Math.abs(kicker_yspeed * 6);
if ((Math.abs(ballMover._y - goalKeeper._y) < jumpdetectrange) && (Math.abs(ballMover._x - goalKeeper._x) < 5)) {
if (ball_height > 10) {
goalKeeper.JumpDefend();
} else {
goalKeeper.Defend();
}
}
if ((target_follow_phase == 0) && (ballMover._y < (goalKeeper._y + (((mcKicker._y - goalKeeper._y) * 2) / 3)))) {
targetMarker._x = CalculateTargetX(ballMover._x, ballMover._y, kicker_xspeed, kicker_yspeed, targetMarker._y);
target_follow_phase = 1;
}
if ((target_follow_phase == 1) && (ballMover._y < (goalKeeper._y + ((mcKicker._y - goalKeeper._y) / 3)))) {
targetMarker._x = CalculateTargetX(ballMover._x, ballMover._y, kicker_xspeed, kicker_yspeed, targetMarker._y);
target_follow_phase = 2;
}
if (((target_follow_phase == 2) && (!goalKeeper.isJumping())) && (Math.abs(targetMarker._x - goalKeeper._x) > 20)) {
if (targetMarker._x < goalKeeper._x) {
goalKeeper.JumpLeft();
} else {
goalKeeper.JumpRight();
}
}
if (targetMarker._x < (goalKeeper._x - keeper_speed)) {
if (!goalKeeper.isJumping()) {
goalKeeper._x = goalKeeper._x - keeper_speed;
} else {
goalKeeper._x = goalKeeper._x - (keeper_speed / 2);
}
goalKeeper.Walk();
} else if (targetMarker._x > (goalKeeper._x + keeper_speed)) {
if (!goalKeeper.isJumping()) {
goalKeeper._x = goalKeeper._x + keeper_speed;
} else {
goalKeeper._x = goalKeeper._x + (keeper_speed / 2);
}
goalKeeper.Walk();
} else {
goalKeeper.StopMotion();
}
} else {
goalKeeper.StopMotion();
}
if (ballMover._y <= extremeborder._y) {
kicker_yspeed = Math.abs(kicker_yspeed);
kicker_yspeed = kicker_yspeed / 2;
if (kicker_yspeed > 2) {
kicker_yspeed = 2;
}
kicker_xspeed = kicker_xspeed / 2;
wind_x = wind_x / 8;
wind_y = wind_y / 8;
if (!nosounds) {
bgm2.start(0, 1);
nosounds = true;
}
}
if ((((!save_done) && (!goal_done)) && (ballMover._y >= goalKeeper._y)) && ((ballMover._y + kicker_yspeed) <= goalKeeper._y)) {
save_checked = true;
if (com.gskinner.sprites.CollisionDetection.checkForCollision(ball, goalKeeper)) {
kicker_yspeed = Math.abs(kicker_yspeed);
kicker_yspeed = kicker_yspeed / 7;
if (!flashAlerts._visible) {
flashAlerts._visible = true;
if (!nosounds) {
bgm2.start(0, 1);
nosounds = true;
}
flashAlerts.gotoAndPlay("save");
save_done = true;
}
wind_x = 0;
wind_y = 0;
}
}
if (((((save_checked && (!goal_done)) && (kicker_yspeed < 0)) && ((goalPost._y - ballMover._y) > 0)) && ((goalPost._y - ballMover._y) < 10)) && (ballMover.hitTest(goalArea))) {
flashAlerts._visible = true;
if (!nosounds) {
bgm.start(0, 1);
nosounds = true;
}
flashAlerts.gotoAndPlay("goal");
kicker_xspeed = 0;
kicker_yspeed = 0.2;
goalPost.gotoAndPlay(1);
goal_done = true;
currentScore = int(DistanceBetween(ball._x, ball._y, goalKeeper._x, goalKeeper._y));
scoreCard.scoreDisplay.txtScore.text = currentScore;
scoreCard._x = ball._x + 50;
scoreCard._y = ball._y;
scoreCard._visible = true;
scoreCard.gotoAndPlay(1);
wind_x = 0;
wind_y = 0;
}
if (kicker_yspeed < 0) {
i = 0;
while (i < NUM_OBSTACLES) {
if ((Math.abs(GetObstacle(i)._y - ballMover._y) < 2) && (com.gskinner.sprites.CollisionDetection.checkForCollision(ball, GetObstacle(i)))) {
kicker_yspeed = -kicker_yspeed;
GetObstacle(i).gotoAndPlay(1);
if (!nosounds) {
bgm2.start(0, 1);
nosounds = true;
}
break;
}
i++;
}
}
}
return(undefined);
}
var _local1 = Math.atan2(_ymouse - kickArea._y, _xmouse - kickArea._x);
var _local2 = _local1;
if (_local1 < 0) {
if (_local1 < -1.5707963267949) {
_local1 = -3.14159265358979;
} else {
_local1 = 0;
}
_local2 = -_local1;
}
mcArrow._rotation = (_local1 * 180) / Math.PI;
if (_local2 > 2.51327412287183) {
mcKicker.gotoAndStop(5);
} else if (_local2 > 1.88495559215388) {
mcKicker.gotoAndStop(4);
} else if (_local2 > 1.25663706143592) {
mcKicker.gotoAndStop(3);
} else if (_local2 > 0.628318530717959) {
mcKicker.gotoAndStop(2);
} else {
mcKicker.gotoAndStop(1);
}
if (hoveringAbove) {
mcKicker._x = _xmouse;
mcKicker._y = _ymouse;
} else {
posx = kickArea._x + (r1 * Math.cos(_local1));
posy = kickArea._y + (r2 * Math.sin(_local1));
if (Math.abs(posx - kickArea._x) < Math.abs(_xmouse - kickArea._x)) {
mcKicker._x = posx;
} else {
mcKicker._x = _xmouse;
}
mcKicker._y = posy;
}
};
btnReplay.onRelease = function () {
nosounds = true;
DoReplay();
};
btnNextLevel.onRelease = function () {
nosounds = false;
NextLevel();
};
Frame 113
stop();
txtFinalScore.text = totalScore;
txtChancesLeft.text = _root.numChances;
txtTotalBonus.text = _root.numChances * 50;
txtGrandTotal.text = Number(_root.totalScore) + (_root.numChances * 50);
btnPlayAgain.onRelease = function () {
gotoAndStop (103);
};
Frame 114
stop();
txtFinalScore.text = totalScore;
btnTryAgain.onRelease = function () {
gotoAndStop (103);
};
Symbol 13 MovieClip Frame 12
Symbol 26 MovieClip Frame 1
this.onRelease = function () {
getURL ("http://www.gamezindia.com", "_blank");
};
Symbol 30 Button
on (release) {
getURL ("http://www.kibagames.com", "_blank");
}
Symbol 361 MovieClip [__Packages.com.gskinner.sprites.CollisionDetection] Frame 0
class com.gskinner.sprites.CollisionDetection
{
function CollisionDetection () {
}
static function checkForCollision(p_clip1, p_clip2, p_alphaTolerance) {
if (p_alphaTolerance == undefined) {
p_alphaTolerance = 255;
}
var _local4 = p_clip1.getBounds(_root);
var _local3 = p_clip2.getBounds(_root);
if (((_local4.xMax < _local3.xMin) || (_local3.xMax < _local4.xMin)) || ((_local4.yMax < _local3.yMin) || (_local3.yMax < _local4.yMin))) {
return(null);
}
var _local2 = {};
_local2.xMin = Math.max(_local4.xMin, _local3.xMin);
_local2.xMax = Math.min(_local4.xMax, _local3.xMax);
_local2.yMin = Math.max(_local4.yMin, _local3.yMin);
_local2.yMax = Math.min(_local4.yMax, _local3.yMax);
var _local7 = new flash.display.BitmapData(_local2.xMax - _local2.xMin, _local2.yMax - _local2.yMin, false);
var _local5 = p_clip1.transform.concatenatedMatrix;
_local5.tx = _local5.tx - _local2.xMin;
_local5.ty = _local5.ty - _local2.yMin;
_local7.draw(p_clip1, _local5, new flash.geom.ColorTransform(1, 1, 1, 1, 255, -255, -255, p_alphaTolerance));
_local5 = p_clip2.transform.concatenatedMatrix;
_local5.tx = _local5.tx - _local2.xMin;
_local5.ty = _local5.ty - _local2.yMin;
_local7.draw(p_clip2, _local5, new flash.geom.ColorTransform(1, 1, 1, 1, 255, 255, 255, p_alphaTolerance), "difference");
var _local6 = _local7.getColorBoundsRect(4294967295, 4278255615);
if (_local6.width == 0) {
return(null);
}
_local6.x = _local6.x + _local2.xMin;
_local6.y = _local6.y + _local2.yMin;
return(_local6);
}
}
Symbol 65 MovieClip Frame 1
this.onRelease = function () {
getURL ("http://www.gamezindia.com", "_blank");
};
Symbol 69 MovieClip Frame 1
button.onRelease = function () {
trace("inside2");
_root.soundmute = false;
_root.mutebutton._visible = true;
_root.unmutebutton._visible = false;
_root.bgm9.setVolume(80);
};
Symbol 72 MovieClip Frame 1
button.onRelease = function () {
trace("inside");
_root.soundmute = true;
_root.mutebutton._visible = false;
_root.unmutebutton._visible = true;
_root.bgm9.setVolume(0);
};
Symbol 92 Button
on (release) {
getURL ("http://www.kibagames.com/", "_blank");
}
Symbol 98 MovieClip Frame 1
this.onRelease = function () {
getURL ("http://www.kibagames.com/", "_blank");
};
Symbol 109 MovieClip Frame 8
gotoAndStop (1);
Symbol 136 MovieClip Frame 1
function Reset() {
gotoAndStop (1);
}
Symbol 136 MovieClip Frame 91
stop();
Symbol 231 MovieClip Frame 1
function Walk() {
if (_currentframe == 1) {
gotoAndPlay (2);
}
}
function JumpRight() {
if (_currentframe <= 6) {
gotoAndPlay ("jumpright");
}
}
function JumpLeft() {
if (_currentframe <= 6) {
gotoAndPlay ("jumpleft");
}
}
function SmallJumpRight() {
if (_currentframe <= 6) {
gotoAndPlay ("smalljumpright");
}
}
function SmallJumpLeft() {
if (_currentframe <= 6) {
gotoAndPlay ("smalljumpleft");
}
}
function StopMotion() {
if ((_currentframe > 1) && (_currentframe <= 6)) {
gotoAndStop (1);
}
}
function Defend() {
if ((!isJumping()) && (_currentframe < 118)) {
gotoAndPlay ("defend");
}
}
function JumpDefend() {
if ((!isJumping()) && (_currentframe < 118)) {
gotoAndPlay ("jumpdefend");
}
}
function isJumping() {
if (_currentframe > 6) {
return(true);
}
return(false);
}
stop();
Symbol 231 MovieClip Frame 7
gotoAndPlay (2);
Symbol 231 MovieClip Frame 47
stop();
Symbol 231 MovieClip Frame 86
stop();
Symbol 231 MovieClip Frame 100
stop();
Symbol 231 MovieClip Frame 134
gotoAndStop (1);
Symbol 231 MovieClip Frame 148
gotoAndStop (1);
Symbol 242 MovieClip Frame 20
this._visible = false;
gotoAndStop (1);
Symbol 242 MovieClip Frame 40
stop();
this._visible = false;
Symbol 246 MovieClip Frame 20
stop();
this._visible = false;
Symbol 283 MovieClip Frame 1
btnReplay.onRelease = function () {
_parent._parent.DoReplay();
};
btnRetry.onRelease = function () {
_parent._parent.DoRetry();
};
btnNextLevel.onRelease = function () {
_parent._parent.NextLevel();
};
Symbol 284 MovieClip Frame 14
stop();
Symbol 284 MovieClip Frame 28
stop();
gotoAndStop (1);
Symbol 294 MovieClip Frame 1
function Run() {
gotoAndPlay (2);
}
Symbol 294 MovieClip Frame 7
gotoAndPlay (2);
Symbol 298 MovieClip Frame 1
function Run() {
gotoAndPlay (2);
}
Symbol 298 MovieClip Frame 7
gotoAndPlay (2);
Symbol 302 MovieClip Frame 1
function Run() {
gotoAndPlay (2);
}
Symbol 302 MovieClip Frame 7
gotoAndPlay (2);
Symbol 306 MovieClip Frame 1
function Run() {
gotoAndPlay (2);
}
Symbol 306 MovieClip Frame 7
gotoAndPlay (2);
Symbol 311 MovieClip Frame 1
function Run() {
gotoAndPlay (2);
}
Symbol 311 MovieClip Frame 7
gotoAndPlay (2);
Symbol 312 MovieClip Frame 1
kicker.stop();
Symbol 312 MovieClip Frame 2
kicker.stop();
Symbol 312 MovieClip Frame 3
kicker.stop();
Symbol 312 MovieClip Frame 4
kicker.stop();
Symbol 312 MovieClip Frame 5
kicker.stop();