Frame 1
Stage.scaleMode = "noscale";
_quality = "medium";
Frame 3
_root.levelGrid.playLevel(1);
stop();
Symbol 9 MovieClip [block1] Frame 1
Symbol 11 MovieClip [levelEntrance] Frame 1
_root.lemmingLayer.lemmingEntranceX = _x + 16;
_root.lemmingLayer.lemmingEntranceY = _y - 10;
Symbol 14 MovieClip [lemming] Frame 1
function killLemming() {
_root.scoreBox.lemmingsOut--;
if (_root.scoreBox.lemmingsOut < 0) {
_root.scoreBox.lemmingsOut = 0;
}
if ((_root.scoreBox.lemmingsOut == 0) and (_parent.totalLemmings == _parent.maxLemmings)) {
_parent.endlevelcountdown = 30;
_root.levelGrid.endLevel();
}
_alpha = 50;
deathdirection = 2 - random(5);
this.onEnterFrame = function () {
_y = (_y-1);
_x = (_x + deathdirection);
};
}
function exitLemming() {
_root.scoreBox.lemmingsOut--;
_root.scoreBox.lemmingsRescued++;
if ((_root.scoreBox.lemmingsOut == 0) and (_parent.totalLemmings == _parent.maxLemmings)) {
_root.levelGrid.endLevel();
}
this.removeMovieClip();
}
function checkObjects() {
var currentSquare = _root.levelGrid.gridValue(xgrid, ygrid);
if (currentSquare == "t") {
ymom = -6.5;
_y = (_y + ymom);
if (Math.abs(xmom) < walkSpeed) {
if (goingRight) {
xmom = walkSpeed;
} else {
xmom = -walkSpeed;
}
}
onGround = false;
} else if (currentSquare == "s") {
ymom = -10;
if (Math.abs(xmom) < walkSpeed) {
if (goingRight) {
xmom = walkSpeed;
} else {
xmom = -walkSpeed;
}
}
_y = (_y + ymom);
onGround = false;
} else if (currentSquare == "l") {
ymom = -6;
xmom = -5.2;
_y = (_y + ymom);
_x = (_x + xmom);
onGround = false;
goingRight = false;
lg._xscale = -100;
} else if (currentSquare == "r") {
ymom = -6;
xmom = 5.2;
_y = (_y + ymom);
_x = (_x + xmom);
goingRight = true;
onGround = false;
lg._xscale = 100;
} else if (currentSquare == "d") {
killLemming();
} else if (currentSquare == "e") {
exitLemming();
} else {
return(false);
}
return(true);
}
function collisionTest() {
xmom = xmom * friction;
ymom = ymom + gravity;
_y = (_y + ymom);
xgrid = Math.floor(_x / 32);
xrem = _x - (xgrid * 32);
ygrid = Math.floor(_y / 32);
yrem = _y - (ygrid * 32);
if (!checkObjects()) {
if (ymom > 0) {
var squareBelow = _root.levelGrid.gridValue(xgrid, ygrid + 1);
if ((squareBelow == "x") || (ygrid == 9)) {
_y = ((ygrid * _root.levelGrid.blockWidth) - 0.01);
if (ymom > ymomDeath) {
killLemming();
}
ymom = 0;
onGround = true;
} else {
onGround = false;
}
} else if (ymom < 0) {
var currentSquare = _root.levelGrid.gridValue(xgrid, ygrid);
var squareAbove = _root.levelGrid.gridValue(xgrid, ygrid - 1);
if (currentSquare == "x") {
_y = (((ygrid + 1) * _root.levelGrid.blockWidth) - blockCeiling);
ymom = gravity;
} else if ((squareAbove == "x") and (yrem <= 2)) {
_y = (_y + (-ymom));
ymom = gravity;
}
}
if (onGround) {
if (goingRight) {
xmom = walkSpeed;
} else {
xmom = -walkSpeed;
}
}
lastx = _x;
_x = (_x + xmom);
if (xmom and (xrem > (32 - (lemmingWidth / 2)))) {
var squareRight = _root.levelGrid.gridValue(xgrid + 1, ygrid);
if (yrem >= blockCeiling) {
squareRight = ".";
}
if (!onGround) {
var squareBelowRight = _root.levelGrid.gridValue(xgrid + 1, ygrid + 1);
} else {
squareBelowRight = null;
}
if (((((squareRight == "x") || (squareBelowRight == "x")) || (squareRight == "r")) || (squareBelowRight == "r")) || (xgrid == 14)) {
xmom = -Math.abs(xmom);
_x = (_x + (xmom * 2));
xmom = xmom / 2;
lg._xscale = -100;
goingRight = false;
}
} else if ((xmom < 0) and (xrem < (lemmingWidth / 2))) {
var squareLeft = _root.levelGrid.gridValue(xgrid - 1, ygrid);
if (yrem >= blockCeiling) {
squareLeft = ".";
}
if (!onGround) {
var squareBelowLeft = _root.levelGrid.gridValue(xgrid - 1, ygrid + 1);
} else {
squareBelowLeft = null;
}
if (((((squareLeft == "x") || (squareBelowLeft == "x")) || (squareLeft == "l")) || (squareBelowLeft == "l")) || (xgrid == 0)) {
xmom = Math.abs(xmom);
_x = (_x + (xmom * 2));
xmom = xmom / 2;
lg._xscale = 100;
goingRight = true;
}
}
}
}
lemmingWidth = 16;
lemmingHeight = 24;
gravity = 0.3;
friction = 0.99;
ymomDeath = 8;
goingRight = true;
walkSpeed = 2;
blockCeiling = _root.levelGrid.blockHeight - lemmingHeight;
this.onEnterFrame = collisionTest;
Symbol 16 MovieClip [levelExit] Frame 1
this.onEnterFrame = function () {
_alpha = (_alpha - 5);
if (_alpha < 10) {
_alpha = 100;
}
};
Symbol 23 Button
on (press) {
dragItem();
}
on (release, releaseOutside) {
dropItem();
}
Symbol 28 MovieClip Frame 1
function gridOk() {
xgrid = Math.floor(_parent._xmouse / 32);
ygrid = Math.floor(_parent._ymouse / 32);
_x = (xgrid * 32);
_y = (ygrid * 32);
currentGridValue = _root.levelGrid.gridValue(xgrid, ygrid);
belowGridValue = _root.levelGrid.gridValue(xgrid, ygrid + 1);
if ((currentGridValue == ".") and ((((belowGridValue == "x") || (belowGridValue == "d")) || (_root.levelEditor)) || (ygrid == 9))) {
return(true);
}
return(false);
}
function dragItem() {
if (objectsLeft) {
_alpha = 80;
this.onEnterFrame = function () {
if (gridOk()) {
invalidChoice._visible = false;
} else {
invalidChoice._visible = true;
}
};
}
}
function dropItem() {
if (objectsLeft || (_root.levelEditor)) {
if (gridOk()) {
_root.levelGrid.setGrid(xgrid, ygrid, objectType);
if (!_root.levelEditor) {
objectsLeft--;
}
}
_x = startX;
_y = startY;
if (objectsLeft) {
_alpha = 100;
}
invalidChoice._visible = false;
if (!_root.levelEditor) {
numberIndicator._visible = true;
}
objectBoxBackground._visible = true;
this.onEnterFrame = null;
dragObjectOutline._visible = true;
}
}
invalidChoice._visible = false;
objectsLeft = 0;
startX = _x;
startY = _y;
this.attachMovie(objectLink, "item", 1);
Instance of Symbol 28 MovieClip "o0" in Symbol 29 MovieClip Frame 1
//component parameters
onClipEvent (initialize) {
objectType = "t";
objectLink = "trampoline";
}
Instance of Symbol 28 MovieClip "o1" in Symbol 29 MovieClip Frame 1
//component parameters
onClipEvent (initialize) {
objectType = "s";
objectLink = "superTrampoline";
}
Instance of Symbol 28 MovieClip "o2" in Symbol 29 MovieClip Frame 1
//component parameters
onClipEvent (initialize) {
objectType = "x";
objectLink = "block1";
}
Instance of Symbol 28 MovieClip "o3" in Symbol 29 MovieClip Frame 1
//component parameters
onClipEvent (initialize) {
objectType = "l";
objectLink = "leftTrampoline";
}
Instance of Symbol 28 MovieClip "o4" in Symbol 29 MovieClip Frame 1
//component parameters
onClipEvent (initialize) {
objectType = "r";
objectLink = "rightTrampoline";
}
Symbol 30 MovieClip Frame 1
function endLevel() {
_root.lemmingLayer.removeLemmings();
if (_root.scoreBox.lemmingsRescued >= neededlemmings) {
nextLevel();
} else {
playLevel(currentLevel);
}
}
function nextLevel() {
currentLevel++;
if (currentLevel == 5) {
currentLevel = 1;
}
playLevel(currentLevel);
}
function playLevel(levelnum) {
currentLevel = levelnum;
loadLevel(levelnum);
}
function startGame() {
_parent.lemmingLayer.maxLemmings = startlemmings;
_parent.lemmingLayer.startLemmings();
i = 0;
while (i < 5) {
_root.objectPanel["o" add i].objectsLeft = o.substring(i, i + 1);
i++;
}
}
function resetGame() {
for (i in this) {
this[i].removeMovieClip();
}
line = new Array();
_root.scoreBox.lemmingsNeeded = neededlemmings;
for (x in originalLine) {
line[x] = originalLine[x];
}
setupGrid();
startGame();
}
function gridValue(x, y) {
return(line[y].substring(x, x + 1));
}
function setGrid(x, y, object) {
newStyle = 1;
line[y] = (line[y].substring(0, x) + object) + line[y].substring(x + 1, length(line[y]));
styleline[y] = (styleline[y].substring(0, x) + newStyle) + styleline[y].substring(x + 1, length(styleline[y]));
var newid = ((y * blockHeight) + x);
var newName = ((("block_" + y) + "_") + x);
this.attachMovie(blockId[object], newName, 1000 + newid);
blockPointer = this[newName];
blockPointer._x = x * blockWidth;
blockPointer._y = y * blockHeight;
}
function loadLevel(levelnum) {
originalLine = new Array();
line = new Array();
styleline = new Array();
if (levelnum == 1) {
levelData = "...............!.......e.......!r....xxxxx....l!....lx...xr....!r.............l!xx.xxxx.xxxx.xx!xx...........xx!...............!..o..xxxxx.....!dx...........xd";
o = "44344";
startlemmings = 10;
neededlemmings = 5;
} else if (levelnum == 2) {
levelData = "........x......!..v..vv.x....x.!xxxxxxxoxx...x.!......d.....xx.!......xxx..xxx.!r..x.ex..xx....!x...xx.........!...............!...............!......xddx....l";
o = "22222";
startlemmings = 13;
neededlemmings = 5;
} else if (levelnum == 3) {
levelData = "o..............!...............!xxxx..xx.......!...x..xxxxdddd.!...xxxx......x.!...exd.......x.!x...x...d....x.!x.......xr..xx.!xx......d......!xxxxxxxxxxxxxxx";
o = "41122";
startlemmings = 17;
neededlemmings = 10;
} else if (levelnum == 4) {
levelData = "...........xo..!...........xx.x!.xx..x....lx..x!..xddxr....x.xe!x..xxx....lx.x.!...d.xr.d....x.!.xxxxxxxxxxxxx.!...............!...............!x..dxd..xxxxxxx";
o = "42022";
startlemmings = 20;
neededlemmings = 20;
}
originalLine = levelData.split("!");
for (x in originalLine) {
line[x] = originalLine[x];
}
resetGame();
}
function setupGrid() {
blockHeight = 32;
blockWidth = 32;
blockId = new Array();
blockId.x = "block1";
blockId.o = "levelEntrance";
blockId.t = "trampoline";
blockId.s = "superTrampoline";
blockId.d = "deathSymbol";
blockId.e = "levelExit";
blockId.l = "leftTrampoline";
blockId.r = "rightTrampoline";
gridHeight = line.length;
gridWidth = length(line[0]);
var y = 0;
while (y < gridHeight) {
var x = 0;
while (x < length(line[0])) {
var newid = ((y * blockHeight) + x);
var newName = ((("block_" + y) + "_") + x);
var tempBlock = line[y].substring(x, x + 1);
var tempStyle = styleline[y].substring(x, x + 1);
if (tempBlock != ".") {
this.attachMovie(blockId[tempBlock], newName, 1000 + newid);
blockPointer = this[newName];
blockPointer._x = x * blockWidth;
blockPointer._y = y * blockHeight;
}
x++;
}
y++;
}
}
Symbol 37 Button
on (press) {
_root.levelGrid.endLevel();
}
Symbol 40 MovieClip Frame 1
function startLemmings() {
for (i in this) {
this[i].removeMovieClip();
}
totalLemmings = 0;
maxLemmings = 20;
lemmingDelay = 20;
creationWait = lemmingDelay;
_parent.scoreBox.lemmingsOut = 0;
_parent.scoreBox.lemmingsRescued = 0;
play();
}
function creationLoop() {
creationWait--;
if ((creationWait == 0) and (totalLemmings < maxLemmings)) {
totalLemmings++;
_parent.scoreBox.lemmingsOut++;
creationWait = lemmingDelay;
this.attachMovie("lemming", "lemming" + totalLemmings, totalLemmings);
lemmingPointer = this["lemming" + totalLemmings];
lemmingPointer._x = lemmingEntranceX;
lemmingPointer._y = lemmingEntranceY;
}
}
this.onEnterFrame = creationLoop;