Frame 1
function checkLoadProgress() {
var _local1 = getBytesLoaded() / getBytesTotal();
if (_local1 < 1) {
progressBar._xscale = _local1 * 100;
} else {
gotoAndStop ("menu");
onEnterFrame = null;
}
}
stop();
onEnterFrame = checkLoadProgress;
Frame 2
function saveScore(thisScore) {
if (thisScore > cookie.data.bestScore) {
cookie.data.bestScore = thisScore;
tryFlush();
}
}
function tryFlush() {
var _local1 = cookie.flush();
if (_local1 == false) {
canStoreCookie = false;
}
}
function onCookieStatus(statusObject) {
if (statusObject.level == "Error") {
canStoreCookie = false;
}
}
function startGame() {
gotoAndStop ("game");
}
function showInstructions() {
gotoAndStop ("instructions");
}
stop();
var canStoreCookie = true;
var cookie = SharedObject.getLocal("fleePersonalBest", "/");
if (cookie) {
cookie.onStatus = onCookieStatus;
if (cookie.data.bestScore === undefined) {
cookie.data.bestScore = 0;
}
tryFlush();
} else {
canStoreCookie = false;
}
ball._visible = (ceiling._visible = (statusbar._visible = (gameover._visible = (ballDie._visible = false))));
startGameButton.onRelease = startGame;
showInstructionsButton.onRelease = showInstructions;
Frame 3
stop();
ball._visible = (ceiling._visible = (statusbar._visible = (gameover._visible = (ballDie._visible = false))));
startGameButton.onRelease = startGame;
Frame 4
function limitNumber(num, minLimit, maxLimit) {
if (maxLimit === null) {
maxLimit = Infinity;
}
if (minLimit === null) {
minLimit = -Infinity;
}
return(Math.max(minLimit, Math.min(num, maxLimit)));
}
function calcSpeed() {
xControl = (Key.isDown(39) - Key.isDown(37)) * hasControl;
xSpeed = (xSpeed + (xControl * ACCELERATION)) * (xControl ? 1 : (FRICTION));
xSpeed = limitNumber(xSpeed, -MAX_X_SPEED, MAX_X_SPEED);
ySpeed = ySpeed + GRAVITY;
if (((!isInAir) && (Key.isDown(38))) && (hasControl)) {
ySpeed = JUMP_VELOCITY - (isAtBottom ? 0 : (platformSpeed));
isInAir = true;
}
}
function moveBall() {
calcSpeed();
this._x = this._x + xSpeed;
if (this._x < LEFT_BORDER) {
xSpeed = 0;
this._x = LEFT_BORDER;
} else if (this._x > RIGHT_BORDER) {
xSpeed = 0;
this._x = RIGHT_BORDER;
}
this._y = this._y + ySpeed;
if (platforms.length) {
currentPlatform = platforms[0];
if (this._y > currentPlatform[0]._y) {
if (currentPlatform[0].endPoint >= (this._x - HALF_BALL_WIDTH)) {
this._y = currentPlatform[0]._y;
ySpeed = 0;
isInAir = false;
} else if (currentPlatform[1].endPoint <= (this._x + HALF_BALL_WIDTH)) {
this._y = currentPlatform[1]._y;
ySpeed = 0;
isInAir = false;
} else {
deactivatePlatform(0);
score = score + 10;
isInAir = true;
}
} else {
isInAir = true;
}
}
if (this._y > AVAILABLE_HEIGHT) {
this._y = AVAILABLE_HEIGHT;
ySpeed = 0;
isInAir = false;
isAtBottom = true;
} else {
isAtBottom = false;
}
}
function changeLives(amount) {
lives = lives + amount;
if (lives > 0) {
if (lives > 5) {
lives = 5;
}
if (amount < 0) {
ball.play();
isInvincible = true;
}
} else {
endGame();
}
trace(lives);
}
function endGame() {
onEnterFrame = null;
var _local2 = allPlatforms.length;
var _local1 = 0;
while (_local1 < _local2) {
removeMovieClip(allPlatforms[_local1][0]);
removeMovieClip(allPlatforms[_local1][1]);
_local1++;
}
hasControl = false;
gotoAndStop ("gameover");
}
function handleCeiling() {
if (this.hitTest(ball)) {
ySpeed = 0;
ball._y = (this._y + this._height) + ball._height;
deactivatePlatform(0);
if (!isInvincible) {
changeLives(-1);
}
}
}
function createPlatform() {
((platformId >= 1000) ? ((platformId = 0)) : ((platformId = platformId + 10)));
var thisPlatformHoleSize = (platformHoleSize + Math.round(Math.random() * platformHoleSize));
var holeStart = (10 + Math.round(Math.random() * ((Stage.width - 20) - thisPlatformHoleSize)));
var pf1 = createEmptyMovieClip("left_platform" + platformId, platformId);
pf1.endPoint = holeStart;
with (pf1) {
lineStyle(3, 15132390, 100);
moveTo(-100, 0);
beginFill(0, 0);
lineTo(endPoint, 0);
lineStyle(0, 0, 0);
lineTo(endPoint, 200);
lineTo(-100, 200);
lineTo(-100, 0);
endFill();
_y = AVAILABLE_HEIGHT + 200;
}
var bonusAmount = Math.floor((Math.random() * holeStart) / 50);
if (bonusAmount) {
var currentBonus;
var currentBonusX = ((holeStart * 0.5) - ((bonusAmount - 1) * 25));
var c = 0;
while (c < bonusAmount) {
currentBonus = createBonus(pf1);
currentBonus._x = currentBonusX;
currentBonus._y = -100;
currentBonus.onEnterFrame = handleBonus;
currentBonusX = currentBonusX + 50;
c++;
}
}
var pf2 = createEmptyMovieClip("right_platform" + platformId, platformId + 5);
pf2.endPoint = holeStart + thisPlatformHoleSize;
with (pf2) {
lineStyle(3, 15132390, 100);
moveTo(1000, 0);
beginFill(0, 0);
lineTo(endPoint, 0);
lineStyle(0, 0, 0);
lineTo(endPoint, 200);
lineTo(1000, 200);
lineTo(1000, 0);
endFill();
_y = AVAILABLE_HEIGHT + 200;
}
var pfWidth = (Stage.width - pf2.endPoint);
bonusAmount = Math.floor((Math.random() * pfWidth) / 50);
if (bonusAmount) {
var currentBonus;
var currentBonusX = ((pf2.endPoint + (pfWidth * 0.5)) - ((bonusAmount - 1) * 25));
var c = 0;
while (c < bonusAmount) {
currentBonus = createBonus(pf1);
currentBonus._x = currentBonusX;
currentBonus._y = -100;
currentBonus.onEnterFrame = handleBonus;
currentBonusX = currentBonusX + 50;
c++;
}
}
pf1.onEnterFrame = (pf2.onEnterFrame = movePlatform);
platformAmount++;
var pf = new Array(pf1, pf2);
platforms.push(pf);
allPlatforms.push(pf);
return(pf);
}
function movePlatform() {
this._y = this._y - platformSpeed;
if (this._y < 0) {
var _local2 = 0;
while (_local2 < platformAmount) {
if (platforms[_local2][0] == this) {
deactivatePlatform(_local2);
break;
}
_local2++;
}
_local2 = 0;
while (_local2 < allPlatforms.length) {
if (allPlatforms[_local2][0] == this) {
removePlatform(_local2);
break;
}
_local2++;
}
}
}
function spawnPlatforms() {
if ((--platformTimer) <= 0) {
createPlatform();
platformHoleSize = platformHoleSize + ((50 - platformHoleSize) / 15);
platformInterval = platformInterval + ((18 - platformInterval) / 15);
platformSpeed = platformSpeed + ((8 - platformSpeed) / 15);
platformTimer = platformInterval + Math.round((Math.random() * platformInterval) * 0.2);
}
}
function deactivatePlatform(platformNum) {
platforms[platformNum][0]._alpha = (platforms[platformNum][1]._alpha = 50);
platforms.splice(platformNum, 1);
platformAmount--;
}
function removePlatform(platformNum) {
allPlatforms[platformNum][0].removeMovieClip();
allPlatforms[platformNum][1].removeMovieClip();
allPlatforms.splice(platformNum, 1);
}
function createBonus(platform) {
var _local2 = platform.getNextHighestDepth();
var _local3 = Math.random();
var _local1;
if (_local3 < 0.9) {
_local1 = COIN1;
} else if (_local3 < 0.99) {
_local1 = COIN2;
} else {
_local1 = LIFE;
}
var _local4 = {bType:_local1};
return(platform.attachMovie(_local1, "bonus" + _local2, _local2, _local4));
}
function handleBonus() {
if (ball.hitTest(this._parent._x + this._x, this._parent._y + this._y, true)) {
if (this.bType == COIN1) {
score++;
} else if (this.bType == COIN2) {
score = score + 5;
} else if (this.bType == LIFE) {
changeLives(1);
}
this.play();
this.onEnterFrame = null;
}
}
stop();
ball._visible = (ceiling._visible = (statusbar._visible = true));
gameover._visible = (ballDie._visible = false);
var GRAVITY = 1.5;
var JUMP_VELOCITY = -15;
var ACCELERATION = 3;
var FRICTION = 0.8;
var MAX_X_SPEED = 30;
var HALF_BALL_WIDTH = 19;
var LEFT_BORDER = HALF_BALL_WIDTH;
var RIGHT_BORDER = (Stage.width - HALF_BALL_WIDTH);
var AVAILABLE_HEIGHT = (Stage.height - statusbar._height);
var COIN1 = "coin";
var COIN2 = "coin2";
var LIFE = "life";
ballDie.removeMovieClip();
var hasControl = true;
var xSpeed = 0;
var ySpeed = 0;
var xControl = 0;
var isInAir = true;
var isAtBottom = false;
var isInvincible = false;
ball.gotoAndStop("normal");
ball.swapDepths(4000);
var platforms = new Array();
var allPlatforms = new Array();
var platformId = 0;
var currentPlatform;
var platformSpeed = 2;
var platformInterval = 100;
var platformTimer = 0;
var platformHoleSize = 300;
var platformAmount = 0;
ceiling.swapDepths(2000);
var score = 0;
var lives = 3;
statusbar.swapDepths(3000);
ball.onEnterFrame = moveBall;
ceiling.onEnterFrame = handleCeiling;
onEnterFrame = spawnPlatforms;
Frame 5
saveScore(score);
gameover.swapDepths(3500);
ball._visible = (ceiling._visible = (statusbar._visible = (gameover._visible = (ballDie._visible = true))));
ballDie._x = ball._x;
ballDie._y = ball._y;
ballDie.onEnterFrame = moveBall;
ballDie.swapDepths(6000);
ballDie.gotoAndPlay("gameover");
ball.removeMovieClip();
Symbol 3 MovieClip [coin2] Frame 1
stop();
Symbol 3 MovieClip [coin2] Frame 10
this.removeMovieClip();
Symbol 5 MovieClip [coin] Frame 1
stop();
Symbol 5 MovieClip [coin] Frame 10
this.removeMovieClip();
Symbol 8 MovieClip [life] Frame 1
stop();
Symbol 8 MovieClip [life] Frame 10
this.removeMovieClip();
Symbol 45 MovieClip Frame 1
stop();
Symbol 45 MovieClip Frame 91
_root.isInvincible = false;
gotoAndStop ("normal");
Symbol 45 MovieClip Frame 92
play();
Symbol 45 MovieClip Frame 149
stop();
Symbol 47 MovieClip Frame 1
stop();
Symbol 50 MovieClip Frame 1
function updateStatus() {
lifeMeter.gotoAndStop(_root.lives + 1);
scoreTxt.text = _root.score + " points";
}
onEnterFrame = updateStatus;
Symbol 58 MovieClip Frame 1
function playAgain() {
_root.gotoAndStop("game");
}
function mainMenu() {
_root.gotoAndStop("menu");
}
resultTxt.text = ("You got " + _root.score) + " points.";
if (_root.canStoreCookie) {
bestScoreTxt.text = ("(your best score is " + _root.cookie.data.bestScore) + ")";
bestScoreTxt._visible = true;
} else {
bestScoreTxt._visible = false;
}
playAgainButton.onRelease = playAgain;
mainMenuButton.onRelease = mainMenu;