Frame 1
stop();
Frame 2
function absloc(target) {
point = new Object();
point.x = target._x;
point.y = target._y;
target._parent.localToGlobal(point);
return(point);
}
function ricochet(oldangle, impactangle) {
return((impactangle * 2) - oldangle);
}
function whites_exist() {
var _local2 = 0;
i = 0;
while (i < max_balls) {
if (!_root["b" + i].state) {
_local2 = 1;
}
i++;
}
return(_local2);
}
shots = 10;
level = 0;
spinny._rotation = 2;
ballhit_sfx = new Sound();
ballhit_sfx.attachSound("ball_hit.wav");
sidehit_sfx = new Sound();
sidehit_sfx.attachSound("side_hit.wav");
bling_sfx = new Sound();
bling_sfx.attachSound("bling.wav");
root_ball._visible = 0;
onMouseDown = function () {
_root.firing = 1;
};
onMouseUp = function () {
_root.firing = 0;
};
Frame 3
starting_balls = 2;
max_balls = starting_balls + level;
var i = 0;
while (i < max_balls) {
root_ball.duplicateMovieClip("b" + i, i);
var f = 1;
while (f) {
f = 0;
_root["b" + i]._x = (random(10) * 64) + 32;
_root["b" + i]._y = (random(7.5) * 64) + 32;
var j = 0;
while (j < i) {
if ((_root["b" + i]._x == _root["b" + j]._x) && (_root["b" + i]._y == _root["b" + j]._y)) {
f = 1;
j = i;
}
j++;
}
}
_root["b" + i].stop();
if (!i) {
_root["b" + i].gotoAndStop(4);
_root["b" + i].state = 3;
} else if (!(i % 4)) {
_root["b" + i].gotoAndStop(3);
_root["b" + i].state = 2;
} else {
_root["b" + i].state = 0;
}
i++;
}
Frame 5
moving = 0;
i = 1;
while (i < max_balls) {
ball = _root["b" + i];
if (ball.target._y) {
ball.target._y = ball.target._y + 0.2;
if (ball.target._y > 0) {
ball.target._y = 0;
} else {
x = absloc(ball.target).x;
y = absloc(ball.target).y;
j = 0;
while (j < max_balls) {
if ((i != j) && (_root["b" + j].hitTest(x, y, true))) {
startball = _root["b" + j];
if ((!j) && (ball.state == 1)) {
_root["b" + j]._x = -80;
shots++;
bling_sfx.start();
} else if (j) {
dx = _root["b" + i]._x - _root["b" + j]._x;
dy = _root["b" + i]._y - _root["b" + j]._y;
angle = (-Math.atan2(dx, dy)) / (Math.PI/180);
ball._rotation = ricochet(ball._rotation, angle + 90);
if ((!startball.state) && (ball.state == 1)) {
startball.gotoAndStop(2);
startball.state = 1;
} else if ((!ball.state) && (startball.state == 1)) {
ball.gotoAndStop(2);
ball.state = 1;
} else if ((ball.state == 2) && (startball.state == 1)) {
startball.gotoAndStop(1);
startball.state = 0;
} else if ((startball.state == 2) && (ball.state == 1)) {
ball.gotoAndStop(1);
ball.state = 0;
}
startball.target._y = ball.target._y;
startball._rotation = angle;
ball.target._y = ball.target._y + 1;
ballhit_sfx.start();
}
}
j++;
}
if ((x < 0) || (x > 640)) {
ball._rotation = ricochet(ball._rotation, 0);
x = absloc(ball.target).x;
y = absloc(ball.target).y;
sidehit_sfx.start();
}
if ((y < 0) || (y > 480)) {
ball._rotation = ricochet(ball._rotation, 90);
x = absloc(ball.target).x;
y = absloc(ball.target).y;
sidehit_sfx.start();
}
ball._x = x;
ball._y = y;
moving = 1;
}
}
i++;
}
if ((!moving) && (shots)) {
if (firing && (!cocked)) {
i = 0;
while (i < max_balls) {
if (_root["b" + i].hitTest(_xmouse, _ymouse, true)) {
startball = _root["b" + i];
if (!startball.state) {
startball.gotoAndStop(2);
startball.state = 1;
}
i = max_balls + 1;
spinny._x = startball._x;
spinny._y = startball._y;
spinny._visible = 1;
cocked = 1;
}
i++;
}
} else if (cocked && (!firing)) {
moving = 1;
cocked = 0;
shots--;
spinny._visible = 0;
startball.target._y = -32;
startball._rotation = spinny._rotation;
} else if (firing) {
spinny._rotation = spinny._rotation + 5;
}
}
if ((!((moving || (cocked)) || (shots > 0))) && (whites_exist())) {
i = 0;
while (i < max_balls) {
removeMovieClip(_root["b" + i]);
i++;
}
gotoAndPlay ("game over");
} else if ((whites_exist() || (moving)) || (cocked)) {
prevFrame();
play();
} else {
shots++;
level++;
gotoAndPlay (3);
}
Frame 6
stop();
Symbol 11 Button
on (release) {
play();
}