Combined Code
movieClip 2 Rock {
}
movieClip 4 Mon {
}
movieClip 6 Grass {
}
frame 1 {
var allGrass = new Array();
var allRock = new Array();
var alive = new Array();
var dead = new Array();
var neighbors = new Array();
var overpop = 40;
var curEnt;
var monX = (Math.floor(Math.random() * 3) - 1) * 10;
var monY = (Math.floor(Math.random() * 3) - 1) * 10;
var nomNom = false;
onLoad = function () {
var v3 = Math.floor(Math.random() * 64) * 10;
var v4 = Math.floor(Math.random() * 48) * 10;
var v6 = 0;
while (v6 < 10) {
v3 = Math.floor(Math.random() * 64) * 10;
v4 = Math.floor(Math.random() * 48) * 10;
curEnt = _root.attachMovie('Grass', 'Grass', this.getNextHighestDepth(), {'_x': v3, '_y': v4});
allGrass.push(curEnt);
++v6;
}
v6 = 0;
while (v6 < 2) {
v3 = Math.floor(Math.random() * 64) * 10;
v4 = Math.floor(Math.random() * 48) * 10;
var v5 = 0;
while (v5 < 30) {
curEnt = _root.attachMovie('Rock', 'Rock', this.getNextHighestDepth(), {'_x': v3, '_y': v4});
allRock.push(curEnt);
if (Math.floor(Math.random() * 100) > 50) {
if (Math.floor(Math.random() * 100) > 50) {
v3 += 10;
} else {
v3 -= 10;
}
} else {
if (Math.floor(Math.random() * 100) > 50) {
v4 += 10;
} else {
v4 -= 10;
}
}
++v5;
}
++v6;
}
v3 = Math.floor(Math.random() * 64) * 10;
v4 = Math.floor(Math.random() * 48) * 10;
_root.attachMovie('Mon', 'Mon', this.getNextHighestDepth(), {'_x': v3, '_y': v4});
};
onEnterFrame = function () {
var v9 = 0;
while (v9 < allGrass.length) {
if (Math.floor(Math.random() * 100) + 1 > 70) {
neighbors = new Array();
var v8 = 0;
while (v8 < allGrass.length) {
if (v8 != v9 && allGrass[v8]._x < allGrass[v9]._x + 20 && allGrass[v8]._x > allGrass[v9]._x - 20 && allGrass[v8]._y < allGrass[v9]._y + 20 && allGrass[v8]._y > allGrass[v9]._y - 20) {
neighbors.push(v8);
}
++v8;
}
overpop = 30;
v8 = 0;
while (v8 < allRock.length) {
var v5 = allGrass[v9]._x - 10;
while (v5 < allGrass[v9]._x + 20) {
var v3 = allGrass[v9]._y - 10;
while (v3 < allGrass[v9]._y + 20) {
if (allRock[v8]._x == v5 && allRock[v8]._y == v3) {
overpop -= 15;
}
v3 += 10;
}
v5 += 10;
}
++v8;
}
if (Math.floor(Math.random() * 100) + 1 > neighbors.length * overpop) {
var v7 = allGrass[v9]._x;
var v6 = allGrass[v9]._y;
if (Math.floor(Math.random() * 100) < 66) {
if (Math.floor(Math.random() * 100) < 50) {
v7 += 10;
} else {
v7 -= 10;
}
}
if (Math.floor(Math.random() * 100) < 66) {
if (Math.floor(Math.random() * 100) < 50) {
v6 += 10;
} else {
v6 -= 10;
}
}
var v4 = true;
if (v7 < 0 || v7 > Stage.width) {
v4 = false;
}
if (v4 == true) {
if (v6 < 0 || v6 > Stage.height) {
v4 = false;
}
}
if (v4 == true) {
if (v7 == Mon._x && v6 == Mon._y) {
v4 = false;
}
}
if (v4 == true) {
v8 = 0;
while (v8 < alive.length) {
if (alive[v8]._x == v7 && alive[v8]._y == v6) {
v4 = false;
}
++v8;
}
}
if (v4 == true) {
v8 = 0;
while (v8 < neighbors.length) {
if (allGrass[neighbors[v8]]._x == v7 && allGrass[neighbors[v8]]._y == v6) {
v4 = false;
}
++v8;
}
}
if (v4 == true) {
if (overpop < 30) {
v8 = 0;
while (v8 < allRock.length) {
if (allRock[v8]._x == v7 && allRock[v8]._y == v6) {
v4 = false;
}
++v8;
}
}
}
if (v4 == true) {
curEnt = _root.attachMovie('Grass', 'Grass', this.getNextHighestDepth(), {'_x': v7, '_y': v6});
alive.push(curEnt);
}
} else {
dead.push(v9);
}
}
++v9;
}
v9 = 0;
while (v9 < alive.length) {
allGrass.push(alive[v9]);
++v9;
}
alive = new Array();
v9 = 0;
while (v9 < dead.length) {
allGrass[dead[v9]].removeMovieClip();
allGrass.splice(dead[v9], 1);
++v9;
}
dead = new Array();
nomNom = false;
v9 = 0;
while (v9 < allGrass.length) {
if (nomNom == false && allGrass[v9]._x < Mon._x + 40 && allGrass[v9]._x > Mon._x - 40 && allGrass[v9]._y < Mon._y + 40 && allGrass[v9]._y > Mon._y - 40) {
Mon._x = allGrass[v9]._x;
Mon._y = allGrass[v9]._y;
dead.push(v9);
nomNom = true;
}
++v9;
}
v9 = 0;
while (v9 < dead.length) {
allGrass[dead[v9]].removeMovieClip();
allGrass.splice(dead[v9], 1);
++v9;
}
dead = new Array();
if (nomNom == false) {
if (Math.floor(Math.random() * 100) > 90) {
monX = (Math.floor(Math.random() * 3) - 1) * 10;
}
if (Math.floor(Math.random() * 100) > 90) {
monY = (Math.floor(Math.random() * 3) - 1) * 10;
}
if (Mon._x + monX > -10 && Mon._x + monX < 640) {
Mon._x += monX;
} else {
monX = (Math.floor(Math.random() * 3) - 1) * 10;
}
if (Mon._y + monY > -10 && Mon._y + monY < 480) {
Mon._y += monY;
} else {
monY = (Math.floor(Math.random() * 3) - 1) * 10;
}
}
if (allGrass.length == 0) {
xm = Math.floor(Math.random() * 64) * 10;
ym = Math.floor(Math.random() * 48) * 10;
curEnt = _root.attachMovie('Grass', 'Grass', this.getNextHighestDepth(), {'_x': xm, '_y': ym});
allGrass.push(curEnt);
}
movFrameRate.t = getTimer();
movFrameRate.frameRate = Math.round(1000 / (movFrameRate.t - movFrameRate.o));
movFrameRate.o = movFrameRate.t;
};
}
movieClip 9 {
}