Frame 1
function Sprites() {
createEmptyMovieClip("sprite_root", 0);
var zRange = 500;
var zArray = new Array(zRange);
var _local2 = 0;
while (_local2 < zRange) {
zArray[_local2] = zRange - _local2;
_local2++;
}
var groupList = new Object();
this.getNumFree = function () {
return(zArray.length);
};
this.create = function (props) {
var _local4 = zArray.pop() + zRange;
var _local5 = "sprite" + _local4;
var _local3;
if ((typeof(props.group) == "string") && (groupList[props.group])) {
groupList[props.group].createEmptyMovieClip(_local5, _local4);
_local3 = groupList[props.group][_local5];
} else {
sprite_root.createEmptyMovieClip(_local5, _local4);
_local3 = sprite_root[_local5];
}
if (typeof(props.member) == "string") {
_local3.attachMovie(props.member, "member_mc", _local4);
}
_local3._x = ((typeof(props.x) == "number") ? (props.x) : (Stage.width / 2));
_local3._y = ((typeof(props.y) == "number") ? (props.y) : (Stage.height / 2));
if (typeof(props.width) == "number") {
_local3._width = props.width;
}
if (typeof(props.height) == "number") {
_local3._height = props.height;
}
if (typeof(props.xscale) == "number") {
_local3._xscale = props.xscale;
}
if (typeof(props.yscale) == "number") {
_local3._yscale = props.yscale;
}
_local3._visible = ((typeof(props.visible) == "boolean") ? (props.visible) : true);
_local3._alpha = ((typeof(props.alpha) == "number") ? (props.alpha) : 100);
_local3.zIndex = _local4;
_local3.toBack = function () {
var _local3 = this.zIndex;
var _local2 = this.zIndex % zRange;
this.swapDepths(_local2);
this.member_mc.swapDepths(_local2);
this.zIndex = _local2;
};
_local3.toFront = function () {
var _local2 = (this.zIndex % zRange) + (zRange * 2);
this.swapDepths(_local2);
this.member_mc.swapDepths(_local2);
this.zIndex = _local2;
};
return(_local3);
};
this.createGroup = function (props) {
if (typeof(props.group) == "string") {
var _local2 = props.group;
props.group = null;
if (groupList[_local2]) {
wr("Alert! generating an already existing group: ", _local2);
} else {
groupList[_local2] = this.create(props);
groupList[_local2].groupName = _local2;
}
}
return(groupList[_local2]);
};
this.removeGroup = function (nameOrSprite) {
if (typeof(nameOrSprite) == "string") {
gName = nameOrSprite;
} else {
gName = nameOrSprite.groupName;
}
if (groupList[gName]) {
sprites.remove(groupList[gName]);
groupList[gName] = null;
}
};
this.setMember = function (sprite, member) {
sprite.attachMovie(member, "member_mc", sprite.getDepth());
};
this.createText = function (props) {
var _local5 = this.create({x:props.x, y:props.y});
_local5.createTextField("member_mc", _local5.zIndex, 0, 0, 1, 1);
var _local3 = _local5.member_mc;
_local3.autosize = ((typeof(props.align) == "string") ? (props.align) : "left");
_local3.multiline = false;
_local3.wordWrap = false;
_local3.border = false;
_local3.selectable = false;
_local3.type = "dynamic";
_local3.embedFonts = true;
var _local4 = new TextFormat();
_local4.color = ((typeof(props.color) == "string") ? (props.color) : "0xffffff");
_local4.size = props.size || 9;
_local4.font = ((typeof(props.font) == "string") ? (props.font) : "Arial");
_local4.align = ((typeof(props.align) == "string") ? (props.align) : "left");
_local4.bold = ((typeof(props.bold) == "boolean") ? (props.bold) : false);
_local3.setNewTextFormat(_local4);
_local3.text = ((typeof(props.text) == "string") ? (props.text) : "");
return(_local5);
};
this.remove = function (sprite) {
if (!sprite.zIndex) {
return(undefined);
}
var _local1 = sprite.zIndex % zRange;
sprite.removeMovieClip();
zArray.push(_local1);
return(_local1);
};
}
function Events() {
var listeners = new Array();
var stopCount = 0;
this.runIt = function (object) {
if (typeof(object.run) == "function") {
var _local1 = 0;
while (_local1 < listeners.length) {
if (listeners[_local1] == object) {
return(undefined);
}
_local1++;
}
listeners.push(object);
} else {
wr("tried to run bad object!");
wrObj(object);
}
};
this.stopIt = function (object) {
var _local1 = 0;
while (_local1 < listeners.length) {
if (listeners[_local1] == object) {
stopCount++;
listeners[_local1].eventOrphan = true;
return(undefined);
}
_local1++;
}
};
onEnterFrame = function () {
var _local2 = listeners;
var _local1 = 0;
while (_local1 < _local2.length) {
if (!_local2[_local1].eventOrphan) {
_local2[_local1].run();
}
_local1++;
}
if (stopCount > 0) {
_local1 = 0;
while (_local1 < listeners.length) {
if (listeners[_local1].eventOrphan) {
listeners[_local1].eventOrphan = false;
listeners.splice(_local1, 1);
_local1--;
stopCount--;
}
_local1++;
}
}
};
this.putEventList = function () {
wr("Running Object list:");
var _local1 = 0;
while (_local1 < listeners.length) {
wr(listeners[_local1]);
_local1++;
}
};
this.checkEventList = function () {
var _local2 = listeners;
var _local1 = 0;
while (_local1 < _local2.length) {
if (typeof(_local2[_local1]) != "object") {
wr("invalid object in event: ", _local1);
}
_local1++;
}
};
}
function SoundFx() {
var _local4 = ["errorclick.aif", "ping1.wav", "ping2.wav", "ping3.wav", "ping4.wav", "ping5.wav", "gameover.aif", "levelup.aif", "swapsound.wav", "blockdrop.aif"];
createEmptyMovieClip("sound_fx", -1);
var _local5 = 0;
var sounds = new Object();
var _local2 = 0;
while (_local2 < _local4.length) {
var _local3 = new Sound(sound_fx.createEmptyMovieClip("sound_" + (_local2 + 1), (-_local2) - 2));
_local3.attachSound(_local4[_local2]);
_local3.onSoundComplete = function () {
this.playing = false;
};
sounds[_local4[_local2]] = _local3;
sounds[_local4[_local2]].playing = false;
_local2++;
}
this.play = function (sound, nostop) {
if (sounds[sound].playing) {
if (nostop) {
return(undefined);
}
this.stop(sound);
}
sounds[sound].playing = true;
sounds[sound].start();
};
this.stop = function (sound) {
sounds[sound].stop();
sounds[sound].playing = false;
};
}
function wr() {
var _local3 = "> ";
var _local2 = 0;
while (_local2 < arguments.length) {
_local3 = _local3 + arguments[_local2];
_local2++;
if (arguments.length != _local2) {
_local3 = _local3 + " ";
}
}
}
function wrObj(obj, rec) {
function wrObjDump(obj, rec, currprop) {
currprop = ((typeof(currprop) == "string") ? (currprop + ".") : "");
for (prop in obj) {
if (rec) {
if (typeof(obj[prop]) == "object") {
wrObjDump(obj[prop], rec, currprop + prop);
}
}
}
}
wrObjDump(obj, rec);
}
function fill(width, p) {
var _local2 = "";
var _local3 = ((typeof(p) != "string") ? " " : (p));
var _local1 = 0;
while (_local1 < width) {
_local2 = _local2 + _local3;
_local1++;
}
return(_local2);
}
function Random() {
var seed = 0;
var seed2 = 0;
this.range = function (start, stop) {
var _local2 = stop - start;
var _local1 = Math.random() * (_local2 + 1);
_local1 = Math.floor(start + _local1);
return(Math.min(_local1, stop));
};
this.setSeed = function (s) {
wr("setSeed:", s);
seed = s & 65535;
seed2 = seed;
};
this.rangeFromSeed = function (start, stop) {
var _local3 = stop - start;
var _local2 = this.floatFromSeed() * (_local3 + 1);
_local2 = Math.floor(start + _local2);
return(Math.min(_local2, stop));
};
this.rangeFromSeed2 = function (start, stop) {
var _local3 = stop - start;
var _local2 = this.floatFromSeed2() * (_local3 + 1);
_local2 = Math.floor(start + _local2);
return(Math.min(_local2, stop));
};
this.floatFromSeed = function () {
seed = ((seed * 732573) + 3545443) & 65535;
temp = seed / 65536;
return(temp);
};
this.floatFromSeed2 = function () {
seed2 = ((seed2 * 732573) + 3545443) & 65535;
temp = seed2 / 65536;
return(temp);
};
}
function Slide(props) {
this.mysprite = props.sprite;
this.orig_x = this.mysprite._x;
this.orig_y = this.mysprite._y;
this.curr_x = this.orig_x;
this.curr_y = this.orig_y;
this.target_x = ((typeof(props.x) == "number") ? (props.x) : (this.orig_x));
this.target_y = ((typeof(props.y) == "number") ? (props.y) : (this.orig_y));
this.move_x = this.orig_x != this.target_x;
this.move_y = this.orig_y != this.target_y;
this.callback = props.callback;
this.delay = props.delay || 0;
this.v = 0;
this.nFrames = props.nFrames || 10;
this.run = function () {
if (this.delay > 0) {
this.delay--;
return(undefined);
}
this.v = Math.min(this.v + (Math.Pi / (this.nFrames * 2)), (Math.PI/2));
if (this.move_x) {
this.curr_x = this.orig_x + ((Math.sin(this.v + 4.71238898038469) + 1) * (this.target_x - this.orig_x));
this.mysprite._x = this.curr_x;
}
if (this.move_y) {
this.curr_y = this.orig_y + ((Math.sin(this.v + 4.71238898038469) + 1) * (this.target_y - this.orig_y));
this.mysprite._y = this.curr_y;
}
if (this.v >= (Math.PI/2)) {
events.stopIt(this);
if (this.callback) {
this.callback();
}
}
};
events.runIt(this);
}
function Fade(props) {
this.mysprite = props.sprite;
this.mode = ((typeof(props.mode) == "string") ? (props.mode) : "in");
this.nFrames = props.frames || 10;
this.counter = this.nFrames;
this.alphastep = 100 / this.nFrames;
if (this.mode == "in") {
this.alphastep = -this.alphastep;
this.curralpha = 0;
} else {
this.curralpha = 100;
}
this.callback = props.callback;
this.run = function () {
this.counter--;
this.curralpha = this.curralpha - this.alphastep;
this.mysprite._alpha = this.curralpha;
if (this.counter == 0) {
if (this.mode == "pulse") {
this.counter = this.nFrames;
this.alphastep = -this.alphastep;
} else {
events.stopIt(this);
if (this.callback) {
this.callback();
}
}
}
};
events.runIt(this);
}
function Animate(props) {
this.mysprite = props.sprite;
this.callback = props.callback;
this.delay = props.delay || 0;
this.animation = props.animation;
this.animpos = 0;
this.loop = ((typeof(props.loop) == "boolean") ? (props.loop) : false);
this.run = function () {
if (this.delay > 0) {
this.delay--;
return(undefined);
}
if (this.animpos > this.animation.length) {
if (this.loop) {
this.animpos = 0;
} else {
events.stopIt(this);
if (this.callback) {
this.callback();
}
return(undefined);
}
}
sprites.setMember(this.mysprite, this.animation[this.animpos]);
this.animpos++;
};
this.kill = function () {
events.stopIt(this);
};
events.runIt(this);
}
function Delay(what, frames) {
this.what = what;
this.counter = 0;
this.nFrames = frames;
this.run = function () {
this.counter++;
if (this.counter > this.nFrames) {
events.stopIt(this);
this.what();
}
};
events.runIt(this);
}
function Gui() {
function isString(str) {
return(typeof(str) == "string");
}
var T_time_left = time_text;
var _local8 = points_text;
var TH_time_left = time_tag_text;
var TH_points = points_tag_text;
var TH_end_button = end_game_text;
var T_info_text = info_text;
var T_info_text_drop = info_text_drop;
this.alertActive = false;
var gameAreaCenterX = 431;
var p_automat = new scoreAutomat(_local8);
events.runIt(p_automat);
this.setTime = function (time) {
T_time_left.text = time;
};
this.addPoints = function (points) {
p_automat.addScore(points);
};
this.setInfo = function (info) {
T_info_text.text = info;
T_info_text_drop.text = info;
};
this.alert = function (_header, _body) {
if (this.alertActive) {
return(undefined);
}
this.alertActive = true;
var _local6 = {member:"popupbox", x:gameAreaCenterX, y:200};
var _local2 = sprites.create(_local6);
var _local4 = _local2.member_mc.body_txt._height;
_local2.member_mc.body_txt.autosize = "center";
_local2.member_mc.header_txt.text = _header;
_local2.member_mc.body_txt.text = _body;
var _local3 = _local2.member_mc.body_txt._height;
var _local5 = (_local3 - _local4) / 2;
_local2.member_mc.body_txt._y = _local2.member_mc.body_txt._y - Math.min(40, _local5);
_local2.member_mc.body_txt.autosize = false;
if (_local3 > 116) {
_local2.member_mc.body_txt._height = 116;
}
if (_local2.member_mc.body_txt._width > 214) {
_local2.member_mc.body_txt._width = 214;
}
_local2.swapDepths(3333);
};
this.setupHeaders = function (props) {
TH_time_left.text = (isString(props.time) ? (props.time) : "00:00");
TH_points.text = (isString(props.points) ? (props.points) : "0");
TH_end_button.text = (isString(props.end) ? (props.end) : "END GAME");
var _local3 = (isString(props.instruction) ? (props.instruction) : "");
this.setInfo(_local3);
end_game_button._visible = true;
};
var _local7 = sprites.create({member:"main_top", x:90, y:10});
_local7.toFront();
end_game_button._visible = false;
end_game_button.useHandCursor = false;
end_game_button.onRelease = function () {
fscommand ("playData", "7718=0");
game.setGameOver();
};
this.gameIsOver = function () {
end_game_button._visible = false;
};
}
function scoreAutomat(txt_field) {
function updateScore() {
var _local1 = dest_p - curr_p;
var _local2 = _local1 * speed;
if (Math.abs(_local1) <= 2) {
curr_p = dest_p;
} else {
curr_p = curr_p + _local2;
}
txt_field.text = Math.round(curr_p);
if (dest_p == curr_p) {
calcReady();
}
}
function calcReady() {
running = false;
}
var running = false;
var speed = 0.2;
var curr_p = 0;
var dest_p = 0;
var txt_field = txt_field;
this.addScore = function (howMuch) {
running = true;
if ((dest_p + howMuch) < 0) {
dest_p = 0;
} else {
dest_p = dest_p + howMuch;
}
};
this.run = function () {
if (running) {
updateScore();
}
};
}
function blockDropper() {
var dropList = new Array();
var speedList = [2, 7, 10, 18, 18, 19];
var min_y = 10;
this.start = function () {
events.runIt(this);
};
this.dropBlock = function (props) {
var _local1 = new Object();
_local1.sprite = props.sprite;
_local1.orig_y = _local1.sprite._y;
_local1.curr_y = _local1.orig_y;
_local1.sprite.droptarget_y = ((typeof(props.y) == "number") ? (props.y) : (_local1.orig_y));
_local1.move_y = _local1.orig_y != _local1.sprite.droptarget_y;
_local1.callback = props.callback;
_local1.speedListPos = 0;
_local1.speed = 0;
_local1.sprite._y = Math.max(_local1.orig_y, min_y);
_local1.sprite._visible = true;
dropList.push(_local1);
};
this.run = function () {
var _local2;
var _local3;
var _local4 = false;
var _local1 = 0;
while (_local1 < dropList.length) {
_local2 = dropList[_local1].sprite;
_local3 = typeof(_local2.gridX) != "number";
if ((dropList[_local1].curr_y == _local2.droptarget_y) || (_local3)) {
_local4 = true;
if (!_local3) {
_local2.busy = false;
}
if (dropList[_local1].callback) {
dropList[_local1].callback();
}
dropList.splice(_local1, 1);
_local1--;
} else {
dropList[_local1].speed = speedList[dropList[_local1].speedListPos];
dropList[_local1].curr_y = Math.min(dropList[_local1].curr_y + dropList[_local1].speed, _local2.droptarget_y);
_local2._y = Math.max(min_y, dropList[_local1].curr_y);
dropList[_local1].speedListPos++;
if (dropList[_local1].speedListPos == speedList.length) {
dropList[_local1].speedListPos = speedList.length - 2;
}
}
_local1++;
}
if (_local4) {
soundFx.play("blockdrop.aif", true);
}
};
this.clear = function () {
};
}
function Score() {
var currentLevel = 1;
var midasCounter = 0;
var midasScore = 0;
var gemScores = [0, 0, 50, 100, 150, 250, 500];
var comboScores = [0, 50, 100, 150, 250, 350, 500, 750, 1000];
var comboIndex = 0;
var doClearanceBonusEvent = false;
var currentScore = 0;
var gemCounter = 0;
this.getLevel = function () {
return(currentLevel);
};
this.getScore = function () {
return(currentScore);
};
var eventCodes = {};
eventCodes["clear gems"] = 1295;
eventCodes["clear gems combo"] = 9911;
eventCodes["reset multiplier"] = 9841;
eventCodes.midas = 8982;
eventCodes["level up"] = 1441;
eventCodes["error click"] = 9031;
eventCodes.inactive = 6955;
eventCodes["no more moves"] = 8391;
eventCodes["clearance bonus"] = 6761;
this.evaluateEvent = function (event) {
var _local5 = 0.8 + (0.2 * currentLevel);
var _local3 = 0;
event.code = -1;
if ((event.action == "clear gems") || (event.action == "clear gems combo")) {
_local3 = gemScores[event.value - 1];
_local3 = _local3 + comboScores[comboIndex];
gemCounter = gemCounter + event.value;
wr(gemCounter);
if (Math.floor(gemCounter / 100) != Math.floor((gemCounter - event.value) / 100)) {
doClearanceBonusEvent = true;
}
midasScore = midasScore + _local3;
if ((comboindex > 0) && (event.action == "clear gems")) {
event.action = event.action + " combo";
}
comboIndex++;
comboIndex = Math.min(comboIndex, comboScores.length - 1);
if (!game.gameOver) {
soundFx.play(("ping" + Math.min(comboIndex + 1, 5)) + ".wav");
}
} else if (event.action == "clearance bonus") {
_local3 = 250 + (Math.floor(gemCounter / 100) * 250);
midasScore = midasScore + _local3;
} else if (event.action == "reset multiplier") {
comboIndex = 0;
} else if (event.action == "error click") {
_local3 = -10;
} else if (event.action == "no more moves") {
_local3 = -250;
} else if (event.action == "inactive") {
_local3 = -10;
}
var _local4 = currentScore;
currentScore = currentScore + _local3;
currentScore = Math.max(0, currentScore);
if (!game.gameOver) {
game.gui.addPoints(_local3);
}
event.code = eventCodes[event.action] || 0;
if (_local4 != currentScore) {
event.score = currentScore - _local4;
this.sendEvent(event);
}
if (doClearanceBonusEvent) {
doClearanceBonusEvent = false;
this.evaluateEvent({action:"clearance bonus"});
wr("clearance!");
}
return(_local3);
};
this.setMidasGfx = function () {
var _local2;
if (midasCounter < 7) {
_local2 = midasCounter % 2;
} else {
_local2 = (midasCounter - 6) % 3;
}
var _local1 = 0;
while (_local1 < _local2) {
game.gui.addMidas(currentLevel);
_local1++;
}
};
this.sendEvent = function (props) {
if (game.gameOver) {
return(undefined);
}
var _local1 = String(props.code);
if (props.value) {
_local1 = _local1 + ("," + String(props.value));
}
_local1 = _local1 + ("=" + String(props.score));
fscommand ("playData", _local1);
};
}
function Logger() {
var theLog = new Array();
this.logEvent = function (data) {
theLog.push(data);
};
this.getLog = function () {
return(theLog);
};
}
function ScorePop(x, y, score, fontsize) {
var _local3 = {text:score + "", x:x, y:y, bold:true, size:fontsize || 12, align:"center"};
var _local2 = sprites.createText(_local3);
_local2.member_mc.background = true;
_local2.member_mc.backgroundColor = "0x404040";
_local2.member_mc.border = true;
_local2.member_mc.borderColor = "0xffffff";
_local2.toFront();
this.mysprite = _local2;
this.orig_y = this.mysprite._y;
this.curr_y = this.orig_y;
this.endPos = this.orig_y - 37;
if (this.endPos < 15) {
this.endPos = 15;
}
this.target_y = this.endPos;
this.move_y = this.orig_y != this.target_y;
this.v = 0;
this.nFrames = 10;
this.state = 1;
this.fadecounter = 100;
this.run = function () {
if (this.state == 1) {
this.v = Math.min(this.v + (Math.Pi / (this.nFrames * 2)), (Math.PI/2));
this.curr_y = this.orig_y + (Math.sin(this.v) * (this.target_y - this.orig_y));
this.mysprite._y = this.curr_y;
if (this.v >= (Math.PI/2)) {
this.state++;
}
} else if (this.state == 2) {
this.fadecounter = this.fadecounter - 9;
this.mysprite._alpha = this.fadecounter;
if (this.fadecounter < 10) {
events.stopIt(this);
sprites.remove(this.mysprite);
}
}
};
events.runIt(this);
}
function SlideSlow(props) {
this.mysprite = props.sprite;
this.orig_x = this.mysprite._x;
this.orig_y = this.mysprite._y;
this.curr_x = this.orig_x;
this.curr_y = this.orig_y;
this.target_x = ((typeof(props.x) == "number") ? (props.x) : (this.orig_x));
this.target_y = ((typeof(props.y) == "number") ? (props.y) : (this.orig_y));
this.move_x = this.orig_x != this.target_x;
this.move_y = this.orig_y != this.target_y;
this.callback = props.callback;
if (props.slideBack == true) {
this.slideBack = true;
} else {
this.slideBack = false;
}
this.v = 0;
this.nFrames = props.nFrames || 10;
this.run = function () {
var _local2 = (Math.PI/2);
if (this.slideBack) {
_local2 = Math.PI;
}
this.v = Math.min(this.v + (Math.Pi / (this.nFrames * 2)), _local2);
if (this.move_x) {
this.curr_x = this.orig_x + (Math.sin(this.v) * (this.target_x - this.orig_x));
this.mysprite._x = this.curr_x;
}
if (this.move_y) {
this.curr_y = this.orig_y + (Math.sin(this.v) * (this.target_y - this.orig_y));
this.mysprite._y = this.curr_y;
}
if (this.v >= _local2) {
events.stopIt(this);
if (this.callback) {
this.callback();
}
}
};
events.runIt(this);
}
function Zoom(props) {
this.mysprite = props.sprite;
this.mode = ((typeof(props.mode) == "string") ? (props.mode) : "in");
this.nFrames = props.frames || 10;
this.counter = this.nFrames;
this.zoomstep = 100 / this.nFrames;
if (this.mode == "in") {
this.zoomstep = -this.zoomstep;
this.currzoom = 0;
} else {
this.currzoom = 100;
}
this.xstep = (this.mysprite._width / 2) / this.nFrames;
this.ystep = (this.mysprite._height / 2) / this.nFrames;
this.callback = props.callback;
this.run = function () {
this.counter--;
this.currzoom = this.currzoom - this.zoomstep;
this.mysprite._xscale = this.currzoom;
this.mysprite._yscale = this.currzoom;
this.mysprite._x = this.mysprite._x + this.xstep;
this.mysprite._y = this.mysprite._y + this.ystep;
if (this.counter == 0) {
if (this.mode == "pulse") {
this.counter = this.nFrames;
this.zoomstep = -this.zoomstep;
} else {
events.stopIt(this);
if (this.callback) {
this.callback();
}
}
}
};
events.runIt(this);
}
function Xplode(props) {
this.start_x = props.x;
this.start_y = props.y;
this.multip = ((typeof(props.multip) == "number") ? (props.multip) : 1);
this.partcount = ((typeof(props.partcount) == "number") ? (props.partcount) : 3);
this.parts = new Array(this.partcount);
this.readycount = 0;
this.run = function () {
var _local3 = 0;
while (_local3 < this.partcount) {
var _local2 = this.parts[_local3];
if (_local2) {
_local2._x = _local2._x + _local2.direction;
_local2._y = _local2._y - _local2.speed;
_local2.speed = _local2.speed - 1.7;
if (_local2._y > _local2.endpos) {
sprites.remove(_local2);
this.parts[_local3] = null;
this.readycount++;
}
}
_local3++;
}
if (this.readycount >= this.partcount) {
events.stopIt(this);
}
};
this.start = function () {
var _local2 = 0;
while (_local2 < this.partcount) {
this.parts[_local2] = this.generatePart(_local2);
_local2++;
}
};
this.generatePart = function (partno) {
var _local4 = ((Math.random() * 8) + 2) * this.multip;
var _local3 = ((Math.random() * 4) + 0.5) * this.multip;
var _local5 = ((this.start_y + 25) + (Math.random() * 20)) * this.multip;
if ((partno % 2) == 0) {
_local3 = -_local3;
}
var _local2 = sprites.create({member:"g_star", x:this.start_x, y:this.start_y});
_local2.toFront();
_local2.speed = _local4;
_local2.direction = _local3;
_local2.endpos = _local5;
return(_local2);
};
this.start();
events.runIt(this);
}
function Hilite(g) {
this.running = false;
this.start_x = g.gameArrayPos_x + g.blockSize;
this.step_x = g.blockSize * 2;
this.steps = ((g.gameArrayWidth * 2) + 2) / 2;
this.mysprite = sprites.create({member:"glansen", y:g.gameArrayPos_y, visible:false});
this.mysprite._alpha = 80;
this.mysprite.toFront();
this.mask = sprites.create({member:"stagemask", x:g.gameArrayPos_x, y:g.gameArrayPos_y});
this.mask.toFront();
this.mysprite.setMask(this.mask);
this.run = function () {
this.step++;
if (this.step == this.steps) {
this.stop();
return(undefined);
}
this.mysprite._x = this.start_x + (this.step_x * this.step);
};
this.start = function () {
if (this.running) {
return(undefined);
}
this.running = true;
this.step = 0;
this.mysprite._x = this.start_x;
this.mysprite._visible = true;
events.runIt(this);
};
this.stop = function () {
if (!this.running) {
return(undefined);
}
this.running = false;
this.mysprite._visible = false;
events.stopIt(this);
};
}
function KrumelurBlink() {
this.mysprite = sprites.create({member:"krumelur_x", visible:false});
this.mysprite.toFront();
this.running = false;
this.stopflag = false;
this.blinklist;
this.blinkstep;
this.run = function () {
if (this.stopflag) {
return(this._stop());
}
this.blinklist[this.blinkstep]--;
if (this.blinklist[this.blinkstep] == 0) {
this.mysprite._visible = !this.mysprite._visible;
this.blinkstep++;
if (this.blinkstep == this.blinklist.length) {
this._stop();
}
}
};
this.blink = function (props) {
this.blinklist = [2, 2, 2, 2, 20, 1];
this.blinkstep = 0;
sprites.setMember(this.mysprite, props.member);
this.mysprite._x = props.x;
this.mysprite._y = props.y;
this.mysprite._visible = true;
if (!this.running) {
events.runIt(this);
}
this.running = true;
this.stopflag = false;
};
this.stop = function () {
this.stopflag = true;
};
this._stop = function () {
events.stopIt(this);
this.mysprite._visible = false;
this.running = false;
};
}
function Fuse() {
var anim = [[0, 0], [3, 0], [6, 1], [9, 1], [12, 2], [15, 2], [18, 3], [20, 4], [23, 5], [26, 6], [29, 7], [31, 8], [28, 9], [25, 9], [22, 9], [19, 9], [16, 10], [13, 10], [10, 10], [7, 10], [4, 10], [1, 10], [-2, 10], [-5, 10], [-8, 10], [-11, 10], [-14, 11], [-16, 12], [-18, 14], [-17, 17], [-14, 18], [-11, 19], [-9, 20], [-6, 21], [-3, 21], [0, 21], [3, 22], [6, 22], [9, 22], [12, 22], [15, 21], [18, 21], [21, 21], [24, 20], [27, 20], [30, 19], [33, 19], [35, 18], [38, 17], [41, 16], [44, 14], [46, 13], [49, 11], [51, 9], [53, 8], [56, 6], [59, 5], [62, 5], [65, 4], [68, 4], [71, 3], [73, 3], [76, 3], [79, 3], [82, 3], [85, 3], [88, 4], [91, 4], [94, 5], [97, 7], [99, 8], [99, 11], [99, 14], [101, 17], [103, 18], [106, 19], [109, 19], [112, 20], [115, 20], [118, 20], [121, 20], [123, 21], [125, 23], [127, 25], [128, 28], [129, 31], [130, 34], [131, 37], [132, 39], [132, 42], [132, 45], [131, 48], [131, 51], [131, 54], [130, 57], [130, 60], [129, 63], [129, 66], [130, 69], [130, 72]];
var _local7 = anim.length;
var animStep = -1;
var start_x = 134;
var start_y = 239;
var fusesprite = thefuse;
var flamesprite = sprites.create({member:"flame", x:-500, y:-500});
this.update = function (_time, _totsec) {
var _local2 = (_time / _totsec) / 10;
var _local1 = 99 - Math.floor(_local2);
if (_local1 == animStep) {
} else {
animStep = Math.min(_local1, 100);
if (animStep <= 0) {
if (flamesprite != false) {
sprites.remove(flamesprite);
flamesprite = false;
}
return(undefined);
}
flamesprite._x = start_x + anim[animStep][0];
flamesprite._y = start_y + anim[animStep][1];
fusesprite._alpha = Math.min(100, animStep + 15);
}
};
this.updateMoves = function (moves, totalMoves) {
var _local1 = Math.floor(100 * (moves / totalMoves));
if (_local1 > 99) {
_local1 = 99;
}
flamesprite._x = start_x + anim[_local1][0];
flamesprite._y = start_y + anim[_local1][1];
};
this.kill = function () {
if (flamesprite != false) {
sprites.remove(flamesprite);
flamesprite = false;
}
};
}
function Initslide(props) {
this.mysprite = props.sprite;
this.orig_x = this.mysprite._x;
this.orig_y = this.mysprite._y;
this.curr_x = this.orig_x;
this.curr_y = this.orig_y;
this.target_x = ((typeof(props.x) == "number") ? (props.x) : (this.orig_x));
this.target_y = ((typeof(props.y) == "number") ? (props.y) : (this.orig_y));
this.move_x = this.orig_x != this.target_x;
this.move_y = this.orig_y != this.target_y;
this.callback = props.callback;
this.delay = props.delay || 0;
this.v = 0;
this.nFrames = props.nFrames || 10;
this.run = function () {
if (this.delay > 0) {
this.delay--;
return(undefined);
}
this.v = Math.min(this.v + (Math.Pi / (this.nFrames * 2)), (Math.PI/2));
if (this.move_x) {
this.curr_x = this.orig_x + (Math.sin(this.v) * (this.target_x - this.orig_x));
this.mysprite._x = this.curr_x;
}
if (this.move_y) {
this.curr_y = this.orig_y + (Math.sin(this.v) * (this.target_y - this.orig_y));
if (this.curr_y > 10) {
this.mysprite._visible = true;
}
this.mysprite._y = this.curr_y;
}
if (this.v >= (Math.PI/2)) {
events.stopIt(this);
if (this.callback) {
this.callback();
}
}
};
events.runIt(this);
}
function Game() {
function start() {
var _local1 = new XML();
_local1.ignoreWhite = true;
_local1.parseXML(gameData);
random.setSeed(parseInt(_local1.firstChild.attributes.randomseed));
skillLevel = ((typeof(_local1.firstChild.attributes.skilllevel) == "string") ? (parseInt(_local1.firstChild.attributes.skilllevel)) : 1);
colours = ((typeof(_local1.firstChild.attributes.colours) == "string") ? (parseInt(_local1.firstChild.attributes.colours)) : 7);
if (isNan(colours)) {
colours = 7;
} else if (colours < 4) {
colours = 4;
} else if (colours > 7) {
colours = 7;
}
if (_local1.firstChild.attributes.relaxMode == "true") {
relaxMode = true;
totalMoves = Number(_local1.firstChild.attributes.moves);
moves = totalMoves;
} else {
gameDuration = ((typeof(_local1.firstChild.attributes.timelimit) == "string") ? (parseInt(_local1.firstChild.attributes.timelimit)) : 180);
}
postScoreDelay = ((typeof(_local1.firstChild.attributes.postdelay) == "string") ? (parseInt(_local1.firstChild.attributes.postdelay) * 25) : 75);
finalScoreText = ((typeof(_local1.final.firstChild.nodeValue) == "string") ? (_local1.final.firstChild.nodeValue) : "You Got");
timeUpText = ((typeof(_local1.timeup.firstChild.nodeValue) == "string") ? (_local1.timeup.firstChild.nodeValue) : "TIME UP!");
gameOverText = ((typeof(_local1.gameover.firstChild.nodeValue) == "string") ? (_local1.gameover.firstChild.nodeValue) : "GAME OVER!");
noMovesText = ((typeof(_local1.nomoves.firstChild.nodeValue) == "string") ? (_local1.nomoves.firstChild.nodeValue) : "No more moves!");
robot = 0;
if (robot) {
clickTimeDefault.hint = 1000;
}
var _local2 = new Object();
_local2.points = _local1.score.firstChild.nodeValue;
if (relaxMode) {
_local2.time = _local1.moves.firstChild.nodeValue;
} else {
_local2.time = _local1.time.firstChild.nodeValue;
}
_local2.instruction = _local1.instruction.firstChild.nodeValue;
_local2.end = _local1.end.firstChild.nodeValue;
game.gui.setupHeaders(_local2);
self.setUpLevel();
fps_status = new Object();
fps_status.lastTime = new Date().getTime();
fps_status.frameCnt = 0;
events.runIt(self);
wr("start game.run");
fscommand ("gameStart");
}
function selectBlock(theBlock) {
selectedBlock = theBlock;
sprites.setMember(selectedBlock, game.blockColors[selectedBlock.color] + "1");
}
function deSelectBlock() {
sprites.setMember(selectedBlock, game.blockColors[selectedBlock.color]);
selectedBlock = false;
}
function swapBlocks(b1, b2) {
x1 = b1.gridX;
y1 = b1.gridY;
x2 = b2.gridX;
y2 = b2.gridY;
var _local3 = false;
game.evaluateEvent({action:"reset multiplier"});
if ((x1 == x2) && (Math.abs(y1 - y2) == 1)) {
_local3 = true;
}
if ((y1 == y2) && (Math.abs(x1 - x2) == 1)) {
_local3 = true;
}
if (!_local3) {
return(undefined);
}
game.krumelur.stop();
gameArray[x1][y1] = b2;
gameArray[x2][y2] = b1;
b1.gridX = x2;
b1.gridY = y2;
b2.gridX = x1;
b2.gridY = y1;
var _local6 = 1 + checkBlockRight(b1.gridX + 1, b1.gridY, b1.color);
_local6 = _local6 + checkBlockLeft(b1.gridX - 1, b1.gridY, b1.color);
var _local4 = 1 + checkBlockUp(b1.gridX, b1.gridY + 1, b1.color);
_local4 = _local4 + checkBlockDown(b1.gridX, b1.gridY - 1, b1.color);
var _local7 = 1 + checkBlockRight(b2.gridX + 1, b2.gridY, b2.color);
_local7 = _local7 + checkBlockLeft(b2.gridX - 1, b2.gridY, b2.color);
var _local5 = 1 + checkBlockUp(b2.gridX, b2.gridY + 1, b2.color);
_local5 = _local5 + checkBlockDown(b2.gridX, b2.gridY - 1, b2.color);
if ((((_local6 < 3) && (_local4 < 3)) && (_local7 < 3)) && (_local5 < 3)) {
gameArray[x1][y1] = b1;
gameArray[x2][y2] = b2;
b1.gridX = x1;
b1.gridY = y1;
b2.gridX = x2;
b2.gridY = y2;
var _local8 = function () {
game.sliding = false;
game.checkCombos();
};
props = {sprite:b1, slideBack:true, x:game.gameArrayPos_x + (x2 * game.blockSize), y:game.gameArrayPos_y + (((game.gameArrayHeight - y2) - 1) * game.blockSize)};
new SlideSlow(props);
var props = {callback:_local8, slideBack:true, sprite:b2, x:game.gameArrayPos_x + (x1 * game.blockSize), y:game.gameArrayPos_y + (((game.gameArrayHeight - y1) - 1) * game.blockSize)};
new SlideSlow(props);
game.sliding = true;
} else {
moves--;
setClickTime();
game.blockcheckCountOnClick = (game.blockcheckCount = game.blockcheckCount - (game.blockcheckCount % 2));
game.blockcheckCountOnline = false;
var _local8 = function () {
game.sliding = false;
game.checkCombos();
};
props = {sprite:b1, x:game.gameArrayPos_x + (x2 * game.blockSize), y:game.gameArrayPos_y + (((game.gameArrayHeight - y2) - 1) * game.blockSize)};
new SlideSlow(props);
var props = {callback:_local8, sprite:b2, x:game.gameArrayPos_x + (x1 * game.blockSize), y:game.gameArrayPos_y + (((game.gameArrayHeight - y1) - 1) * game.blockSize)};
new SlideSlow(props);
game.sliding = true;
}
soundFx.play("swapsound.wav");
}
function checkBlockRight(x, y, color) {
var _local1 = x;
while (((gameArray[_local1][y].color == color) && (!gameArray[_local1][y].busy)) && (!gameArray[_local1][y].tagged)) {
_local1++;
}
return(_local1 - x);
}
function checkBlockLeft(x, y, color) {
var _local1 = x;
while (((gameArray[_local1][y].color == color) && (!gameArray[_local1][y].busy)) && (!gameArray[_local1][y].tagged)) {
_local1--;
}
return(x - _local1);
}
function checkBlockUp(x, y, color) {
var _local1 = y;
while (((gameArray[x][_local1].color == color) && (!gameArray[x][_local1].busy)) && (!gameArray[x][_local1].tagged)) {
_local1++;
}
return(_local1 - y);
}
function checkBlockDown(x, y, color) {
var _local1 = y;
while (((gameArray[x][_local1].color == color) && (!gameArray[x][_local1].busy)) && (!gameArray[x][_local1].tagged)) {
_local1--;
}
return(y - _local1);
}
function checkBlock(x, y) {
var _local1 = gameArray[x][y].color;
return(Math.max(checkBlockRight(x + 1, y, _local1) + checkBlockLeft(x, y, _local1), checkBlockUp(x, y + 1, _local1) + checkBlockDown(x, y, _local1)));
}
function testSwap(x1, y1, x2, y2) {
var _local5 = gameArray[x1][y1];
gameArray[x1][y1] = gameArray[x2][y2];
gameArray[x2][y2] = _local5;
var _local6 = Math.max(checkBlock(x1, y1), checkBlock(x2, y2));
gameArray[x2][y2] = gameArray[x1][y1];
gameArray[x1][y1] = _local5;
return(_local6);
}
function checkPossibleMoves() {
if (game.droppingBlockCnt > 0) {
return(undefined);
}
if (game.sliding == true) {
return(undefined);
}
var _local1 = Math.floor(game.blockcheckCount / 2);
if ((_local1 * 2) == game.blockcheckCount) {
game.blockCheckData[_local1] = new Array();
}
var _local6 = Math.floor(game.gameArrayWidth / 2) * (game.blockcheckCount % 2);
var _local7 = _local6 + Math.floor(game.gameArrayWidth / 2);
var _local5 = _local6;
while (_local5 < _local7) {
if (_local5 < (game.gameArrayWidth - 1)) {
if (testSwap(_local5, _local1, _local5 + 1, _local1) >= 3) {
game.blockCheckData[_local1].push({x:_local5, vertical:false});
}
}
if (_local1 < (game.gameArrayHeight - 1)) {
if (testSwap(_local5, _local1, _local5, _local1 + 1) >= 3) {
game.blockCheckData[_local1].push({x:_local5, vertical:true});
}
}
_local5++;
}
game.blockcheckCount = (game.blockcheckCount + 1) % (game.gameArrayHeight * 2);
if (game.blockcheckCountOnClick == game.blockcheckCount) {
game.blockcheckCountOnline = true;
var _local3;
var _local2 = 0;
while (_local2 < game.gameArrayHeight) {
_local3 = _local3 + game.blockCheckData[_local2].length;
if (_local3 > 0) {
break;
}
_local2++;
}
if (_local3 == 0) {
game.killLevel();
var _local8 = new ScorePop(431, 250, noMovesText, 12);
_local8.target_y = 112;
_local8.nFrames = 15;
return(undefined);
}
}
}
function showHintMove() {
if (game.droppingBlockCnt > 0) {
return(undefined);
}
if (game.sliding == true) {
return(undefined);
}
if (!game.blockcheckCountOnline) {
return(undefined);
}
if (tryGameOver) {
return(undefined);
}
var _local7 = random.range(0, game.gameArrayHeight - 1);
var _local1;
var _local2;
var _local5;
var _local6;
var _local4 = 0;
while (_local4 < game.gameArrayHeight) {
_local1 = (_local7 + _local4) % game.gameArrayHeight;
if (game.blockCheckData[_local1].length > 0) {
_local5 = random.rangeFromSeed2(0, game.blockCheckData[_local1].length - 1);
_local2 = game.blockCheckData[_local1][_local5].x;
_local6 = game.blockCheckData[_local1][_local5].vertical;
var _local3;
if (_local6) {
_local3 = {x:game.gameArrayPos_x + (_local2 * game.blockSize), y:game.gameArrayPos_y + (((game.gameArrayHeight - _local1) - 2) * game.blockSize)};
_local3.member = "krumelur_y";
if (robot) {
swapBlocks(gameArray[_local2][_local1], gameArray[_local2][_local1 + 1]);
}
} else {
_local3 = {x:game.gameArrayPos_x + (_local2 * game.blockSize), y:game.gameArrayPos_y + (((game.gameArrayHeight - _local1) - 1) * game.blockSize)};
_local3.member = "krumelur_x";
if (robot) {
swapBlocks(gameArray[_local2][_local1], gameArray[_local2 + 1][_local1]);
}
}
game.krumelur.blink(_local3);
return(undefined);
}
_local4++;
}
}
function moveDownBlocks() {
var _local2 = 0;
while (_local2 < gameArray.length) {
var _local3 = 0;
var _local6 = 0;
while (_local6 < gameArray[_local2].length) {
if (gameArray[_local2][_local6]) {
if (_local3 < _local6) {
var _local1 = gameArray[_local2][_local6];
var _local4 = _local1.gridY - _local3;
if (_local1.busy) {
_local1.droptarget_y = _local1.droptarget_y + (_local4 * game.blockSize);
} else {
var _local5 = function () {
game.droppingBlockCnt--;
if (game.droppingBlockCnt == 0) {
game.checkCombos();
}
};
var _local7 = {sprite:_local1, y:_local1._y + (_local4 * game.blockSize), callback:_local5};
game.blockDropper.dropBlock(_local7);
game.droppingBlockCnt++;
_local1.busy = true;
}
_local1.gridY = _local3;
gameArray[_local2][_local3] = _local1;
gameArray[_local2][_local6] = false;
_local3++;
} else {
_local3++;
}
}
_local6++;
}
_local2++;
}
if (game.droppingBlockCnt == 0) {
}
}
function clearBlockTags() {
var _local2 = tagList.length;
var _local1 = 0;
while (_local1 < _local2) {
tagList[_local1].tagged = false;
_local1++;
}
tagList = new Array();
}
function selectTaggedBlocks() {
var _local2 = tagList.length;
var _local1 = 0;
while (_local1 < _local2) {
sprites.setMember(tagList[_local1], game.blockColors[tagList[_local1].color] + "1");
tagList[_local1].selected = true;
_local1++;
}
}
function deselectBlocks() {
var _local2 = tagList.length;
var _local1 = 0;
while (_local1 < _local2) {
sprites.setMember(tagList[_local1], game.blockColors[tagList[_local1].color]);
tagList[_local1].tagged = false;
tagList[_local1].selected = false;
_local1++;
}
tagList = new Array();
}
function killBlock(block) {
block.busy = true;
block.tagged = false;
var _local4 = {member:"midas", x:block._x, y:block._y};
if (!_local4.x) {
wr("Error! killblock called with block:", block);
}
new Xplode({x:block._x + (block._width / 2), y:block._y + (block._height / 2)});
x = block.gridX;
y = block.gridY;
gameArray[x][y] = false;
gameArray[x].blockCount--;
sprites.remove(block);
}
function killTaggedBlocks() {
var _local3 = tagList.length;
var _local5;
var _local4;
if (_local3 > 0) {
var _local1 = 0;
while (_local1 < _local3) {
var _local2 = tagList[_local1];
killBlock(_local2);
_local1++;
}
}
tagList = new Array();
}
function setClickTime(secs) {
var _local1 = new Date().getTime();
if (secs) {
_local1 = _local1 + secs;
}
for (var _local2 in clickTimeDefault) {
clickTime[_local2] = _local1;
}
}
function checkClickTime(prop, no_reset) {
if (clickTime[prop] == 0) {
return(false);
}
var _local2 = new Date().getTime();
if ((_local2 - clickTime[prop]) >= clickTimeDefault[prop]) {
if (no_reset) {
clickTime[prop] = 0;
} else {
clickTime[prop] = _local2;
}
return(true);
}
return(false);
}
var relaxMode = false;
var totalMoves;
var moves;
var self = this;
this.blockSize = 37;
this.blockColors = ["blue", "purple", "green", "white", "red", "orange", "midas"];
this.gameArrayPos_x = 282;
this.gameArrayPos_y = 68;
this.gameArrayWidth = 8;
this.gameArrayHeight = 8;
this.gameArrayStartHeight = 8;
this.frameCnt = 0;
this.gameOver = false;
var tryGameOver = false;
var gameOverreason;
this.blockDropper = new blockDropper();
this.blockDropper.start();
gameNotStarted = true;
this.blockcheckCount = 0;
this.blockcheckCountOnClick = 0;
this.blockcheckCountOnline = false;
this.blockCheckData = new Array();
this.sliding = false;
this.changingLevel = true;
var clickTimeDefault = {inactive:3000, hilite:6000, hint:10000};
var clickTime = {};
var skillLevel;
var colours;
var gameArray;
var tagList = new Array();
var finalScoreText;
var timeUpText;
var gameOverText;
var noMovesText;
var postScoreDelay;
var robot;
var scoreObj = new Score();
var log = new Logger();
this.gui = new Gui();
this.hilite = new Hilite(this);
this.krumelur = new KrumelurBlink();
this.droppingBlockCnt = 0;
this.fuse = new Fuse();
var startTime = new Date().getTime();
var gameDuration;
var selectedBlock;
var fps_status;
this.initialize = function () {
var _local2 = new Object();
_local2.run = function () {
if (gameData != undefined) {
events.stopIt(this);
game.callStart();
}
};
events.runIt(_local2);
};
this.callStart = function () {
start();
};
this.setUpLevel = function () {
this.blockCheckData = new Array();
setClickTime(2000);
if (gameArray) {
gameArray = null;
}
selectedBlock = false;
this.droppingBlockCnt = 0;
this.sliding = false;
var _local15 = 0;
gameArray = new Array();
var _local2 = 0;
while (_local2 < game.gameArrayWidth) {
gameArray.push(new Array());
var _local13 = 0;
while (_local13 < game.gameArrayHeight) {
gameArray[_local2].push(false);
_local13++;
}
gameArray[_local2].blockCount = 0;
_local13 = 0;
while (_local13 < game.gameArrayHeight) {
var _local4 = true;
var _local3;
var _local7 = 0;
while (_local4) {
_local3 = random.rangeFromSeed(0, colours - 1);
_local4 = (checkBlockDown(_local2, _local13 - 1, _local3) >= 2) || (checkBlockLeft(_local2 - 1, _local13, _local3) >= 2);
_local7++;
}
this.pushBall(_local2, _local3, _local13);
_local13++;
}
_local2++;
}
_local2 = 0;
while (_local2 < game.gameArrayWidth) {
var _local14 = function () {
soundFx.play("blockdrop.aif", false);
game.droppingBlockCnt--;
if (game.droppingBlockCnt == 0) {
game.checkCombos();
}
};
var _local12 = function () {
game.droppingBlockCnt--;
if (game.droppingBlockCnt == 0) {
game.checkCombos();
}
};
var _local13 = 0;
while (_local13 < game.gameArrayHeight) {
var _local5 = _local13 + _local2;
var _local6 = gameArray[_local2][_local13]._y;
gameArray[_local2][_local13]._y = 20;
((-_local13) * this.blockSize) / 2;
if ((_local13 == 0) && ((_local2 % 2) == 0)) {
props = {callback:_local14, sprite:gameArray[_local2][_local13], y:_local6, delay:_local5, nFrames:7};
} else {
props = {callback:_local12, sprite:gameArray[_local2][_local13], y:_local6, delay:_local5, nFrames:7};
}
new Initslide(props);
game.droppingBlockCnt++;
_local13++;
}
_local2++;
}
game.changingLevel = false;
moveDownBlocks();
};
this.killLevel = function () {
var _local10 = function () {
};
var _local12 = new Delay(_local10, 8);
game.changingLevel = true;
var _local4 = 0;
var _local9 = function () {
sprites.remove(this.mysprite);
};
var _local3 = 0;
var _local2 = 0;
while (_local2 < game.gameArrayWidth) {
var _local8 = 0;
while (_local8 < game.gameArrayHeight) {
tmpSprite = gameArray[_local2][_local8];
if (tmpSprite) {
tmpSprite.onPress = null;
_local3 = _local8 + _local2;
new Slide({sprite:tmpSprite, y:tmpSprite._y + 400, nFrames:15, callback:_local9, delay:_local3});
_local4 = Math.max(_local4, _local3);
}
_local8++;
}
_local2++;
}
var _local11 = function () {
if (game.gameOver) {
return(undefined);
}
game.setUpLevel();
};
var _local13 = new Delay(_local11, _local4 + 16);
};
this.nextLevel = function () {
this.killLevel();
};
this.run = function () {
this.frameCnt++;
var _local3 = new Date().getTime();
if (tryGameOver) {
this.setGameOver2();
}
if (this.gameOver) {
return(undefined);
}
if (game.changingLevel == true) {
return(undefined);
}
if (!relaxMode) {
if (checkClickTime("inactive")) {
game.evaluateEvent({action:"inactive", value:n});
}
}
if (checkClickTime("hint")) {
showHintMove();
}
if (checkClickTime("hilite", true)) {
this.hilite.start();
}
if (gameNotStarted) {
startTime = _local3;
}
if (!relaxMode) {
var _local2 = Math.round(gameDuration - ((_local3 - startTime) / 1000));
_local2 = Math.max(0, _local2);
_local2 = Math.min(gameDuration, _local2);
if (((gameDuration * 1000) - (_local3 - startTime)) <= 0) {
game.setGameOver(timeUpText);
}
var _local5 = String(Math.floor(_local2 / 60) + ":");
var _local4 = _local2 % 60;
_local5 = _local5 + ((_local4 < 10) ? ("0" + _local4) : (_local4));
this.gui.setTime(_local5);
if (!gameNotStarted) {
this.fuse.update(_local3 - startTime, gameDuration);
}
} else {
this.gui.setTime("" + moves);
if (moves <= 0) {
game.setGameOver(noMovesText);
}
if (!gameNotStarted) {
this.fuse.updateMoves(moves, totalMoves);
}
}
checkPossibleMoves();
};
this.setGameOver = function (reason) {
tryGameOver = true;
gameOverreason = reason;
if (this.gameOver) {
return(undefined);
}
var _local3 = 0;
while (_local3 < game.gameArrayWidth) {
var _local2 = 0;
while (_local2 < game.gameArrayHeight) {
tmpSprite = gameArray[_local3][_local2];
if (tmpSprite) {
tmpSprite.onPress = none;
}
_local2++;
}
_local3++;
}
this.setGameOver2();
};
this.setGameOver2 = function () {
if (this.gameOver) {
return(undefined);
}
if (game.droppingBlockCnt > 0) {
return(undefined);
}
if (game.sliding == true) {
return(undefined);
}
this.gameOver = true;
var _local2 = ((typeof(gameOverreason) == "string") ? (gameOverreason) : (gameOverText));
this.gui.alert(_local2, (finalScoreText + ": ") + game.getScore());
this.gui.gameIsOver();
this.fuse.kill();
new Xplode({x:176, y:234, partcount:25, multip:2});
soundFx.play("gameover.aif");
new Delay(function () {
game.generateMagicBall();
}, postScoreDelay);
};
this.pushBall = function (x, color, insert_y) {
if (typeof(insert_y) != "number") {
insert_y = game.gameArrayHeight - 1;
}
var _local5 = gameArray[x].length - 1;
while (_local5 > insert_y) {
gameArray[x][_local5] = gameArray[x][_local5 - 1];
gameArray[x][_local5].gridY = _local5;
gameArray[x][_local5]._y = game.gameArrayPos_y + (((game.gameArrayHeight - _local5) - 1) * game.blockSize);
_local5--;
}
_local5 = insert_y;
var _local6 = game.blockColors[color];
var _local7 = {member:_local6, visible:false, x:game.gameArrayPos_x + (x * game.blockSize), y:game.gameArrayPos_y + (((game.gameArrayHeight - _local5) - 1) * game.blockSize)};
var _local2 = sprites.create(_local7);
_local2.useHandCursor = false;
_local2.gridX = x;
_local2.gridY = _local5;
_local2.busy = false;
_local2.tagged = false;
_local2.selected = false;
_local2.color = color;
if (!tryGameOver) {
_local2.onPress = function () {
game.clickBlock(this);
};
}
gameArray[x][_local5] = _local2;
gameArray[x].blockCount++;
return(true);
};
this.getLevel = function () {
return(scoreObj.getLevel());
};
this.clickBlock = function (clickedBlock) {
if (this.droppingBlockCnt > 0) {
return(undefined);
}
if (this.sliding == true) {
return(undefined);
}
this.hilite.stop();
if (selectedBlock) {
swapBlocks(clickedBlock, selectedBlock);
deSelectBlock();
return(undefined);
}
selectBlock(clickedBlock);
};
this.checkCombos = function () {
gameNotStarted = false;
var _local5 = -1;
var _local2 = 1;
var _local3 = 0;
while (_local3 < this.gameArrayWidth) {
var _local4 = 0;
while (_local4 < (this.gameArrayHeight + 1)) {
if (gameArray[_local3][_local4].color == _local5) {
_local2++;
} else {
if (_local2 >= 3) {
setClickTime();
var _local6 = game.evaluateEvent({action:"clear gems", value:_local2});
new ScorePop((this.gameArrayPos_x + ((_local3 + 0.5) * this.blockSize)) + 2, (this.gameArrayPos_y + (((this.gameArrayHeight - _local4) + (_local2 / 2)) * this.blockSize)) - 8, _local6);
while (_local2 > 0) {
if (!gameArray[_local3][_local4 - _local2].tagged) {
gameArray[_local3][_local4 - _local2].tagged = true;
taglist.push(gameArray[_local3][_local4 - _local2]);
_local2--;
}
}
}
_local5 = gameArray[_local3][_local4].color;
_local2 = 1;
}
_local4++;
}
_local2 = 1;
_local5 = -1;
_local3++;
}
var _local4 = 0;
while (_local4 < this.gameArrayHeight) {
_local3 = 0;
while (_local3 < (this.gameArrayWidth + 1)) {
if (gameArray[_local3][_local4].color == _local5) {
_local2++;
} else {
if (_local2 >= 3) {
setClickTime();
var _local6 = game.evaluateEvent({action:"clear gems", value:_local2});
new ScorePop((this.gameArrayPos_x + ((_local3 - (_local2 / 2)) * this.blockSize)) + 2, (this.gameArrayPos_y + (((this.gameArrayHeight - _local4) - 1) * this.blockSize)) + 10, _local6);
while (_local2 > 0) {
if (!gameArray[_local3 - _local2][_local4].tagged) {
gameArray[_local3 - _local2][_local4].tagged = true;
taglist.push(gameArray[_local3 - _local2][_local4]);
}
_local2--;
}
}
_local5 = gameArray[_local3][_local4].color;
_local2 = 1;
}
_local3++;
}
_local2 = 1;
_local5 = -1;
_local4++;
}
_local2 = taglist.length;
killTaggedBlocks();
if (_local2 > 0) {
game.feedNewBlocks();
}
};
this.feedNewBlocks = function () {
var _local3;
var _local5 = 0;
var _local2 = 0;
while (_local2 < game.gameArrayWidth) {
_local3 = 0;
while (gameArray[_local2].blockCount < game.gameArrayHeight) {
var _local4 = random.rangeFromSeed(0, colours - 1);
this.pushBall(_local2, _local4, game.gameArrayHeight + _local3);
_local3++;
}
_local5 = Math.max(_local3, _local5);
_local2++;
}
if (_local5 > 0) {
moveDownBlocks();
}
};
this.getScore = function () {
return(scoreObj.getScore());
};
this.getLevel = function () {
return(scoreObj.getLevel());
};
this.getSkillLevel = function () {
return(skillLevel);
};
this.getColours = function () {
return(colours);
};
this.evaluateEvent = function (props) {
if (gameOver) {
return(undefined);
}
log.logEvent(props);
return(scoreObj.evaluateEvent(props));
};
this.generateMagicBall = function () {
var _local3 = new Score();
var _local2 = log.getLog();
var _local1 = 0;
while (_local1 < _local2.length) {
_local3.evaluateEvent(_local2[_local1]);
_local1++;
}
var _local4 = _local3.getScore();
wr("THIS IS THE FINAL RESULT:");
wr("SCORE:", _local4);
wr(".......................... wowowowo");
gameResult = _local4;
fscommand ("gameOver", String(_local4));
};
}
function startup() {
if (_gameStarted) {
return(undefined);
}
_gameStarted = true;
game = new Game("MidasMiner");
game.initialize();
}
sprites = new Sprites();
events = new Events();
soundFx = new SoundFx();
random = new Random();
var gameResult = undefined;
var gameData = undefined;
Stage.showMenu = false;
Stage.scaleMode = "noScale";
stop();
startup();