Frame 1
function nextLevel() {
lev++;
newLevel();
}
function quitGame() {
killLevel();
ballKillAll();
_root.targetScope._x = -250;
gotoAndStop ("menu");
}
function newGame() {
lev = 1;
oldLev = 0;
life = 3;
score = 0;
newLevel();
}
function loseLife() {
if (!lifeLost) {
lifeLost = true;
life--;
deletePlayer();
_root.targetScope._x = -250;
this.onEnterFrame = function () {
};
if (life <= 0) {
gotoAndStop ("gameOver");
} else {
gotoAndStop ("loseLife");
}
}
}
function deletePlayer() {
var _local1 = balls.length - 1;
while (_local1 >= 0) {
if (balls[_local1] == player) {
ballKill(_local1);
}
_local1--;
}
}
function newLevel() {
lifeLost = false;
hurryUp = false;
deathReason = "";
skipIntro = false;
if (!draw_level(lev)) {
gameComplete();
} else {
_root.gotoAndStop("game");
player.vx = 0;
player.vy = 0;
timeStart(99);
}
}
function killLevel() {
for (all in _root.levelMC) {
_root.levelMC[all].removeMovieClip();
}
for (all in _root.levelCollision) {
_root.levelCollision[all].removeMovieClip();
}
for (all in _root.levelWallMC) {
_root.levelWallMC[all].removeMovieClip();
}
}
function gameComplete() {
gotoAndStop ("gameComplete");
}
function addBall(x, y, type) {
if (oldLev == lev) {
return(true);
}
x = ((tileSize * x) + (tileSize / 2)) + randRange(-3, 3);
y = ((tileSize * y) + (tileSize / 2)) + randRange(-3, 3);
vx = 0;
vy = 0;
r = type;
m = r;
t = 2;
balls.push(new ball(x, y, vx, vy, r, m, t));
}
function draw_level(number) {
if (oldLev != number) {
ballKillAll();
}
level = new Array();
switch (number) {
case 1 :
subtitle = "Tutorial 1 : In the Beginning";
ball_start_x = 1;
ball_start_y = 3;
gui_x = 0;
gui_y = 0;
level[0] = new Array(150, 1, 3, 1, 150, 150, 150, 4);
level[1] = new Array(150, 1, 13, 5, 1, 1, 1, 1);
level[2] = new Array(150, 150, 151, 150, 150, 150, 150, 150);
level[3] = new Array(3, 2, 1, 1, 1, 1, 1, 200);
level[4] = new Array(150, 150, 150, 150, 150, 150, 150, 151);
level[5] = new Array(1, 1, 1, 1, 1, 4, 4, 4);
addBall(5, 3, 8);
break;
case 2 :
subtitle = "Tutorial 2 : Easy Movement";
ball_start_x = 0;
ball_start_y = 2;
gui_x = 3;
gui_y = 4;
level[0] = new Array(150, 150, 150, 150, 150, 150, 150, 151);
level[1] = new Array(150, 151, 150, 150, 150, 150, 150, 150);
level[2] = new Array(2, 3, 13, 103, 103, 103, 103, 200);
level[3] = new Array(150, 150, 150, 150, 150, 150, 150, 150);
level[4] = new Array(150, 150, 150, 150, 151, 150, 150, 150);
level[5] = new Array(151, 150, 150, 150, 150, 150, 150, 150);
addBall(2, 2, 20);
break;
case 3 :
subtitle = "Tutorial 3 : Pop the RED Ball";
ball_start_x = 0;
ball_start_y = 1;
gui_x = 5;
gui_y = 2;
level[0] = new Array(151, 150, 151, 150, 150, 150, 150, 150);
level[1] = new Array(2, 1, 1, 1, 1, 1, 1, 180);
level[2] = new Array(150, 150, 151, 150, 150, 150, 150, 151);
level[3] = new Array(1, 4, 180, 180, 1, 1, 3, 1);
level[4] = new Array(6, 1, 5, 3, 1, 13, 180, 6);
level[5] = new Array(1, 180, 180, 180, 180, 180, 180, 1);
addBall(3, 1, 20);
break;
case 4 :
subtitle = "Tutorial 4 : Oops - no friction!";
ball_start_x = 0;
ball_start_y = 3;
gui_x = 2;
gui_y = 1;
level[0] = new Array(105, 104, 150, 104, 104, 104, 105, 150);
level[1] = new Array(104, 104, 150, 104, 105, 104, 104, 150);
level[2] = new Array(151, 150, 150, 150, 150, 150, 150, 150);
level[3] = new Array(2, 104, 104, 104, 104, 105, 104, 200);
level[4] = new Array(150, 150, 150, 151, 150, 150, 150, 151);
level[5] = new Array(104, 105, 150, 104, 104, 104, 104, 104);
addBall(2, 3, 25);
break;
case 5 :
subtitle = "Around and Around";
ball_start_x = 0;
ball_start_y = 5;
gui_x = 3;
gui_y = 3;
level[0] = new Array(1, 1, 1, 1, 1, 1, 3, 1);
level[1] = new Array(1, 150, 150, 151, 150, 150, 150, 1);
level[2] = new Array(3, 150, 4, 9, 4, 4, 151, 1);
level[3] = new Array(1, 150, 4, 150, 150, 200, 150, 3);
level[4] = new Array(1, 150, 9, 151, 150, 150, 150, 1);
level[5] = new Array(2, 151, 1, 5, 1, 13, 1, 1);
addBall(4, 2, 10);
break;
case 6 :
subtitle = "2 by 4";
ball_start_x = 3;
ball_start_y = 2;
gui_x = 4;
gui_y = 0;
level[0] = new Array(150, 150, 151, 150, 150, 150, 150, 151);
level[1] = new Array(3, 1, 1, 13, 1, 1, 1, 1);
level[2] = new Array(1, 1, 1, 2, 3, 1, 1, 1);
level[3] = new Array(4, 9, 4, 4, 4, 4, 4, 4);
level[4] = new Array(6, 4, 4, 4, 4, 9, 4, 6);
level[5] = new Array(200, 3, 1, 1, 1, 5, 1, 200);
addBall(1, 1, 10);
addBall(6, 1, 30);
addBall(1, 4, 30);
addBall(6, 4, 10);
break;
case 7 :
subtitle = "Conveyor Confusion";
ball_start_x = 6;
ball_start_y = 0;
gui_x = 0;
gui_y = 5;
level[0] = new Array(200, 103, 103, 100, 102, 150, 2, 1);
level[1] = new Array(200, 100, 102, 102, 101, 150, 1, 13);
level[2] = new Array(180, 102, 102, 103, 101, 151, 6, 6);
level[3] = new Array(200, 101, 103, 101, 103, 150, 100, 100);
level[4] = new Array(151, 150, 101, 100, 102, 102, 102, 100);
level[5] = new Array(180, 150, 101, 102, 101, 101, 102, 102);
addBall(7, 1, 25);
break;
case 8 :
subtitle = "Danger! Spikes!";
ball_start_x = 0;
ball_start_y = 2;
gui_x = 0;
gui_y = 0;
level[0] = new Array(150, 104, 104, 104, 180, 104, 104, 180);
level[1] = new Array(3, 104, 105, 104, 104, 104, 104, 180);
level[2] = new Array(2, 104, 104, 104, 104, 104, 104, 180);
level[3] = new Array(13, 104, 104, 104, 104, 105, 104, 180);
level[4] = new Array(1, 104, 104, 104, 104, 104, 104, 180);
level[5] = new Array(180, 105, 104, 104, 180, 104, 104, 180);
addBall(2, 1, 15);
addBall(2, 2, 15);
addBall(2, 3, 15);
addBall(2, 4, 15);
addBall(3, 1, 15);
addBall(3, 2, 15);
addBall(3, 3, 15);
addBall(3, 4, 15);
addBall(4, 1, 15);
addBall(4, 2, 15);
addBall(4, 3, 15);
addBall(4, 4, 15);
break;
case 9 :
subtitle = "Moving Icely";
ball_start_x = 6;
ball_start_y = 0;
gui_x = 7;
gui_y = 1;
level[0] = new Array(103, 104, 103, 103, 105, 104, 2, 180);
level[1] = new Array(104, 150, 150, 150, 150, 151, 150, 150);
level[2] = new Array(101, 150, 100, 104, 102, 150, 9, 4);
level[3] = new Array(104, 151, 104, 150, 105, 151, 4, 4);
level[4] = new Array(104, 150, 104, 150, 104, 150, 151, 100);
level[5] = new Array(101, 104, 102, 151, 101, 105, 104, 102);
addBall(6, 2, 20);
addBall(6, 2, 15);
addBall(7, 2, 20);
addBall(6, 3, 15);
addBall(6, 3, 20);
break;
case 10 :
subtitle = "In the Middle";
ball_start_x = 3;
ball_start_y = 2;
gui_x = 3;
gui_y = 0;
level[0] = new Array(200, 150, 151, 150, 150, 150, 150, 200);
level[1] = new Array(8, 1, 1, 100, 1, 1, 1, 8);
level[2] = new Array(103, 103, 103, 2, 102, 102, 102, 102);
level[3] = new Array(1, 4, 1, 101, 1, 1, 3, 1);
level[4] = new Array(6, 1, 1, 101, 1, 13, 1, 6);
level[5] = new Array(200, 150, 150, 150, 151, 150, 150, 200);
addBall(1, 1, 10);
addBall(6, 1, 30);
addBall(1, 4, 30);
addBall(6, 4, 10);
break;
case 11 :
subtitle = "Slopes";
ball_start_x = 5;
ball_start_y = 5;
gui_x = 2;
gui_y = 3;
level[0] = new Array(150, 161, 162, 150, 150, 161, 1, 162);
level[1] = new Array(161, 163, 164, 162, 161, 163, 164, 1);
level[2] = new Array(1, 151, 150, 1, 1, 150, 161, 13);
level[3] = new Array(1, 162, 150, 150, 150, 150, 1, 163);
level[4] = new Array(164, 3, 1, 162, 150, 161, 5, 150);
level[5] = new Array(150, 151, 164, 200, 150, 2, 1, 162);
addBall(6, 4, 25);
addBall(6, 0, 15);
break;
case 12 :
subtitle = "3 Balls, 3 Holes";
ball_start_x = 7;
ball_start_y = 1;
gui_x = 4;
gui_y = 4;
level[0] = new Array(150, 150, 150, 151, 150, 150, 150, 1);
level[1] = new Array(200, 103, 5, 1, 3, 1, 102, 2);
level[2] = new Array(150, 151, 150, 150, 150, 150, 151, 1);
level[3] = new Array(200, 103, 103, 1, 1, 3, 102, 1);
level[4] = new Array(150, 150, 150, 150, 150, 151, 150, 1);
level[5] = new Array(200, 103, 103, 103, 1, 3, 102, 1);
addBall(2, 1, 20);
addBall(3, 3, 25);
addBall(4, 5, 30);
break;
case 13 :
subtitle = "Oooh - Circles";
ball_start_x = 2;
ball_start_y = 0;
gui_x = 1;
gui_y = 0;
level[0] = new Array(200, 150, 2, 1, 1, 1, 1, 1);
level[1] = new Array(1, 160, 1, 160, 1, 160, 1, 160);
level[2] = new Array(1, 3, 1, 1, 1, 1, 5, 1);
level[3] = new Array(160, 4, 160, 1, 160, 1, 160, 4);
level[4] = new Array(1, 1, 1, 3, 1, 13, 1, 1);
level[5] = new Array(1, 160, 1, 160, 1, 160, 1, 160);
addBall(7, 3, 25);
addBall(1, 3, 25);
break;
case 14 :
subtitle = "Push it Round";
ball_start_x = 0;
ball_start_y = 0;
gui_x = 3;
gui_y = 2;
level[0] = new Array(2, 150, 13, 1, 5, 1, 1, 1);
level[1] = new Array(1, 151, 1, 1, 1, 3, 1, 10);
level[2] = new Array(1, 150, 1, 150, 151, 150, 150, 11);
level[3] = new Array(1, 150, 5, 150, 4, 9, 4, 4);
level[4] = new Array(1, 3, 1, 150, 4, 150, 150, 150);
level[5] = new Array(164, 4, 163, 150, 9, 4, 4, 200);
addBall(0, 2, 15);
addBall(4, 1, 20);
break;
case 15 :
subtitle = "Ouch Spiky";
ball_start_x = 0;
ball_start_y = 0;
gui_x = 1;
gui_y = 0;
level[0] = new Array(2, 150, 180, 1, 5, 13, 180, 150);
level[1] = new Array(1, 180, 1, 1, 180, 3, 1, 180);
level[2] = new Array(1, 180, 1, 150, 180, 1, 180, 150);
level[3] = new Array(3, 150, 5, 180, 151, 9, 4, 4);
level[4] = new Array(1, 180, 1, 150, 180, 180, 180, 5);
level[5] = new Array(1, 4, 1, 180, 150, 200, 4, 4);
addBall(7, 5, 25);
break;
case 16 :
subtitle = "Ice Circles";
ball_start_x = 4;
ball_start_y = 5;
gui_x = 0;
gui_y = 5;
level[0] = new Array(104, 105, 104, 104, 104, 105, 104, 104);
level[1] = new Array(1, 160, 1, 160, 1, 160, 1, 160);
level[2] = new Array(104, 104, 105, 104, 104, 104, 104, 104);
level[3] = new Array(160, 4, 160, 1, 160, 3, 160, 4);
level[4] = new Array(104, 104, 104, 104, 105, 104, 104, 105);
level[5] = new Array(150, 160, 1, 160, 2, 160, 200, 160);
addBall(0, 0, 25);
addBall(0, 2, 25);
break;
case 17 :
subtitle = "A-Mazing";
ball_start_x = 2;
ball_start_y = 0;
gui_x = 1;
gui_y = 0;
level[0] = new Array(200, 150, 2, 160, 160, 3, 1, 1);
level[1] = new Array(1, 160, 1, 1, 160, 1, 160, 1);
level[2] = new Array(5, 1, 160, 1, 1, 1, 160, 5);
level[3] = new Array(160, 1, 160, 4, 160, 160, 160, 1);
level[4] = new Array(160, 3, 160, 1, 160, 1, 4, 1);
level[5] = new Array(160, 1, 1, 1, 160, 1, 1, 160);
addBall(5, 2, 30);
addBall(6, 4, 30);
break;
case 18 :
subtitle = "Ice Maze";
ball_start_x = 7;
ball_start_y = 0;
gui_x = 2;
gui_y = 1;
level[0] = new Array(180, 105, 104, 104, 104, 1, 151, 2);
level[1] = new Array(150, 104, 150, 180, 180, 104, 150, 104);
level[2] = new Array(1, 1, 150, 150, 105, 104, 150, 104);
level[3] = new Array(3, 180, 150, 1, 104, 151, 1, 1);
level[4] = new Array(1, 150, 150, 1, 180, 180, 1, 180);
level[5] = new Array(200, 151, 180, 104, 104, 104, 104, 150);
addBall(0, 4, 35);
break;
case 19 :
subtitle = "Conveyor Carnage";
ball_start_x = 6;
ball_start_y = 0;
gui_x = 0;
gui_y = 2;
level[0] = new Array(150, 103, 103, 1, 103, 1, 2, 1);
level[1] = new Array(180, 103, 5, 103, 12, 3, 1, 1);
level[2] = new Array(150, 103, 103, 1, 103, 103, 1, 5);
level[3] = new Array(200, 103, 4, 103, 103, 12, 1, 1);
level[4] = new Array(150, 103, 1, 103, 1, 103, 103, 1);
level[5] = new Array(180, 103, 1, 103, 3, 103, 12, 1);
addBall(2, 1, 25);
addBall(4, 5, 25);
addBall(2, 3, 25);
break;
case 20 :
subtitle = "It Takes All Types";
ball_start_x = 3;
ball_start_y = 2;
gui_x = 7;
gui_y = 1;
level[0] = new Array(105, 104, 105, 180, 104, 104, 104, 180);
level[1] = new Array(104, 180, 104, 151, 105, 150, 105, 150);
level[2] = new Array(200, 150, 1, 2, 1, 150, 104, 180);
level[3] = new Array(104, 180, 1, 1, 1, 180, 104, 104);
level[4] = new Array(103, 150, 180, 101, 150, 150, 180, 104);
level[5] = new Array(102, 101, 102, 103, 180, 105, 104, 104);
addBall(0, 1, 20);
addBall(0, 3, 15);
addBall(6, 2, 25);
addBall(5, 5, 30);
break;
default :
return(false);
}
killLevel();
balls.push(new ball(0, 0, 0, 0, 15, 15, 1));
_root.player = balls[balls.length - 1];
ballSetBounds(0, 0, 640, 480);
oldLev = number;
player.movie._x = (tileSize * ball_start_x) + (tileSize / 2);
player.movie._y = (tileSize * ball_start_y) + (tileSize / 2);
var _local2 = balls.length - 1;
while (_local2 >= 0) {
balls[_local2].vx = 0;
balls[_local2].vy = 0;
_local2--;
}
_root.gameGui._x = (tileSize * gui_x) + (tileSize / 2);
_root.gameGui._y = (tileSize * gui_y) + (tileSize / 2);
y = 0;
while (y <= tileYCount) {
x = 0;
while (x <= tileXCount) {
if (level[y][x] > 0) {
depth = (y * 12) + x;
tile = level[y][x];
tx = (x * tileSize) + (tileSize / 2);
ty = (y * tileSize) + (tileSize / 2);
if ((tile >= 150) && (tile <= 180)) {
place_brick = _root.levelWallMC.attachMovie("brick", "brick_" + depth, _root.levelWallMC.getNextHighestDepth(), {_x:tx, _y:ty});
place_brick.gotoAndStop(tile);
if (tile >= 150) {
place_brick = _root.levelCollision.attachMovie("brickCollision", "brick_" + depth, _root.levelCollision.getNextHighestDepth(), {_x:tx, _y:ty});
place_brick.gotoAndStop(tile);
}
tile = 99;
}
place_brick = _root.levelMC.attachMovie("brick", "brick_" + depth, _root.levelMC.getNextHighestDepth(), {_x:tx, _y:ty});
place_brick.gotoAndStop(tile);
}
x++;
}
y++;
}
return(true);
}
function timeStart(time) {
if (time != 0) {
timeDirection = -1;
} else {
timeDirection = 1;
}
currentTime = time;
startTime = getTimer();
timePauseLength = 0;
timePauseStart = 0;
}
function timePause() {
timePauseStart = getTimer();
}
function timeUnpause() {
timePauseLength = timePauseLength + (getTimer() - timePauseStart);
}
function timeStop() {
totalTime = getTimer() - startTime;
}
function timeGetSecs() {
return(Math.floor(timeGetMillisecs() / 1000));
}
function timeGet() {
return((timeGetSecs() * timeDirection) + currentTime);
}
function timeGetMillisecs() {
return((getTimer() - startTime) - timePauseLength);
}
function ballShoot() {
var _local1 = targetScope.power._totalframes / 2;
var _local3 = Math.abs(targetScope.power._currentframe - _local1);
var _local2 = ((_local1 - _local3) + 5) * 0.55;
player.vx = player.vx + (Math.cos(radians(targetScope._rotation - 90)) * _local2);
player.vy = player.vy + (Math.sin(radians(targetScope._rotation - 90)) * _local2);
}
function ballAmount() {
return(balls.length);
}
function ballScale(ball, percent) {
scale = (ball.radius * percent) / 5;
ball.movie._xscale = (ball.movie._yscale = scale);
}
function ballKill(b) {
balls[b].movie.removeMovieClip();
delete balls[b];
balls.splice(b, 1);
}
function ballKillAll() {
var _local1 = balls.length - 1;
while (_local1 >= 0) {
ballKill(_local1);
_local1--;
}
ballCount = 0;
}
function ballInBox(ball, x, y, width, height, debug) {
if (debug == true) {
trace((((((x + " : ") + y) + " : ") + width) + " : ") + height);
}
var _local3 = -0.6;
var _local2 = ball.radius * (ball._z / 100);
if (ball.movie._x < (x + _local2)) {
ball.movie._x = x + _local2;
ball.vx = ball.vx * _local3;
playWallBounce = true;
}
if (ball.movie._x > ((x + width) - _local2)) {
ball.movie._x = (x + width) - _local2;
ball.vx = ball.vx * _local3;
playWallBounce = true;
}
if (ball.movie._y < (y + _local2)) {
ball.movie._y = y + _local2;
ball.vy = ball.vy * _local3;
playWallBounce = true;
}
if (ball.movie._y > ((y + height) - _local2)) {
ball.movie._y = (y + height) - _local2;
ball.vy = ball.vy * _local3;
playWallBounce = true;
}
}
function isBallInBox(ball, x, y, width, height, debug) {
if (debug == true) {
trace((((((x + " : ") + y) + " : ") + width) + " : ") + height);
}
if (ball.movie._x > x) {
if (ball.movie._x < (x + width)) {
if (ball.movie._y > y) {
if (ball.movie._y < (y + height)) {
return(true);
}
}
}
}
return(false);
}
function ballReaction(b1, b2, dist, xdiff, ydiff) {
var _local12 = Math.atan2(ydiff, xdiff);
var _local4 = Math.cos(_local12);
var _local3 = Math.sin(_local12);
var _local5 = (_local4 * b1.vx) + (_local3 * b1.vy);
var _local9 = (_local4 * b1.vy) - (_local3 * b1.vx);
var _local6 = (_local4 * b2.vx) + (_local3 * b2.vy);
var _local8 = (_local4 * b2.vy) - (_local3 * b2.vx);
var _local14 = (_local5 * b1.mass) + (_local6 * b2.mass);
var _local13 = _local5 - _local6;
_local5 = (_local14 - (b2.mass * _local13)) / (b1.mass + b2.mass);
_local6 = _local13 + _local5;
b1.vx = (_local4 * _local5) - (_local3 * _local9);
b1.vy = (_local4 * _local9) + (_local3 * _local5);
b2.vx = (_local4 * _local6) - (_local3 * _local8);
b2.vy = (_local4 * _local8) + (_local3 * _local6);
b1.xmov = b1.xmov * 0.99;
b1.ymov = b1.ymov * 0.99;
b2.xmov = b2.xmov * 0.99;
b2.ymov = b2.ymov * 0.99;
var _local10 = (((b1.radius + b2.radius) + 2) - dist) / 2;
var _local11 = _local4 * _local10;
var _local7 = _local3 * _local10;
b1.movie._x = b1.movie._x - _local11;
b1.movie._y = b1.movie._y - _local7;
b2.movie._x = b2.movie._x + _local11;
b2.movie._y = b2.movie._y + _local7;
}
function isCollision(tx, ty) {
tile = currentTile(tx, ty);
if ((tile >= 150) && (tile <= 180)) {
if (tile >= 160) {
if (_root.levelCollision.hitTest(tx, ty, true)) {
if (tile == 180) {
playPop = true;
return(2);
}
playWallBounce = true;
return(1);
}
return(0);
}
playWallBounce = true;
return(1);
}
return(0);
}
function print_r(obj, indent) {
if (indent == null) {
indent = " ";
}
var _local2 = "";
for (item in obj) {
if (typeof(obj[item]) == "object") {
_local2 = _local2 + (((indent + "[") + item) + "] => Object\n");
} else {
_local2 = _local2 + (((((indent + "[") + item) + "] => ") + obj[item]) + newline);
}
_local2 = _local2 + print_r(obj[item], indent + " ");
}
return(_local2);
}
function soundAddSound(soundName) {
snd = sounds.push(new soundCreate(soundName, false));
return(snd - 1);
}
function soundAddMusic(soundName) {
music = sounds.push(new soundCreate(soundName, true));
return(music - 1);
}
function soundPlay(sound, loop) {
if ((sounds[sound].delay <= 0) || (loop > 1)) {
if (sounds[sound].isPlaying == false) {
sounds[sound].sound.start(0, loop);
sounds[sound].setVolume(100);
if (loop > 1) {
sounds[sound].isPlaying = true;
} else {
sounds[sound].isPlaying = false;
}
} else {
sounds[s].setVolume(100);
sounds[s].length = 0;
sounds[s].duration = 0;
}
sounds[sound].delay = 6;
}
}
function soundStop(sound) {
sounds[sound].sound.stop();
sounds[sound].isPlaying = false;
}
function soundCreate(soundName, isMusic) {
this.name = "sound_" + soundName;
this.soundName = soundName;
this.isPlaying = false;
this.delay = 0;
this.length = 0;
this.duration = 0;
if (isMusic == true) {
_root.createEmptyMovieClip(this.name, _root.getNextHighestDepth());
this.sound = new Sound(this.name);
} else {
this.sound = new Sound(_root);
}
this.sound.attachSound(soundName);
}
function soundFadeCreate(s, duration) {
if (sounds[s].isPlaying == true) {
sounds[s].length = duration;
sounds[s].duration = duration;
}
}
function soundUpdate() {
var _local1;
for (var _local2 in sounds) {
sounds[_local2].delay--;
if (sounds[_local2].length > 0) {
sounds[_local2].length--;
_local1 = sounds[_local2].length / sounds[_local2].duration;
_local1 = _local1 * 100;
sounds[_local2].sound.setVolume(_local1);
if (sounds[_local2].length <= 0) {
sounds[_local2].sound.stop();
sounds[_local2].isPlaying = false;
sounds[_local2].sound.setVolume(100);
}
}
}
}
function soundFadeAll() {
for (var _local1 in sounds) {
soundF.push(new soundFade(_local1, 30));
}
}
function start() {
intro.play();
}
function reset() {
_root.targetScope._x = -250;
_root.gotoAndStop("menu");
}
function quit() {
GameManager.getInstance().gameDone();
}
function enableConsole() {
gameActive = false;
GameManager.getInstance().enableConsole();
}
function disableConsole() {
gameActive = true;
GameManager.getInstance().disableConsole();
}
function preload() {
this.onEnterFrame = function () {
percentLoaded = (_root.getBytesLoaded() / _root.getBytesTotal()) * 100;
_root.preloader.gotoAndStop(Math.floor(percentLoaded));
if (percentLoaded >= 95) {
gotoAndStop ("loaded");
delete this.onEnterFrame;
}
};
}
_global.yspeed = 0;
_global.xspeed = 0;
_global.lev = 1;
_global.oldLev = 0;
_global.life = 0;
_global.lifeLost = false;
_global.score = 0;
_global.subtitleq = "";
_global.gameActive = false;
_global.hurryUp = false;
_global.deathReason = "";
_global.skipIntro = false;
_global.newTarget = "";
_global.tileSize = 80;
_global.tileXCount = 7;
_global.tileYCount = 5;
_global.playPop = false;
_global.playBallBounce = false;
_global.playWallBounce = false;
updateMenu = function () {
menuScope._x = player.movie._x;
menuScope._y = player.movie._y;
menuScope._rotation = -90 + degrees(Math.atan2(menuScope._y - _root._ymouse, menuScope._x - _xmouse));
};
updateGame = function () {
friction = 0.99;
power = 0.4;
playPop = false;
playBallBounce = false;
playWallBounce = false;
ballUpdate();
targetScope._x = player.movie._x;
targetScope._y = player.movie._y;
targetScope._rotation = -90 + degrees(Math.atan2(targetScope._y - _root._ymouse, targetScope._x - _xmouse));
gameTime = timeGet();
if (timeGet() <= 0) {
deathReason = "Out of Time";
loseLife();
}
if ((timeGet() <= 10) && (hurryUp == false)) {
hurryUp = true;
mcHurryUp.gotoAndPlay("play");
}
if (playPop == true) {
soundPlay(sndPop, 1);
}
if (playBallBounce == true) {
soundPlay(sndBallBounce, 1);
}
if (playWallBounce == true) {
soundPlay(sndWallBounce, 1);
}
if (ballAmount() <= 1) {
if (balls[0] == player) {
gotoAndStop ("levelComplete");
} else {
loseLife();
}
}
};
_global.startTime = 0;
_global.totalTime = 0;
_global.timeDirection = 1;
_global.timePauseLength = 0;
_global.timePauseStart = 0;
_global.currenttime = 0;
_global.ballXMax;
_global.ballYMax;
_global.ballXMin;
_global.ballYMin;
_global.ballFriction = 0.97;
_global.balls = Array();
_global.ballCount = 0;
ballDemo = function () {
ballSetBounds(0, 0, 550, 400);
var _local3 = 5;
var _local2 = _local3;
while (_local2 >= 1) {
var _local1 = 1;
while (_local1 <= _local2) {
x = ((5 - _local2) * 27) + 150;
y = ((_local1 * 31) - ((_local2 * 31) / 2)) + 200;
vx = 0;
vy = 0;
radius = 20;
mass = radius * 5;
balls.push(new ball(x, y, vx, vy, radius, mass));
_local1++;
}
_local2--;
}
balls.push(new ball(500, 115, -40, 1, 10, 25));
};
ball = function (x, y, vx, vy, r, m, t) {
ballCount++;
this._mcname = "ball" + ballCount;
this.movie = _root.ballClip.attachMovie("ball", this._mcname, ballClip.getNextHighestDepth());
this.movie._x = x;
this.movie._y = y;
this._z = 100;
this.movie._status = "alive";
this.vx = vx;
this.vy = vy;
this.vz = 0;
this.radius = r;
this.texture = t;
if ((m == 0) || (m == undefined)) {
this.mass = this.radius * 3;
} else {
this.mass = m;
}
this.movie.texture.gotoAndStop(t);
this.movie.t = t;
return(this);
};
ballSetBounds = function (xMin, yMin, xMax, yMax) {
ballXMax = xMax;
ballYMax = yMax;
ballXMin = xMin;
ballYMin = yMin;
};
ballReset = function (b) {
b = balls[b];
b.movie._x = 0;
b.movie._y = 0;
b.vx = 0;
b.vy = 0;
};
ballUpdate = function () {
var _local5;
var _local4;
var _local6;
var _local3;
var _local1 = balls.length - 1;
while (_local1 >= 0) {
if (balls[_local1].movie._status == "alive") {
shapeCollision(balls[_local1]);
if (Math.abs(balls[_local1].vx) < 0.1) {
balls[_local1].vx = 0;
}
if (Math.abs(balls[_local1].vy) < 0.1) {
balls[_local1].vy = 0;
}
var _local2 = balls.length - 1;
while (_local2 >= 0) {
if (_local2 != _local1) {
if (Math.abs(balls[_local1]._z - balls[_local2]._z) < 5) {
_local5 = balls[_local2].movie._x - balls[_local1].movie._x;
_local4 = balls[_local2].movie._y - balls[_local1].movie._y;
_local6 = (balls[_local1].radius + balls[_local2].radius) * (balls[_local1].radius + balls[_local2].radius);
_local3 = (_local5 * _local5) + (_local4 * _local4);
if (_local3 <= _local6) {
playBallBounce = true;
_local6 = balls[_local1].radius + balls[_local2].radius;
_local3 = Math.sqrt(_local3);
ballReaction(balls[_local1], balls[_local2], _local3, _local5, _local4);
}
}
}
_local2--;
}
}
switch (currentTile(balls[_local1].movie._x, balls[_local1].movie._y)) {
case 100 :
balls[_local1].vx = balls[_local1].vx * ballFriction;
balls[_local1].vy = balls[_local1].vy * ballFriction;
balls[_local1].vy = balls[_local1].vy + 0.2;
break;
case 101 :
balls[_local1].vx = balls[_local1].vx * ballFriction;
balls[_local1].vy = balls[_local1].vy * ballFriction;
balls[_local1].vy = balls[_local1].vy - 0.2;
break;
case 102 :
balls[_local1].vx = balls[_local1].vx * ballFriction;
balls[_local1].vy = balls[_local1].vy * ballFriction;
balls[_local1].vx = balls[_local1].vx - 0.2;
break;
case 103 :
balls[_local1].vx = balls[_local1].vx * ballFriction;
balls[_local1].vy = balls[_local1].vy * ballFriction;
balls[_local1].vx = balls[_local1].vx + 0.2;
break;
case 104 :
case 105 :
break;
case 200 :
boxSize = tileSize - balls[_local1].radius;
boxX = Math.floor(balls[_local1].movie._x / tileSize) * tileSize;
boxY = Math.floor(balls[_local1].movie._y / tileSize) * tileSize;
boxX = boxX + (balls[_local1].radius / 2);
boxY = boxY + (balls[_local1].radius / 2);
if (isBallInBox(balls[_local1], boxX, boxY, boxSize, boxSize)) {
balls[_local1].vz = -2;
}
break;
default :
balls[_local1].vx = balls[_local1].vx * ballFriction;
balls[_local1].vy = balls[_local1].vy * ballFriction;
}
ballInBox(balls[_local1], 0, 0, ballXMax, ballYMax);
balls[_local1].movie.texture._y = balls[_local1].movie.texture._y + (balls[_local1].vy / 2);
balls[_local1].movie.texture._x = balls[_local1].movie.texture._x + (balls[_local1].vx / 2);
if (balls[_local1].movie.texture._x > 53) {
balls[_local1].movie.texture._x = balls[_local1].movie.texture._x - 63;
}
if (balls[_local1].movie.texture._x < -53) {
balls[_local1].movie.texture._x = balls[_local1].movie.texture._x + 63;
}
if (balls[_local1].movie.texture._y > 53) {
balls[_local1].movie.texture._y = balls[_local1].movie.texture._y - 63;
}
if (balls[_local1].movie.texture._y < -53) {
balls[_local1].movie.texture._y = balls[_local1].movie.texture._y + 63;
}
ballScale(balls[_local1], balls[_local1]._z);
if (balls[_local1].vz != 0) {
boxSize = (tileSize * (balls[_local1]._z / 100)) + ((balls[_local1].radius * (balls[_local1]._z / 100)) * 2);
boxOffset = (tileSize - boxSize) / 2;
boxX = Math.floor(balls[_local1].movie._x / tileSize) * tileSize;
boxY = Math.floor(balls[_local1].movie._y / tileSize) * tileSize;
boxX = boxX + boxOffset;
boxY = boxY + boxOffset;
ballInBox(balls[_local1], boxX, boxY, boxSize, boxSize);
}
if (balls[_local1]._z < 0) {
balls[_local1].movie._status = "dead";
}
switch (balls[_local1].movie._status) {
case "splat" :
balls[_local1].movie.gotoAndPlay("splat");
balls[_local1].movie._status = "splatting";
balls[_local1].movie.texture.gotoAndStop(balls[_local1].texture);
balls[_local1].movie.texture.stop();
break;
case "dead" :
if (balls[_local1] == player) {
loseLife();
}
ballKill(_local1);
}
_local1--;
}
};
currentTile = function (x, y) {
brick_x = Math.floor(x / tileSize);
brick_y = Math.floor(y / tileSize);
return(level[brick_y][brick_x]);
};
_global.maxSpeed = 20;
shapeCollision = function (b) {
var _local13 = 0;
var _local7 = 24;
var _local11 = 2;
while (_local13 < _local11) {
((b.vx <= maxSpeed) ? (((b.vx >= (-maxSpeed)) ? 0 : ((b.vx = -maxSpeed)))) : ((b.vx = maxSpeed)));
((b.vy <= maxSpeed) ? (((b.vy >= (-maxSpeed)) ? 0 : ((b.vy = -maxSpeed)))) : ((b.vy = maxSpeed)));
b.movie._x = b.movie._x + (b.vx / _local11);
b.movie._y = b.movie._y + (b.vy / _local11);
b._z = b._z + (b.vz / _local11);
var _local4 = 0;
var _local9 = 0;
var _local8 = 0;
var _local3 = 1;
while (_local3 < _local7) {
var _local6 = b.movie._x + (b.radius * Math.sin(radians((_local3 * 360) / _local7)));
var _local5 = b.movie._y - (b.radius * Math.cos(radians((_local3 * 360) / _local7)));
colStat = isCollision(_local6, _local5);
switch (colStat) {
case 1 :
_local4++;
_local9 = _local9 + _local6;
_local8 = _local8 + _local5;
break;
case 2 :
b.movie._status = "splat";
}
_local3++;
}
if (_local4 > 0) {
_root.pointer._rotation = (degrees(Math.atan2(b.movie._x - (_local9 / _local4), b.movie._y - (_local8 / _local4))) * -1) + 90;
_root.pointer._x = b.movie._x - (b.radius * Math.sin(radians(_root.pointer._rotation + 90)));
_root.pointer._y = b.movie._y + (b.radius * Math.cos(radians(_root.pointer._rotation + 90)));
px = _root.pointer._x;
py = _root.pointer._y;
}
if ((_local4 > 0) && (_local4 < _local7)) {
ix = ((px - b.movie._x) / b.radius) * -1;
iy = ((py - b.movie._y) / b.radius) * -1;
speed = Math.sqrt((b.vx * b.vx) + (b.vy * b.vy)) * ballFriction;
var _local12 = (degrees(Math.atan2(b.vx, b.vy)) * -1) + 90;
var _local10 = ((2 * (_root.pointer._rotation - _local12)) + _local12) - 180;
_root.pointer._rotation = _local10 - 180;
b.vx = Math.sin(radians(_local10 + 90)) * speed;
b.vy = Math.cos(radians(_local10 + 90)) * (-speed);
while (isCollision(px, py)) {
b.movie._x = b.movie._x + ix;
b.movie._y = b.movie._y + iy;
px = b.movie._x - (ix * b.radius);
py = b.movie._y - (iy * b.radius);
}
}
_local13++;
}
};
_global.cDeg = 57.2957795130823;
_global.cRad = (Math.PI/180);
degrees = function (r) {
return(r * cDeg);
};
radians = function (d) {
return(d * cRad);
};
randRange = function (min, max, integer) {
if (integer == true) {
return(Math.floor(Math.random() * ((max - min) + 1)) + min);
}
return((Math.random() * ((max - min) + 1)) + min);
};
distance = function (x1, y1, x2, y2) {
xD = x1 - x2;
yD = y1 - y2;
return(Math.sqrt((xD * xD) + (yD * yD)));
};
sgn = function (number) {
if (number < 0) {
return(-1);
}
if (number > 0) {
return(1);
}
return(0);
};
_global.soundF = new Array();
_global.sounds = new Array();
preload();
stop();
Frame 5
start();
Frame 10
_global.sndMenu = soundAddMusic("menu");
_global.sndGame = soundAddMusic("game");
_global.sndBeep = soundAddSound("beep");
_global.sndPop = soundAddSound("pop");
_global.sndBallBounce = soundAddSound("ballBounce");
_global.sndWallBounce = soundAddSound("wallBounce");
Frame 15
stop();
enableConsole();
gameActive = false;
soundPlay(sndMenu, 999);
_root.b_play.onRelease = function () {
soundPlay(sndBeep, 1);
newGame();
};
_root.b_website.onRelease = function () {
soundPlay(sndBeep, 1);
getURL ("http://www.binarysun.co.uk/", "_blank");
};
onEnterFrame = function () {
soundUpdate();
updateMenu();
};
Instance of Symbol 39 MovieClip "targetScope" in Frame 15
onClipEvent (mouseDown) {
if (_root.gameActive == true) {
_alpha = 100;
power.gotoAndPlay(1);
}
}
onClipEvent (mouseUp) {
_alpha = 20;
if (_root.gameActive == true) {
_root.ballShoot();
}
power.gotoAndStop(1);
}
Instance of Symbol 39 MovieClip "menuScope" in Frame 15
onClipEvent (load) {
_alpha = 15;
_x = _root.menuPlayer._x;
_y = _root.menuPlayer._y;
power.gotoAndStop(1);
}
Instance of Symbol 10 MovieClip [ball] in Frame 15
onClipEvent (load) {
texture.gotoAndStop(2);
}
Instance of Symbol 10 MovieClip [ball] in Frame 15
onClipEvent (load) {
texture.gotoAndStop(2);
}
Instance of Symbol 10 MovieClip [ball] in Frame 15
onClipEvent (load) {
texture.gotoAndStop(2);
}
Instance of Symbol 10 MovieClip [ball] in Frame 15
onClipEvent (load) {
texture.gotoAndStop(2);
}
Frame 20
disableConsole();
gameActive = true;
messageLevel.level_title.text = "Level " + lev;
messageLevel.level_description.text = subtitle;
soundFadeCreate(sndMenu, 10);
soundPlay(sndGame, 999);
onEnterFrame = function () {
updateGame();
soundUpdate();
if (Key.isDown(32) || (Key.isDown(80))) {
timePause();
gotoAndStop ("pause");
}
};
stop();
Frame 25
stop();
enableConsole();
gameActive = false;
soundFadeCreate(sndGame, 8);
soundPlay(sndMenu, 999);
tTime = timeGet();
tOldScore = score;
tLevelScore = tTime * life;
tScore = tLevelScore + score;
tLives = life;
if (tTime >= 60) {
life++;
}
score = tScore;
_root.b_play.onRelease = function () {
soundPlay(sndBeep, 1);
nextLevel();
};
onEnterFrame = function () {
soundUpdate();
};
Frame 30
stop();
enableConsole();
soundFadeCreate(sndGame, 8);
_root.b_play.onRelease = function () {
soundPlay(sndBeep, 1);
timeUnpause();
skipIntro = true;
gotoAndStop ("game");
};
_root.b_menu.onRelease = function () {
soundPlay(sndBeep, 1);
quitGame();
};
onEnterFrame = function () {
soundUpdate();
};
Frame 36
stop();
enableConsole();
gameActive = false;
level_reason.text = deathReason;
soundFadeCreate(sndGame, 16);
_root.b_play.onRelease = function () {
soundPlay(sndBeep, 1);
newLevel();
};
onEnterFrame = function () {
soundUpdate();
};
Frame 41
stop();
enableConsole();
gameActive = false;
soundPlay(sndMenu, 999);
_root.b_play.onRelease = function () {
soundPlay(sndBeep, 1);
quitGame();
};
onEnterFrame = function () {
soundUpdate();
};
Frame 46
stop();
enableConsole();
gameActive = false;
soundPlay(sndMenu, 999);
tScore = score;
_root.b_play.onRelease = function () {
soundPlay(sndBeep, 1);
quitGame();
};
onEnterFrame = function () {
soundUpdate();
};
Symbol 3 MovieClip [texture] Frame 1
stop();
Symbol 9 MovieClip Frame 16
stop();
Symbol 10 MovieClip [ball] Frame 1
stop();
Symbol 10 MovieClip [ball] Frame 11
texture.gotoAndStop(t);
Symbol 10 MovieClip [ball] Frame 26
_status = "dead";
stop();
Symbol 17 Button
on (release) {
getURL ("http://www.binarysun.co.uk/", "_blank");
}
Symbol 18 MovieClip Frame 1
stop();
Symbol 18 MovieClip Frame 50
_root.gotoAndPlay("start");
Symbol 21 MovieClip Frame 1
stop();
Symbol 30 MovieClip Frame 1
stop();
Symbol 112 MovieClip [brick] Frame 1
stop();
Symbol 119 MovieClip [brickCollision] Frame 1
stop();
Symbol 151 MovieClip Frame 1
if (_root.skipIntro == true) {
gotoAndStop (51);
}
Symbol 151 MovieClip Frame 51
stop();
Symbol 153 MovieClip Frame 1
stop();
Symbol 153 MovieClip Frame 51
stop();
Symbol 154 MovieClip Frame 10
stop();