Frame 1
stop();
Frame 2
function verlet(ball) {
var _local4 = ball.mc._x;
var _local3 = ball.mc._y;
ball.mc._x = ball.mc._x + ((ball.mc._x - ball.oldx) * drag);
ball.mc._y = ball.mc._y + ((ball.mc._y - ball.oldy) * drag);
ball.mc._y = ball.mc._y + ((grav * dt) * dt);
if (ball.mc._visible) {
katet_a = _local4 - ball.mc._x;
katet_b = _local3 - ball.mc._y;
resultat_rad = Math.atan2(katet_a, katet_b);
ball.mc._rotation = ((-resultat_rad) / Math.PI) * 180;
_root.speed = Math.sqrt(Math.pow(katet_a, 2) + Math.pow(katet_b, 2));
}
ball.oldx = _local4;
ball.oldy = _local3;
}
function constraints(ball0, ball1) {
var _local7 = new flash.geom.Point(ball0.mc._x, ball0.mc._y);
var _local6 = new flash.geom.Point(ball1.mc._x, ball1.mc._y);
var _local1 = _local6.subtract(_local7);
var _local5 = Math.sqrt(_local1.x * _local1.x) + Math.sqrt(_local1.y * _local1.y);
var _local4 = ((_local5 - restlength) / _local5) * ((ball0.mass * 1) + (ball1.mass * 1));
ball0.mc._x = ball0.mc._x + (((ball0.mass * 1) * _local1.x) * _local4);
ball0.mc._y = ball0.mc._y + (((ball0.mass * 1) * _local1.y) * _local4);
ball1.mc._x = ball1.mc._x - (((ball1.mass * 1) * _local1.x) * _local4);
ball1.mc._y = ball1.mc._y - (((ball1.mass * 1) * _local1.y) * _local4);
return(undefined);
}
function lockOn(xpos, ypos) {
if (Math.sqrt(Math.pow(xpos - particles[4].mc._x, 2) + Math.pow(ypos - particles[4].mc._y, 2)) < 200) {
_root.lock_x = xpos;
_root.lock_y = ypos;
_root.dragging = true;
var _local2 = 0;
while (_local2 < (_root.particles.length - 1)) {
_root[("ball" + _local2) + "_mc"]._x = ball4_mc._x;
_root[("ball" + _local2) + "_mc"]._y = ball4_mc._y;
_root.particles[_local2].oldx = ball4_mc._x;
_root.particles[_local2].oldy = ball4_mc._y;
_local2++;
}
}
}
function timer(countdown, test) {
seconds = Math.round(((countdown - getTimer()) + timebase) / 1000);
minutes = Math.floor(seconds / 60);
seconds = seconds % 60;
if (seconds.toString().length < 2) {
seconds = "0" + seconds;
}
if (test) {
return((countdown - getTimer()) + timebase);
}
return((minutes + ":") + seconds);
}
var t = 0;
var ct = 0;
var dt = 0;
var particles = new Array();
attachMovie("terrain_below", "terrain_below", _root.getNextHighestDepth());
i = 0;
while (i < 5) {
attachMovie("ball", ("ball" + i) + "_mc", _root.getNextHighestDepth());
var ball = new Object();
_root[("ball" + i) + "_mc"]._x = 250;
_root[("ball" + i) + "_mc"]._y = 250;
_root[("ball" + i) + "_mc"]._visible = false;
ball.oldx = _root[("ball" + i) + "_mc"]._x;
ball.oldy = _root[("ball" + i) + "_mc"]._y;
ball.mc = _root[("ball" + i) + "_mc"];
ball.mass = 0.35;
ball.speed = 0;
particles.push(ball);
i++;
}
createEmptyMovieClip("lines", _root.getNextHighestDepth());
attachMovie("pickup", "pickup", _root.getNextHighestDepth());
attachMovie("arrow", "arrow", _root.getNextHighestDepth());
attachMovie("score", "score_clip", _root.getNextHighestDepth());
particles[4].speed = 0.15;
particles[4].mass = 0.05;
particles[4].mc._visible = true;
particles[0].mass = 0.001;
var grav = 0;
var drag = 0.995;
counter = 0;
timebase = getTimer();
timeleft = "X:XX";
score = 0;
var restlength = 20;
_root.onEnterFrame = function (Void) {
t++;
dt = t - ct;
ct = t;
var _local4 = 1;
while (_local4 < particles.length) {
var _local3 = particles[_local4];
verlet(_local3);
xmove = Math.sin((_local3.mc._rotation * Math.PI) / 180) * _local3.speed;
_local3.mc._x = _local3.mc._x + xmove;
_local3.mc._y = _local3.mc._y - (Math.cos((_local3.mc._rotation * Math.PI) / 180) * _local3.speed);
_local4++;
}
if (_root.dragging) {
particles[0].mc._x = particles[0].mc._x + ((_root.lock_x - particles[0].mc._x) * 0.25);
particles[0].mc._y = particles[0].mc._y + ((_root.lock_y - particles[0].mc._y) * 0.25);
constraints(particles[0], particles[1]);
constraints(particles[1], particles[2]);
constraints(particles[2], particles[3]);
constraints(particles[3], particles[4]);
}
lines.drawLines(_root.dragging);
_root._x = (-particles[4].mc._x) + 250;
_root._y = (-particles[4].mc._y) + 250;
if (counter > 2) {
tmpdepth = _root.getNextHighestDepth();
_root.attachMovie("bubbles", "bubbles_" + tmpdepth, tmpdepth);
_root["bubbles_" + tmpdepth]._x = particles[4].mc._x;
_root["bubbles_" + tmpdepth]._y = particles[4].mc._y;
counter = 0;
}
_root.score_clip._x = particles[4].mc._x;
_root.score_clip._y = particles[4].mc._y;
_root.arrow._x = particles[4].mc._x;
_root.arrow._y = particles[4].mc._y;
katet_a = _root.arrow._x - _root.pickup._x;
katet_b = _root.arrow._y - _root.pickup._y;
resultat_rad = Math.atan2(katet_a, katet_b);
_root.arrow._rotation = ((-resultat_rad) / Math.PI) * 180;
dist_to_pickup = Math.sqrt(Math.pow(katet_a, 2) + Math.pow(katet_b, 2));
if ((dist_to_pickup > 250) && (_root.arrow._alpha < 110)) {
_root.arrow._alpha = _root.arrow._alpha + 10;
} else if (_root.arrow._alpha > -10) {
_root.arrow._alpha = _root.arrow._alpha - 10;
}
if (dist_to_pickup < 60) {
score = score + 100;
pickup._x = (Math.random() * 800) - 400;
pickup._y = (Math.random() * 800) - 400;
}
katet_a = particles[4].mc._x;
katet_b = particles[4].mc._y;
dist_to_center = Math.sqrt(Math.pow(katet_a, 2) + Math.pow(katet_b, 2));
if (dist_to_center > 900) {
trace("outside area!");
particles[4].mc._x = 0;
particles[4].mc._y = 0;
particles[4].oldx = 0;
particles[4].oldy = 0;
}
counter++;
_root.timeleft = timer(120000, 0);
if (timer(120000, 1) <= 0) {
trace("time's up!");
_root.attachMovie("blur", "blur", _root.getNextHighestDepth());
var _local6 = new flash.geom.Matrix();
_local6.translate(_root._x, _root._y);
var _local5 = new flash.display.BitmapData(500, 500, false, 288);
_local5.draw(_root, _local6);
var _local7 = this.createEmptyMovieClip("mc", this.getNextHighestDepth());
_local7.attachBitmap(_local5, this.getNextHighestDepth());
var _local8 = new flash.filters.BlurFilter(20, 20, 2);
_local5.applyFilter(_local5, _local5.rectangle, new flash.geom.Point(0, 0), _local8);
_root.onEnterFrame = function (Void) {
};
play();
}
};
lines.drawLines = function (doDraw) {
this.createEmptyMovieClip("drawing", this.getNextHighestDepth());
if (doDraw) {
this.drawing.clear();
this._alpha = 100;
this.drawing.lineStyle(2, 16777215, 100, true, "none", "round", "miter", 1);
this.drawing.moveTo(_root.ball0_mc._x, _root.ball0_mc._y);
var _local3 = 1;
while (_local3 < _root.particles.length) {
this.drawing.lineTo(_root[("ball" + _local3) + "_mc"]._x, _root[("ball" + _local3) + "_mc"]._y);
_local3++;
}
} else {
this._alpha = this._alpha - 5;
}
};
var mouseListener = new Object();
mouseListener.onMouseUp = function () {
_root.dragging = false;
};
Mouse.addListener(mouseListener);
stop();
Frame 3
arrow.removeMovieClip();
lines.removeMovieClip();
pickup.removeMovieClip();
score_clip.removeMovieClip();
terrain_below.removeMovieClip();
particles[4].mc.removeMovieClip();
particles[3].mc.removeMovieClip();
particles[2].mc.removeMovieClip();
particles[1].mc.removeMovieClip();
particles[0].mc.removeMovieClip();
delete particles;
_x = 0;
_y = 0;
_root.attachMovie("scoreboard", "scoreboard", _root.getNextHighestDepth());
_root.scoreboard._x = 250;
_root.scoreboard._y = 250;
while (score.toString().length < 7) {
score = "0" + score;
}
stop();
Symbol 5 Button
on (press) {
_root.blur.removeMovieClip();
_root.prevFrame();
this.removeMovieClip();
}
Symbol 7 MovieClip [blur] Frame 1
Symbol 9 MovieClip [bubbles] Frame 1
trace((("bubbles spawned at x: " + _x) + " y: ") + _y);
rotspeed = Math.random() * 5;
xmove = (Math.random() * 4) - 2;
ymove = (Math.random() * 4) - 2;
_rotation = (Math.random() * 360);
_alpha = 50;
this.onEnterFrame = function () {
_rotation = (_rotation + rotspeed);
_alpha = (_alpha - 4);
_x = (_x + xmove);
_y = (_y + ymove);
if (_alpha <= 0) {
removeMovieClip(this);
}
};
stop();
Symbol 17 MovieClip Frame 1
this.onPress = function () {
_root.lockOn(this._x, this._y);
};
Symbol 33 Button
on (press) {
play();
}