Frame 46
fscommand ("allowscale", false);
fscommand ("showmenu", false);
url = new String(_root._url);
trace((url + " ") + url.indexOf("kongregate.com"));
if (url.indexOf("kongregate.com") == -1) {
}
stop();
Frame 47
function spawnDot(newx, newy, silent) {
if (dots.length < maxobjects) {
count_born++;
dots.push(attachMovie("dot", "dot" + (numobjects++), getNextHighestDepth(), {position:new flash.geom.Point(newx, newy), size:0, age:0, health:100, pregnant:100, _x:position.x, _y:position.y}));
trace("created dot");
if (!silent) {
plop_born.start(0, 1);
}
} else {
trace("max number of objects reached");
}
}
function killDot(object) {
for (i in dots) {
if (dots[i] == object) {
dots.splice(i, 1);
object.removeMovieClip();
break;
}
}
trace("removed dot");
plop_die.start(0, 1);
count_die++;
}
function ageDot(object) {
object.age++;
object.size = 2 + (object.age * 0.002);
object.size = object.size * (object.health / 100);
if (object.size > 15) {
object.size = 15;
}
if (object.health < 0) {
killDot(object);
}
if ((object.pregnant > 100) && (object.health > 90)) {
spawnDot((object.position.x + (Math.random() * 10)) - 5, (object.position.y + (Math.random() * 10)) - 5);
object.pregnant = 0;
object.health = object.health - 30;
}
if (object.health > 400) {
object.health = 400;
}
}
function updateDots() {
distance_update_count = 0;
var _local1 = 0;
for (var _local2 in dots) {
ageDot(dots[_local2]);
_local1 = _local1 + dots[_local2].size;
switch (getNeighboursCount(dots[_local2], dots)) {
case 0 :
dots[_local2].health = dots[_local2].health - (1 * rule_healthscale);
break;
case 1 :
dots[_local2].health = dots[_local2].health - (0.25 * rule_healthscale);
break;
case 2 :
dots[_local2].health = dots[_local2].health + 0;
break;
case 3 :
dots[_local2].health = dots[_local2].health + 0;
break;
case 4 :
dots[_local2].health = dots[_local2].health + (1 * rule_healthscale);
dots[_local2].pregnant = dots[_local2].pregnant + (1 * rule_healthscale);
break;
default :
dots[_local2].health = dots[_local2].health - (0.5 * rule_healthscale);
}
if ((alternate == 1) || (alternate == 3)) {
dots[_local2].position = dots[_local2].position.add(keepDistance(dots[_local2], dots));
}
if (alternate == 2) {
dots[_local2].position = dots[_local2].position.add(stayInFrame(dots[_local2]));
}
dots[_local2]._x = dots[_local2].position.x;
dots[_local2]._y = dots[_local2].position.y;
dots[_local2]._xscale = 100 * dots[_local2].size;
dots[_local2]._yscale = dots[_local2]._xscale;
}
alternate++;
if (alternate > 3) {
alternate = 0;
}
biomass.push(_local1);
trace(_local1);
}
function keepDistance(object, objectlist) {
var _local3 = new flash.geom.Point(0, 0);
for (var _local4 in objectlist) {
if (objectlist[_local4] != object) {
if (sqrt(pow(objectlist[_local4].position.x - object.position.x, 2) + pow(objectlist[_local4].position.y - object.position.y, 2)) < (2 + ((object.size * objectlist[_local4].size) * rule_mindistance))) {
_local3 = _local3.add(object.position.subtract(objectlist[_local4].position));
distance_update_count++;
}
}
}
_local3.normalize(rule_collisionamount);
return(_local3);
}
function getNeighboursList(object, objectlist) {
delete neighbours;
neighbours = new Array();
for (var _local3 in objectlist) {
if (objectlist[_local3] != object) {
if (sqrt(pow(objectlist[_local3].position.x - object.position.x, 2) + pow(objectlist[_local3].position.y - object.position.y, 2)) < (rule_neighbourdistance + ((object.size * objectlist[_local3].size) * 2))) {
neighbours.push(objectlist[_local3]);
}
}
}
}
function getNeighboursCount(object, objectlist) {
var _local3 = 0;
for (var _local4 in objectlist) {
if (sqrt(pow(objectlist[_local4].position.x - object.position.x, 2) + pow(objectlist[_local4].position.y - object.position.y, 2)) < (rule_neighbourdistance + ((object.size * objectlist[_local4].size) * 2))) {
_local3++;
}
}
return(_local3 - 1);
}
function drawConnect(object1, object2) {
with (_root) {
drawing.lineStyle(2, 16777215, 30);
drawing.moveTo(object1.position.x, object1.position.y);
drawing.lineTo(object2.position.x, object2.position.y);
}
}
function startDraw() {
drawing.removeMovieClip();
createEmptyMovieClip("drawing", this.getNextHighestDepth());
for (var _local3 in dots) {
getNeighboursList(dots[_local3], dots);
for (var _local2 in neighbours) {
drawConnect(dots[_local3], neighbours[_local2]);
}
}
}
function stayInFrame(object) {
if (sqrt(pow(250 - object.position.x, 2) + pow(250 - object.position.y, 2)) > 200) {
var _local1 = new flash.geom.Point(250 - object.position.x, 250 - object.position.y);
_local1.x = _local1.x / 200;
_local1.y = _local1.y / 200;
return(_local1);
}
return(new flash.geom.Point(0, 0));
}
function updateBiomass() {
biomass_average = 0;
while (biomass.length > 20) {
biomass.shift();
}
for (var _local1 in biomass) {
biomass_average = biomass_average + biomass[_local1];
}
biomass_average = Math.round(biomass_average / biomass.length) * 10;
if (biomass_average > biomass_peak) {
biomass_peak = biomass_average;
}
}
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);
}
function nullify(variable, targetlength) {
while (variable.toString().length < targetlength) {
variable = "0" + variable;
}
return(variable);
}
function reset() {
trace("RESET!");
drawing.removeMovieClip();
blur.removeMovieClip();
play();
}
distance = flash.geom.Point.distance;
pow = Math.pow;
sqrt = Math.sqrt;
var plop_die = new Sound();
plop_die.attachSound("plop_die");
var plop_born = new Sound();
plop_born.attachSound("plop_born");
var go = true;
var dots = new Array();
var neighbours = new Array();
var numobjects = 0;
var PI = Math.PI;
var alternate = 0;
var alternate_draw = 0;
var biomass = new Array(0, 0, 0, 0);
var biomass_average = 0;
var biomass_peak = 0;
var count_born = 0;
var count_die = 0;
var distance_update = true;
var distance_update_count = 0;
var rule_mindistance = 2;
var rule_collisionamount = 1;
var rule_neighbourdistance = 30;
var rule_healthscale = 2;
var maxobjects = 30;
var timebase = getTimer();
var timeleft = "X:XX";
var i = 0;
while (i < 30) {
spawnDot((Math.random() * 300) + 100, (Math.random() * 300) + 100, 1);
i++;
}
this.onEnterFrame = function () {
if ((timer(120000, 1) < 0) || (dots.length == 0)) {
attachMovie("blur", "blur", getNextHighestDepth());
biomass_average = nullify(biomass_average, 7);
biomass_peak = nullify(biomass_peak, 7);
count_born = nullify(count_born, 4);
count_die = nullify(count_die, 4);
attachMovie("scoreboard", "scoreboard", getNextHighestDepth(), {_x:250, _y:250});
for (i in dots) {
dots[i].removeMovieClip();
}
delete dots;
delete onEnterFrame;
} else {
updateDots();
updateBiomass();
timeleft = timer(120000);
if (alternate_draw > 2) {
startDraw();
alternate_draw = 0;
} else {
alternate_draw++;
}
}
};
stop();
Frame 48
for (i in dots) {
dots[i].removeMovieClip();
}
delete dots;
delete onEnterFrame;
gotoAndStop (47);
Frame 49
for (i in dots) {
dots[i].removeMovieClip();
}
drawing.removeMovieClip();
blur.removeMovieClip();
delete dots;
delete onEnterFrame;
Symbol 14 Button
on (press) {
_root.reset();
this.removeMovieClip();
}
Symbol 16 MovieClip [blur] Frame 1
var myBitmapData = (new flash.display.BitmapData(500, 500, false, 6684723));
myBitmapData.draw(_root);
var mc = this.createEmptyMovieClip("mc", this.getNextHighestDepth());
mc.attachBitmap(myBitmapData, this.getNextHighestDepth());
mc.cacheAsBitmap = true;
var filter = (new flash.filters.BlurFilter(5, 5, 2));
var recursions = 0;
mc.onEnterFrame = function () {
if (recursions <= 10) {
myBitmapData.applyFilter(myBitmapData, myBitmapData.rectangle, new flash.geom.Point(0, 0), filter);
trace(("blurred " + recursions) + "times");
} else {
delete this.onEnterFrame;
}
recursions++;
};
stop();
Symbol 19 MovieClip [fps_meter] Frame 1
#initclip 1
FPS = function () {
this.onEnterFrame = function () {
this.fc++;
};
setInterval(this, "calc", 1000);
};
var p = ((FPS.prototype = new MovieClip()));
p.calc = function () {
this.dp.text = this.fc;
this.fc = 0;
};
Object.registerClass("fps_meter", FPS);
#endinitclip
Symbol 21 MovieClip [dot] Frame 1
this.onPress = function () {
if (Key.isDown(17)) {
_parent.killDot(this);
}
this.onEnterFrame = function () {
position.x = _root._xmouse;
position.y = _root._ymouse;
};
trace("pressed!");
};
this.onRelease = function () {
delete this.onEnterFrame;
trace("let go");
};
this.onReleaseOutside = this.onRelease;
Symbol 28 Button
on (press) {
play();
}
Symbol 35 Button
on (press) {
gotoAndStop (49);
}
Symbol 37 Button
on (press) {
gotoAndStop (47);
}