Frame 1
var domain = "http://www.novelgames.com";
var siteID;
var gameID = 38;
var highscoresColour = 153;
if (!siteid) {
siteID = 1;
}
if (!highscores.siteID) {
highscores.loadMovie(domain + "/freeflashgames/highscores/highscores.swf");
}
if (!sendFriend.exists) {
sendFriend.loadMovie(domain + "/freeflashgames/send/send.swf");
}
stop();
_focusrect = false;
Frame 2
stop();
Frame 3
stop();
Frame 4
function initialize() {
var i;
var j;
i = 0;
while (i < dimensionX) {
occupiers[i] = new Array(dimensionY);
j = 0;
while (j < dimensionY) {
occupiers[i][j] = null;
j++;
}
i++;
}
i = 0;
while (i < dimensionY) {
j = 0;
while (j < dimensionX) {
eggsHolder.attachMovie("egg", "egg" + depth, depth);
eggs[depth] = eval ("eggsHolder.egg" + depth);
eggs[depth]._x = getRealX(j, i);
eggs[depth]._y = getRealY(j, i);
eggs[depth].type = Math.floor(Math.random() * eggTypes);
eggs[depth].picture.gotoAndStop(eggs[depth].type + 1);
setEggXY(eggs[depth], j, i);
depth++;
j++;
}
i++;
}
lifePie.gotoAndStop((lifeFull + 1) - life);
}
function setEggXY(egg, x, y) {
egg.x = x;
egg.y = y;
occupiers[x][y] = egg;
}
function getRealX(x, y) {
return(x * eggWidth);
}
function getRealY(x, y) {
if ((x % 2) == 0) {
return(y * eggHeight);
}
return((y * eggHeight) + (eggHeight / 2));
}
function chooseEgg(egg) {
if (!gameStarted) {
return(undefined);
}
if (((isSwapping || (isUnswapping)) || (isDestroying)) || (isDropping)) {
return(undefined);
}
if (!chosenEgg) {
chosenEgg = egg;
egg.gotoAndStop("chosen");
soundChoose.start();
} else if (eggsAreAdjacent(egg, chosenEgg)) {
swapEggs(egg, chosenEgg);
chosenEgg.gotoAndStop("normal");
chosenEgg = null;
soundSwap.start();
} else {
chosenEgg.gotoAndStop("normal");
chosenEgg = null;
soundChoose.start();
}
}
function eggsAreAdjacent(egg1, egg2) {
if (egg1.x == egg2.x) {
return((egg1.y == (egg2.y + 1)) || (egg1.y == (egg2.y - 1)));
}
if (egg1.x == (egg2.x - 1)) {
if ((egg1.x % 2) == 0) {
return((egg1.y == egg2.y) || (egg1.y == (egg2.y + 1)));
}
return((egg1.y == egg2.y) || (egg1.y == (egg2.y - 1)));
}
if (egg1.x == (egg2.x + 1)) {
if ((egg2.x % 2) == 0) {
return((egg1.y == egg2.y) || (egg1.y == (egg2.y - 1)));
}
return((egg1.y == egg2.y) || (egg1.y == (egg2.y + 1)));
}
return(false);
}
function swapEggs(egg1, egg2) {
isSwapping = true;
swappingEgg1 = egg1;
swappingEgg2 = egg2;
egg1.swapTo(egg2.x, egg2.y);
egg2.swapTo(egg1.x, egg1.y);
}
function unswapEggs(egg1, egg2) {
isUnswapping = true;
unswappingEgg1 = egg1;
unswappingEgg2 = egg2;
egg1.unswapTo(egg2.x, egg2.y);
egg2.unswapTo(egg1.x, egg1.y);
}
function finishSwapping() {
var groups;
if (swappingEgg1.isSwapping || (swappingEgg2.isSwapping)) {
return(undefined);
}
isSwapping = false;
setEggXY(swappingEgg1, swappingEgg1.targetX, swappingEgg1.targetY);
setEggXY(swappingEgg2, swappingEgg2.targetX, swappingEgg2.targetY);
groups = getGroups();
if (groups.length == 0) {
combo = 0;
unswapEggs(swappingEgg1, swappingEgg2);
soundSwap.start();
} else {
combo++;
addScore(getScore(groups));
addLife(groups.length);
destroyEggs(groups);
soundGroup.start();
}
}
function finishUnswapping() {
if (unswappingEgg1.isUnswapping || (unswappingEgg2.isUnswapping)) {
return(undefined);
}
isUnswapping = false;
setEggXY(unswappingEgg1, unswappingEgg1.targetX, unswappingEgg1.targetY);
setEggXY(unswappingEgg2, unswappingEgg2.targetX, unswappingEgg2.targetY);
}
function destroyEggs(groups) {
var i;
var j;
isDestroying = true;
destroyingEggs = new Array();
i = 0;
while (i < groups.length) {
j = 0;
while (j < groups[i].length) {
destroyingEggs.push(groups[i][j]);
groups[i][j].destroy();
j++;
}
i++;
}
}
function finishDestroying() {
var i;
i = 0;
while (i < destroyingEggs.length) {
if (destroyingEggs[i]._visible) {
return(undefined);
}
i++;
}
i = 0;
while (i < destroyingEggs.length) {
destroyEgg(destroyingEggs[i]);
i++;
}
isDestroying = false;
dropEggs();
}
function destroyEgg(egg) {
occupiers[egg.x][egg.y] = null;
egg.removeMovieClip();
}
function dropEggs() {
var i;
var j;
var noOfSpaces;
var theEgg;
isDropping = true;
droppingEggs = new Array();
i = 0;
while (i < dimensionX) {
noOfSpaces = 0;
j = dimensionY - 1;
while (j >= 0) {
theEgg = occupiers[i][j];
if (!theEgg) {
noOfSpaces++;
} else if (0 < noOfSpaces) {
theEgg.drop(theEgg.y + noOfSpaces);
droppingEggs.push(theEgg);
}
j--;
}
j = 0;
while (j < noOfSpaces) {
eggsHolder.attachMovie("egg", "egg" + depth, depth);
eggs[depth] = eval ("eggsHolder.egg" + depth);
eggs[depth].x = i;
eggs[depth].y = (-j) - 1;
eggs[depth]._x = getRealX(i, (-j) - 1);
eggs[depth]._y = getRealY(i, (-j) - 1);
eggs[depth].type = Math.floor(Math.random() * eggTypes);
eggs[depth].picture.gotoAndStop(eggs[depth].type + 1);
eggs[depth].isDropping = true;
eggs[depth].targetX = i;
eggs[depth].targetY = (noOfSpaces - 1) - j;
eggs[depth].targetRealX = getRealX(i, (noOfSpaces - 1) - j);
eggs[depth].targetRealY = getRealY(i, (noOfSpaces - 1) - j);
eggs[depth].speedX = 0;
eggs[depth].speedY = dropSpeed;
droppingEggs.push(eggs[depth]);
depth++;
j++;
}
i++;
}
}
function finishDropping() {
var i;
var groups;
i = 0;
while (i < droppingEggs.length) {
if (droppingEggs[i].isDropping) {
return(undefined);
}
i++;
}
i = 0;
while (i < droppingEggs.length) {
setEggXY(droppingEggs[i], droppingEggs[i].targetX, droppingEggs[i].targetY);
i++;
}
isDropping = false;
groups = getGroups();
if (groups.length == 0) {
combo = 0;
} else {
combo++;
addScore(getScore(groups));
addLife(groups.length);
destroyEggs(groups);
soundGroup.start();
}
}
function getGroups() {
var groups = new Array();
var rootEgg;
var theEgg;
var group;
var i;
i = 0;
while (i < dimensionX) {
rootEgg = occupiers[i][0];
theEgg = rootEgg;
group = new Array();
group.push(theEgg);
while ((theEgg = getNextEgg(theEgg, DOWN))) {
if (theEgg.type == rootEgg.type) {
group.push(theEgg);
} else {
if (group.length >= groupSize) {
groups.push(group);
}
rootEgg = theEgg;
group = new Array();
group.push(rootEgg);
}
}
if (group.length >= groupSize) {
groups.push(group);
}
i++;
}
i = 0;
while (i < dimensionX) {
rootEgg = occupiers[i][0];
theEgg = rootEgg;
group = new Array();
group.push(theEgg);
while ((theEgg = getNextEgg(theEgg, RIGHTDOWN))) {
if (theEgg.type == rootEgg.type) {
group.push(theEgg);
} else {
if (group.length >= groupSize) {
groups.push(group);
}
rootEgg = theEgg;
group = new Array();
group.push(rootEgg);
}
}
if (group.length >= groupSize) {
groups.push(group);
}
i = i + 2;
}
i = 0;
while (i < dimensionY) {
rootEgg = occupiers[0][i];
theEgg = rootEgg;
group = new Array();
group.push(theEgg);
while ((theEgg = getNextEgg(theEgg, RIGHTDOWN))) {
if (theEgg.type == rootEgg.type) {
group.push(theEgg);
} else {
if (group.length >= groupSize) {
groups.push(group);
}
rootEgg = theEgg;
group = new Array();
group.push(rootEgg);
}
}
if (group.length >= groupSize) {
groups.push(group);
}
i++;
}
i = 0;
while (i < dimensionX) {
rootEgg = occupiers[i][0];
theEgg = rootEgg;
group = new Array();
group.push(theEgg);
while ((theEgg = getNextEgg(theEgg, LEFTDOWN))) {
if (theEgg.type == rootEgg.type) {
group.push(theEgg);
} else {
if (group.length >= groupSize) {
groups.push(group);
}
rootEgg = theEgg;
group = new Array();
group.push(rootEgg);
}
}
if (group.length >= groupSize) {
groups.push(group);
}
i = i + 2;
}
i = 0;
while (i < dimensionY) {
rootEgg = occupiers[dimensionX - 1][i];
theEgg = rootEgg;
group = new Array();
group.push(theEgg);
while ((theEgg = getNextEgg(theEgg, LEFTDOWN))) {
if (theEgg.type == rootEgg.type) {
group.push(theEgg);
} else {
if (group.length >= groupSize) {
groups.push(group);
}
rootEgg = theEgg;
group = new Array();
group.push(rootEgg);
}
}
if (group.length >= groupSize) {
groups.push(group);
}
i++;
}
return(groups);
}
function getNextEgg(egg, direction) {
if (direction == DOWN) {
if (egg.y == (dimensionY - 1)) {
return(null);
}
return(occupiers[egg.x][egg.y + 1]);
}
if (direction == LEFTDOWN) {
if (egg.x == 0) {
return(null);
}
if ((egg.x % 2) == 0) {
return(occupiers[egg.x - 1][egg.y]);
}
if (egg.y == (dimensionY - 1)) {
return(null);
}
return(occupiers[egg.x - 1][egg.y + 1]);
}
if (egg.x == (dimensionX - 1)) {
return(undefined);
}
if ((egg.x % 2) == 0) {
return(occupiers[egg.x + 1][egg.y]);
}
if (egg.y == (dimensionY - 1)) {
return(null);
}
return(occupiers[egg.x + 1][egg.y + 1]);
}
function getScore(groups) {
var i;
var theScore = 0;
i = 0;
while (i < groups.length) {
theScore = theScore + (combo * (((groups[i].length - groupSize) * extraEggScore) + groupScore));
i++;
}
return(theScore);
}
function addScore(amount) {
score = score + amount;
updateLevel();
}
function updateLevel() {
var i;
i = level - 1;
while (i < levelScores.length) {
if (score < levelScores[i]) {
break;
}
i++;
}
if (level != (i + 1)) {
level = i + 1;
decreaseRate = levelDecreaseRates[i];
}
}
function updateLife() {
if (!gameStarted) {
return(undefined);
}
decreaseCount++;
if (decreaseCount >= decreaseRate) {
decreaseCount = 0;
addLife(-1);
}
}
function addLife(amount) {
life = life + amount;
if (life < 0) {
life = 0;
} else if (lifeFull < life) {
life = lifeFull;
}
lifePie.setLife(life);
if (0 >= life) {
gameOver();
soundGameOver.start();
}
}
function gameOver() {
gameStarted = false;
gameOverDialog.gotoAndPlay(2);
}
var DOWN = 1;
var LEFTDOWN = 2;
var RIGHTDOWN = 3;
var dimensionX = 11;
var dimensionY = 7;
var eggWidth = 40;
var eggHeight = 50;
var eggTypes = 4;
var groupSize = 4;
var swapSteps = 5;
var destroySpeed = 20;
var dropSpeed = 25;
var lifeFull = 32;
var initialLife = 16;
var groupScore = 100;
var extraEggScore = 50;
var levelDecreaseRates = [60, 50, 40, 35, 30, 26, 23, 20, 18, 16, 14, 12, 10];
var levelScores = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000];
var eggs = new Array();
var depth = 0;
var occupiers = new Array();
var chosenEgg = null;
var isSwapping = false;
var swappingEgg1 = null;
var swpaaingEgg2 = null;
var isUnswapping = false;
var unswappingEgg1 = null;
var unswappingEgg2 = null;
var isDestroying = false;
var destroyingEggs = new Array();
var isDropping = false;
var droppingEggs = new Array();
var level = 1;
var life = initialLife;
var score = 0;
var combo = 0;
var decreaseRate = levelDecreaseRates[0];
var decreaseCount = 0;
var gameStarted = true;
var soundChoose = new Sound(this);
var soundSwap = new Sound(this);
var soundGroup = new Sound(this);
var soundGameOver = new Sound(this);
soundChoose.attachSound("soundChoose");
soundSwap.attachSound("soundSwap");
soundGroup.attachSound("soundGroup");
soundGameOver.attachSound("soundGameOver");
initialize();
Instance of Symbol 14 MovieClip in Frame 4
onClipEvent (enterFrame) {
_root.updateLife();
}
Symbol 13 Button
on (release) {
_root.chooseEgg(this);
}
Symbol 26 MovieClip [egg] Frame 1
function swapTo(x, y) {
targetX = x;
targetY = y;
targetRealX = _root.getRealX(x, y);
targetRealY = _root.getRealY(x, y);
speedX = (targetRealX - _x) / _root.swapSteps;
speedY = (targetRealY - _y) / _root.swapSteps;
isSwapping = true;
}
function unswapTo(x, y) {
targetX = x;
targetY = y;
targetRealX = _root.getRealX(x, y);
targetRealY = _root.getRealY(x, y);
speedX = (targetRealX - _x) / _root.swapSteps;
speedY = (targetRealY - _y) / _root.swapSteps;
isUnswapping = true;
}
function destroy() {
isDestroying = true;
}
function drop(y) {
targetX = x;
targetY = y;
targetRealX = _x;
targetRealY = _root.getRealY(x, y);
speedX = 0;
speedY = _root.dropSpeed;
isDropping = true;
}
function move() {
if (!_root.gameStarted) {
return(undefined);
}
if ((isSwapping || (isUnswapping)) || (isDropping)) {
_x = (_x + speedX);
_y = (_y + speedY);
if ((_x == targetRealX) && (_y == targetRealY)) {
if (isSwapping) {
isSwapping = false;
_root.finishSwapping();
} else if (isUnswapping) {
isUnswapping = false;
_root.finishUnswapping();
} else if (isDropping) {
isDropping = false;
_root.finishDropping();
}
}
} else if (isDestroying) {
_xscale = (_xscale - _root.destroySpeed);
_yscale = (_yscale - _root.destroySpeed);
if ((0 >= _xscale) || (0 >= _yscale)) {
_visible = false;
isDestroying = false;
_root.finishDestroying();
}
}
}
function setXY(x, y) {
this.x = x;
this.y = y;
}
var x;
var y;
var type;
var isSwapping;
var isUnswapping;
var targetX;
var targetY;
var targetRealX;
var targetRealY;
var speedX;
var speedY;
var isDestroying;
var isDropping;
Instance of Symbol 14 MovieClip in Symbol 26 MovieClip [egg] Frame 1
onClipEvent (enterFrame) {
_parent.move();
}
Symbol 26 MovieClip [egg] Frame 2
stop();
Symbol 26 MovieClip [egg] Frame 9
stop();
Symbol 33 MovieClip Frame 1
var percent = 0;
stop();
Instance of Symbol 14 MovieClip in Symbol 33 MovieClip Frame 1
onClipEvent (enterFrame) {
if (_parent.percent < 100) {
_parent.percent = Math.floor((_root._framesloaded / _root._totalframes) * 100);
if (_parent.percent < 100) {
_parent.gotoAndStop(_parent.percent + 1);
} else {
_parent.gotoAndPlay(101);
}
}
}
onClipEvent (mouseDown) {
if (_parent.percent >= 100) {
_root.play();
}
}
Symbol 33 MovieClip Frame 101
stop();
_root.play();
Symbol 42 Button
on (release) {
nextFrame();
}
Symbol 46 Button
on (release) {
highscores.showHighscores();
}
Symbol 52 Button
on (release) {
sendFriend.show();
}
Symbol 100 MovieClip Frame 1
function setLife(life) {
if (life < 0) {
life = 0;
} else if (_root.lifeFull < life) {
life = lifeFull;
}
gotoAndStop((_root.lifeFull + 1) - life);
}
Symbol 111 Button
on (release) {
_root.gotoAndStop(1);
}
Symbol 112 MovieClip Frame 1
stop();
Symbol 112 MovieClip Frame 15
_root.highscores.showEnter(_root.score);
stop();