Frame 1
var MochiAd = {showPreloaderAd:function (options) {
var _local29 = {clip:_root, ad_timeout:3000, fadeout_time:250, regpt:"o", method:"showPreloaderAd", color:16747008, background:16777161, outline:13994812};
options = MochiAd._parseOptions(options, _local29);
var _local15 = options.clip;
var _local25 = 11000;
var _local28 = options.ad_timeout;
delete options.ad_timeout;
var fadeout_time = options.fadeout_time;
delete options.fadeout_time;
if (!MochiAd.load(options)) {
return(undefined);
}
_local15.stop();
var mc = _local15._mochiad;
mc.onUnload = function () {
this._parent.play();
};
var _local16 = MochiAd._getRes(options);
var _local5 = _local16[0];
var _local14 = _local16[1];
mc._x = _local5 * 0.5;
mc._y = _local14 * 0.5;
var chk = mc.createEmptyMovieClip("_mochiad_wait", 3);
chk._x = _local5 * -0.5;
chk._y = _local14 * -0.5;
var _local8 = chk.createEmptyMovieClip("_mochiad_bar", 4);
_local8._x = 10;
_local8._y = _local14 - 20;
var _local24 = options.color;
delete options.color;
var _local21 = options.background;
delete options.background;
var _local26 = options.outline;
delete options.outline;
var _local6 = _local8.createEmptyMovieClip("_outline", 1);
_local6.beginFill(_local21);
_local6.moveTo(0, 0);
_local6.lineTo(_local5 - 20, 0);
_local6.lineTo(_local5 - 20, 10);
_local6.lineTo(0, 10);
_local6.lineTo(0, 0);
_local6.endFill();
var _local4 = _local8.createEmptyMovieClip("_inside", 2);
_local4.beginFill(_local24);
_local4.moveTo(0, 0);
_local4.lineTo(_local5 - 20, 0);
_local4.lineTo(_local5 - 20, 10);
_local4.lineTo(0, 10);
_local4.lineTo(0, 0);
_local4.endFill();
_local4._xscale = 0;
var _local7 = _local8.createEmptyMovieClip("_outline", 3);
_local7.lineStyle(0, _local26, 100);
_local7.moveTo(0, 0);
_local7.lineTo(_local5 - 20, 0);
_local7.lineTo(_local5 - 20, 10);
_local7.lineTo(0, 10);
_local7.lineTo(0, 0);
chk.ad_msec = _local25;
chk.ad_timeout = _local28;
chk.started = getTimer();
chk.showing = false;
chk.last_pcnt = 0;
chk.fadeout_time = fadeout_time;
chk.fadeFunction = function () {
var _local2 = 100 * (1 - ((getTimer() - this.fadeout_start) / this.fadeout_time));
if (_local2 > 0) {
this._parent._alpha = _local2;
} else {
var _local3 = this._parent._parent;
MochiAd.unload(_local3);
delete this.onEnterFrame;
}
};
mc.lc.adjustProgress = function (msec) {
var _local2 = this.mc._mochiad_wait;
_local2.server_control = true;
_local2.started = getTimer();
_local2.ad_msec = msec;
};
chk.onEnterFrame = function () {
var _local6 = this._parent._parent;
var _local12 = this._parent._mochiad_ctr;
var _local5 = getTimer() - this.started;
var _local3 = false;
var _local4 = _local6.getBytesTotal();
var _local8 = _local6.getBytesLoaded();
var _local10 = (100 * _local8) / _local4;
var _local11 = (100 * _local5) / chk.ad_msec;
var _local9 = this._mochiad_bar._inside;
var _local2 = Math.min(100, Math.min(_local10 || 0, _local11));
_local2 = Math.max(this.last_pcnt, _local2);
this.last_pcnt = _local2;
_local9._xscale = _local2;
if (!chk.showing) {
var _local7 = _local12.getBytesTotal();
if ((_local7 > 0) || (typeof(_local7) == "undefined")) {
chk.showing = true;
chk.started = getTimer();
} else if (_local5 > chk.ad_timeout) {
_local3 = true;
}
}
if (_local5 > chk.ad_msec) {
_local3 = true;
}
if (((_local4 > 0) && (_local8 >= _local4)) && (_local3)) {
if (this.server_control) {
delete this.onEnterFrame;
} else {
this.fadeout_start = getTimer();
this.onEnterFrame = chk.fadeFunction;
}
}
};
}, showTimedAd:function (options) {
var _local15 = {clip:_root, ad_timeout:2000, fadeout_time:250, regpt:"o", method:"showTimedAd"};
options = MochiAd._parseOptions(options, _local15);
var _local6 = options.clip;
var _local12 = 11000;
var _local14 = options.ad_timeout;
delete options.ad_timeout;
var fadeout_time = options.fadeout_time;
delete options.fadeout_time;
if (!MochiAd.load(options)) {
return(undefined);
}
_local6.stop();
var mc = _local6._mochiad;
mc.onUnload = function () {
this._parent.play();
};
var _local7 = MochiAd._getRes(options);
var _local16 = _local7[0];
var _local13 = _local7[1];
mc._x = _local16 * 0.5;
mc._y = _local13 * 0.5;
var chk = mc.createEmptyMovieClip("_mochiad_wait", 3);
chk.ad_msec = _local12;
chk.ad_timeout = _local14;
chk.started = getTimer();
chk.showing = false;
chk.fadeout_time = fadeout_time;
chk.fadeFunction = function () {
var _local2 = 100 * (1 - ((getTimer() - this.fadeout_start) / this.fadeout_time));
if (_local2 > 0) {
this._parent._alpha = _local2;
} else {
var _local3 = this._parent._parent;
MochiAd.unload(_local3);
delete this.onEnterFrame;
}
};
mc.lc.adjustProgress = function (msec) {
var _local2 = this.mc._mochiad_wait;
_local2.server_control = true;
_local2.started = getTimer();
_local2.ad_msec = msec - 250;
};
chk.onEnterFrame = function () {
var _local5 = this._parent._mochiad_ctr;
var _local4 = getTimer() - this.started;
var _local2 = false;
if (!chk.showing) {
var _local3 = _local5.getBytesTotal();
if ((_local3 > 0) || (typeof(_local3) == "undefined")) {
chk.showing = true;
chk.started = getTimer();
} else if (_local4 > chk.ad_timeout) {
_local2 = true;
}
}
if (_local4 > chk.ad_msec) {
_local2 = true;
}
if (_local2) {
if (this.server_control) {
delete this.onEnterFrame;
} else {
this.fadeout_start = getTimer();
this.onEnterFrame = this.fadeFunction;
}
}
};
}, _allowDomains:function (server) {
var _local1 = server.split("/")[2].split(":")[0];
if (System.security) {
if (System.security.allowDomain) {
System.security.allowDomain("*");
System.security.allowDomain(_local1);
}
if (System.security.allowInsecureDomain) {
System.security.allowInsecureDomain("*");
System.security.allowInsecureDomain(_local1);
}
}
return(_local1);
}, _loadCommunicator:function (options) {
var _local25 = {clip:_root, com_server:"http://x.mochiads.com/com/1/", method:"loadCommunicator", depth:10337, id:"_UNKNOWN_"};
options = MochiAd._parseOptions(options, _local25);
options.swfv = options.clip.getSWFVersion() || 6;
options.mav = "1.4";
var _local18 = options.clip;
var _local20 = "_mochiad_com_" + options.id;
if (!MochiAd._isNetworkAvailable()) {
return(null);
}
if (_local18[_local20]) {
return(_local18[_local20].lc);
}
var _local21 = options.com_server + options.id;
MochiAd._allowDomains(_local21);
delete options.id;
delete options.com_server;
var _local24 = options.depth;
delete options.depth;
var _local17 = _local18.createEmptyMovieClip(_local20, _local24);
var _local11 = _local17.createEmptyMovieClip("_mochiad_com", 1);
for (var _local15 in options) {
_local11[_local15] = options[_local15];
}
var _local6 = new LocalConnection();
var _local16 = ["", Math.floor(new Date().getTime()), random(999999)].join("_");
_local6.mc = _local17;
_local6.name = _local16;
_local6.allowDomain = function (d) {
return(true);
};
_local6.allowInsecureDomain = _local6.allowDomain;
_local6.connect(_local16);
_local17.lc = _local6;
_local11.lc = _local16;
_local6._id = 0;
_local6._queue = [];
_local6.rpcResult = function (cb) {
cb = parseInt(cb);
var _local4 = this._callbacks[cb];
if (!_local4) {
return(undefined);
}
delete this._callbacks[cb];
var _local5 = [];
var _local3 = 2;
while (_local3 < _local4.length) {
_local5.push(_local4[_local3]);
_local3++;
}
_local3 = 1;
while (_local3 < arguments.length) {
_local5.push(arguments[_local3]);
_local3++;
}
var _local6 = _local4[1];
var _local7 = _local4[0];
if (_local7 && (typeof(_local6) == "string")) {
_local6 = _local7[_local6];
}
if (_local6) {
_local6.apply(_local7, _local5);
}
};
_local6._didConnect = function (endpoint) {
this._endpoint = endpoint;
var _local4 = this._queue;
delete this._queue;
var _local5 = this.doSend;
var _local2 = 0;
while (_local2 < _local4.length) {
var _local3 = _local4[_local2];
_local5.apply(this, _local3);
_local2++;
}
};
_local6.doSend = function (args, cbobj, cbfn) {
if (this._endpoint == null) {
var _local4 = [];
var _local3 = 0;
while (_local3 < arguments.length) {
_local4.push(arguments[_local3]);
_local3++;
}
this._queue.push(_local4);
return(undefined);
}
this._id = this._id + 1;
var _local5 = this._id;
if ((cbfn === undefined) || (cbfn === null)) {
cbfn = cbobj;
}
this._callbacks[_local5] = [cbobj, cbfn];
var _local7 = new LocalConnection();
var _local9 = _local7.send(this._endpoint, "rpc", _local5, args);
};
_local6._callbacks = {};
_local6._callbacks[0] = [_local6, "_didConnect"];
_local11.st = getTimer();
_local11.loadMovie(_local21 + ".swf", "POST");
return(_local6);
}, fetchHighScores:function (options, callbackObj, callbackMethod) {
var _local1 = MochiAd._loadCommunicator({id:options.id});
if (!_local1) {
return(false);
}
var _local4 = ["fetchHighScores", options];
_local1.doSend(["fetchHighScores", options], callbackObj, callbackMethod);
return(true);
}, sendHighScore:function (options, callbackObj, callbackMethod) {
var _local1 = MochiAd._loadCommunicator({id:options.id});
if (!_local1) {
return(false);
}
var _local4 = ["sendHighScore", options];
_local1.doSend(["sendHighScore", options], callbackObj, callbackMethod);
return(true);
}, load:function (options) {
var _local13 = {clip:_root, server:"http://x.mochiads.com/srv/1/", method:"load", depth:10333, id:"_UNKNOWN_"};
options = MochiAd._parseOptions(options, _local13);
options.swfv = options.clip.getSWFVersion() || 6;
options.mav = "1.4";
var _local7 = options.clip;
if (!MochiAd._isNetworkAvailable()) {
return(null);
}
if (_local7._mochiad_loaded) {
return(null);
}
var _local12 = options.depth;
delete options.depth;
var _local6 = _local7.createEmptyMovieClip("_mochiad", _local12);
var _local11 = MochiAd._getRes(options);
options.res = (_local11[0] + "x") + _local11[1];
options.server = options.server + options.id;
delete options.id;
_local7._mochiad_loaded = true;
var _local4 = _local6.createEmptyMovieClip("_mochiad_ctr", 1);
for (var _local8 in options) {
_local4[_local8] = options[_local8];
}
if (_local7._url.indexOf("http") != 0) {
options.no_page = true;
}
var _local10 = _local4.server;
delete _local4.server;
var _local14 = MochiAd._allowDomains(_local10);
_local6.onEnterFrame = function () {
if (this._mochiad_ctr._url != this._url) {
this.onEnterFrame = function () {
if (!this._mochiad_ctr) {
delete this.onEnterFrame;
MochiAd.unload(this._parent);
}
};
}
};
var _local5 = new LocalConnection();
var _local9 = ["", Math.floor(new Date().getTime()), random(999999)].join("_");
_local5.mc = _local6;
_local5.name = _local9;
_local5.hostname = _local14;
_local5.allowDomain = function (d) {
return(true);
};
_local5.allowInsecureDomain = _local5.allowDomain;
_local5.connect(_local9);
_local6.lc = _local5;
_local4.lc = _local9;
_local4.st = getTimer();
_local4.loadMovie(_local10 + ".swf", "POST");
return(_local6);
}, unload:function (clip) {
if (typeof(clip) == "undefined") {
clip = _root;
}
if (clip.clip && (clip.clip._mochiad)) {
clip = clip.clip;
}
if (!clip._mochiad) {
return(false);
}
clip._mochiad.removeMovieClip();
delete clip._mochiad_loaded;
delete clip._mochiad;
return(true);
}, _isNetworkAvailable:function () {
if (System.security) {
var _local1 = System.security;
if (_local1.sandboxType == "localWithFile") {
return(false);
}
}
return(true);
}, _getRes:function (options) {
var _local3 = options.clip.getBounds();
var _local2 = 0;
var _local1 = 0;
if (typeof(options.res) != "undefined") {
var _local4 = options.res.split("x");
_local2 = parseFloat(_local4[0]);
_local1 = parseFloat(_local4[1]);
} else {
_local2 = _local3.xMax - _local3.xMin;
_local1 = _local3.yMax - _local3.yMin;
}
if ((_local2 == 0) || (_local1 == 0)) {
_local2 = Stage.width;
_local1 = Stage.height;
}
return([_local2, _local1]);
}, _parseOptions:function (options, defaults) {
var _local4 = {};
for (var _local8 in defaults) {
_local4[_local8] = defaults[_local8];
}
if (options) {
for (var _local8 in options) {
_local4[_local8] = options[_local8];
}
}
if (_root.mochiad_options) {
var _local5 = _root.mochiad_options.split("&");
var _local2 = 0;
while (_local2 < _local5.length) {
var _local3 = _local5[_local2].split("=");
_local4[unescape(_local3[0])] = unescape(_local3[1]);
_local2++;
}
}
return(_local4);
}, _:null};
MochiAd.showPreloaderAd({id:"3fa560ffcc89ebbe", res:"450x550"});
Frame 2
MusicOn = true;
SFXOn = true;
stop();
Frame 3
this.createEmptyMovieClip("SControl", this.getNextHighestDepth());
Music = new Sound(SControl);
Music.attachSound("MUSIC");
Frame 4
CurrLevel = 1;
Lives = 3;
Score = 0;
stop();
Frame 5
gotoAndStop ("Game");
Frame 6
stop();
Frame 7
gotoAndStop ("Game");
Frame 8
Music.stop();
if (GameMode == 1) {
SF.gotoAndStop(2);
} else {
SF.gotoAndStop(1);
}
Lives--;
if (Lives <= 0) {
gotoAndStop ("Game Over");
}
Frame 9
gotoAndStop ("Life Lost");
Frame 10
Music.stop();
if (CurrLevel == 6) {
gotoAndStop ("Pass Level 1");
}
if (CurrLevel == 12) {
gotoAndStop ("Pass Game");
Score = Score + (Lives * 1000);
Lives = 0;
}
SF.gotoAndStop(GameMode);
Frame 11
gotoAndStop ("Level Complete");
Frame 12
gotoAndStop ("Game Over");
Frame 13
Music.stop();
Ind = ScoreInd;
Par = Score;
StrRep = String(Par);
dg = 0;
while (dg <= 10) {
if (dg < StrRep.length) {
Ind["d" + dg]._visible = true;
if (StrRep.charAt(dg) == "-") {
Ind["d" + dg].gotoAndStop(11);
} else {
Ind["d" + dg].gotoAndStop(Number(StrRep.charAt(dg)) + 1);
}
} else {
Ind["d" + dg]._visible = false;
}
dg++;
}
Ind._x = 225 - (StrRep.length * 5);
Frame 14
gotoAndStop ("Game Over");
Frame 15
gotoAndStop ("Pass Level 1");
Frame 17
gotoAndStop ("Pass Level 1");
Frame 18
gotoAndStop ("Pass Game");
Frame 19
Ind = ScoreInd;
Par = Score;
StrRep = String(Par);
dg = 0;
while (dg <= 10) {
if (dg < StrRep.length) {
Ind["d" + dg]._visible = true;
if (StrRep.charAt(dg) == "-") {
Ind["d" + dg].gotoAndStop(11);
} else {
Ind["d" + dg].gotoAndStop(Number(StrRep.charAt(dg)) + 1);
}
} else {
Ind["d" + dg]._visible = false;
}
dg++;
}
Ind._x = 225 - (StrRep.length * 5);
Frame 20
gotoAndStop ("Pass Game");
Frame 21
gotoAndStop ("Instructions");
Frame 23
gotoAndStop ("Instructions");
Frame 24
gotoAndStop ("Submit Score");
Frame 26
gotoAndStop ("Submit Score");
Symbol 11 Button
on (press) {
getURL ("http://www.sugar-free-games.com", "_SELF");
}
Symbol 20 MovieClip Frame 100
_parent.gotoAndStop("AntiGames");
Symbol 31 Button
on (release) {
gotoAndStop ("Main Menu");
}
Symbol 34 Button
on (release) {
getURL ("http://www.sugar-free-games.com/antigames.php", "_blank");
}
Symbol 35 Button
on (release) {
getURL ("http://www.sugar-free-games.com", "_blank");
}
Symbol 39 Button
on (release) {
gotoAndStop ("Game");
}
Symbol 40 Button
on (release) {
gotoAndStop ("Instructions");
}
Symbol 41 Button
on (release) {
getURL ("http://www.sugar-free-games.com/antigames.php", "_blank");
}
Symbol 45 Button
on (press) {
getURL ("http://www.sugar-free-games.com", "_blank");
}
Symbol 182 MovieClip Frame 1
function ReverseXY(Arr) {
TA = new Array();
ya = 0;
while (ya < Arr[Arr.length - 1].length) {
TA[ya] = new Array();
ya++;
}
xa = 0;
while (xa < Arr.length) {
ya = 0;
while (ya <= Arr[xa].length) {
TA[ya][xa] = Arr[xa][ya];
ya++;
}
xa++;
}
return(TA);
}
function DrawLevel() {
dx = 0;
while (dx < Level.length) {
dy = 0;
while (dy < Level[dx].length) {
if ((Level[dx][dy] == 1) or (Level[dx][dy] == 3)) {
duplicateMovieClip (SquareSample, (("S" + dx) + "x") + dy, this.getNextHighestDepth());
this[(("S" + dx) + "x") + dy]._visible = true;
this[(("S" + dx) + "x") + dy]._x = 5 + (dx * 15);
this[(("S" + dx) + "x") + dy]._y = 5 + (dy * 15);
this[(("S" + dx) + "x") + dy].gotoAndStop(Level[dx][dy] + 1);
}
dy++;
}
dx++;
}
}
function RandomDirection(Char) {
StartDir = random(4) + 1;
adr = 0;
while (adr <= 3) {
CheckDir = StartDir + adr;
if (CheckDir > 4) {
CheckDir = CheckDir - 4;
}
if (Level[Char.SquareX + DirsX[CheckDir]][Char.SquareY + DirsY[CheckDir]] != 2) {
Char.Dir = CheckDir;
break;
}
adr++;
}
}
function FillMatrix(X, Y) {
var _local2;
var _local1;
BusyArr = new Array();
DirsPref = new Array();
fd = 1;
while (fd <= 4) {
DirsPref[fd] = {};
fd++;
}
_local2 = 0;
while (_local2 < Level.length) {
BusyArr[_local2] = [];
_local2++;
}
MaxLevels = 10;
FreeSquares = new Array();
FreeSquares.push({x:X, y:Y, Level:0, OD:0});
while (FreeSquares.length > 0) {
CurrSquare = FreeSquares.shift();
if ((CurrSquare.x == 29) and (CurrSquare.y == 15)) {
CurrSquare.x = 0;
} else if ((CurrSquare.x == 0) and (CurrSquare.y == 15)) {
CurrSquare.x = 29;
}
BusyArr[CurrSquare.x][CurrSquare.y] = (CurrSquare.Level + "-") + CurrSquare.OD;
switch (Level[CurrSquare.x][CurrSquare.y]) {
case 1 :
if (DirsPref[CurrSquare.OD].Dot == undefined) {
DirsPref[CurrSquare.OD].Dot = CurrSquare.Level;
}
break;
case 3 :
if (DirsPref[CurrSquare.OD].Blue != undefined) {
break;
}
DirsPref[CurrSquare.OD].Blue = CurrSquare.Level;
}
fg = 1;
while (fg <= GhostsNum) {
if ((((DirsPref[CurrSquare.OD].Ghost == undefined) and (Characters[fg].SquareX == CurrSquare.x)) and (Characters[fg].SquareY == CurrSquare.y)) and (!Characters[fg].Dead)) {
DirsPref[CurrSquare.OD].Ghost = CurrSquare.Level;
if (fg == UnderControl) {
DirsPref[CurrSquare.OD].GhostUnderControl = true;
} else {
DirsPref[CurrSquare.OD].GhostUnderControl = false;
}
}
fg++;
}
if (CurrSquare.Level < MaxLevels) {
_local1 = 1;
while (_local1 <= 4) {
NextSquareX = CurrSquare.x + DirsX[_local1];
NextSquareY = CurrSquare.y + DirsY[_local1];
if (((((((NextSquareX >= 0) and (NextSquareX < Level.length)) and (NextSquareY >= 0)) and (NextSquareY < Level[0].length)) and (Level[CurrSquare.x + DirsX[_local1]][CurrSquare.y + DirsY[_local1]] != 2)) and (Level[CurrSquare.x + DirsX[_local1]][CurrSquare.y + DirsY[_local1]] != 4)) and (BusyArr[NextSquareX][NextSquareY] == undefined)) {
if (CurrSquare.Level == 0) {
OD = _local1;
} else {
OD = CurrSquare.OD;
}
FreeSquares.push({x:NextSquareX, y:NextSquareY, Level:CurrSquare.Level + 1, OD:OD});
}
_local1++;
}
}
}
var _local6;
_local6 = Characters[0].CameFrom + 2;
if (_local6 > 4) {
_local6 = _local6 - 4;
}
pd = 1;
while (pd <= 4) {
if (((DirsPref[pd].Dot == undefined) and (DirsPref[pd].Ghost == undefined)) and (DirsPref[pd].Blue == undefined)) {
DirsPref[pd].Zero = true;
} else {
DirsPref[pd].Zero = false;
}
if (DirsPref[pd].Dot == undefined) {
DirsPref[pd].Dot = MaxLevels;
}
if (DirsPref[pd].Ghost == undefined) {
DirsPref[pd].Ghost = MaxLevels;
}
if (DirsPref[pd].Blue == undefined) {
DirsPref[pd].Blue = MaxLevels;
}
if (DirsPref[pd].GhostUnderControl) {
Mult = 2;
} else {
Mult = 1;
}
if (pd == _local6) {
Red = 10;
} else {
Red = 0;
}
if (!GhostsBlue) {
DirsPref[pd].Score = (((MaxLevels - DirsPref[pd].Dot) - (((MaxLevels - DirsPref[pd].Ghost) * 20) * Mult)) + ((MaxLevels - DirsPref[pd].Blue) * 10)) - Red;
} else {
DirsPref[pd].Score = (((MaxLevels - DirsPref[pd].Dot) + (((MaxLevels - DirsPref[pd].Ghost) * 20) / Mult)) - ((MaxLevels - DirsPref[pd].Blue) * 10)) - Red;
}
pd++;
}
}
function FillGhostMatrix(ind, X, Y) {
var _local2;
var _local1;
BusyArr = new Array();
DirsPref = new Array();
fd = 1;
while (fd <= 4) {
DirsPref[fd] = {};
fd++;
}
_local2 = 0;
while (_local2 < Level.length) {
BusyArr[_local2] = [];
_local2++;
}
MaxLevels = 10;
FreeSquares = new Array();
FreeSquares.push({x:X, y:Y, Level:0, OD:0});
while (FreeSquares.length > 0) {
CurrSquare = FreeSquares.shift();
if ((CurrSquare.x == 29) and (CurrSquare.y == 15)) {
CurrSquare.x = 0;
} else if ((CurrSquare.x == 0) and (CurrSquare.y == 15)) {
CurrSquare.x = 29;
}
BusyArr[CurrSquare.x][CurrSquare.y] = (CurrSquare.Level + "-") + CurrSquare.OD;
if ((((DirsPref[CurrSquare.OD].Ghost == undefined) and (Characters[0].SquareX == CurrSquare.x)) and (Characters[0].SquareY == CurrSquare.y)) and (!Characters[0].Dead)) {
DirsPref[CurrSquare.OD].Score = CurrSquare.Level * 10;
}
if (CurrSquare.Level < MaxLevels) {
_local1 = 1;
while (_local1 <= 4) {
NextSquareX = CurrSquare.x + DirsX[_local1];
NextSquareY = CurrSquare.y + DirsY[_local1];
if ((((((NextSquareX >= 0) and (NextSquareX < Level.length)) and (NextSquareY >= 0)) and (NextSquareY < Level[0].length)) and (Level[CurrSquare.x + DirsX[_local1]][CurrSquare.y + DirsY[_local1]] != 2)) and (BusyArr[NextSquareX][NextSquareY] == undefined)) {
if (CurrSquare.Level == 0) {
OD = _local1;
} else {
OD = CurrSquare.OD;
}
FreeSquares.push({x:NextSquareX, y:NextSquareY, Level:CurrSquare.Level + 1, OD:OD});
}
_local1++;
}
}
}
var _local6;
_local6 = Characters[ind].CameFrom + 2;
if (_local6 > 4) {
_local6 = _local6 - 4;
}
pd = 1;
while (pd <= 4) {
if (DirsPref[pd].Score == undefined) {
DirsPref[pd].Score = 0;
DirsPref[pd].Zero = true;
} else {
DirsPref[pd].Zero = false;
DirsPref[pd].Score = ((MaxLevels + 1) * 10) - DirsPref[pd].Score;
}
if (GhostsBlue) {
DirsPref[pd].Score = -DirsPref[pd].Score;
}
if (pd == _local6) {
DirsPref[pd].Score = DirsPref[pd].Score - 10;
}
pd++;
}
}
function FindDir(ind, FromX, FromY, ToX, ToY) {
var _local2 = new Array();
if (Math.abs(FromX - ToX) > Math.abs(FromY - ToY)) {
if (ToX > FromX) {
_local2.push(2);
} else {
_local2.push(4);
}
} else if (ToY > FromY) {
_local2.push(3);
} else {
_local2.push(1);
}
if (Math.abs(FromX - ToX) > Math.abs(FromY - ToY)) {
if (ToY > FromY) {
_local2.push(3);
} else {
_local2.push(1);
}
} else if (ToX > FromX) {
_local2.push(2);
} else {
_local2.push(4);
}
if (Math.abs(FromX - ToX) > Math.abs(FromY - ToY)) {
if (ToY > FromY) {
_local2.push(1);
} else {
_local2.push(3);
}
} else if (ToX > FromX) {
_local2.push(4);
} else {
_local2.push(2);
}
if (Math.abs(FromX - ToX) > Math.abs(FromY - ToY)) {
if (ToX > FromX) {
_local2.push(4);
} else {
_local2.push(2);
}
} else if (ToY > FromY) {
_local2.push(1);
} else {
_local2.push(3);
}
var _local1;
var _local5;
_local5 = Characters[ind].CameFrom + 2;
if (_local5 > 4) {
_local5 = _local5 - 4;
}
_local1 = 0;
while (_local1 <= 3) {
if (((_local2[_local1] != _local5) and (Level[FromX + DirsX[_local2[_local1]]][FromY + DirsY[_local2[_local1]]] != 2)) and ((ind != 0) or (Level[FromX + DirsX[_local2[_local1]]][FromY + DirsY[_local2[_local1]]] != 4))) {
return(_local2[_local1]);
}
_local1++;
}
}
function TurnGhostsBlue() {
fd = 1;
while (fd <= GhostsNum) {
Characters[fd].Fading = true;
Characters[fd].FadeDir = 1;
if (!GhostsBlue) {
Characters[fd].FadeCounter = 0;
}
fd++;
}
GhostsBlue = true;
BlueCounter = 0;
}
function UpdateIndicator(Ind, Par) {
StrRep = String(Par);
dg = 0;
while (dg <= 10) {
if (dg < StrRep.length) {
Ind["d" + dg]._visible = true;
if (StrRep.charAt(dg) == "-") {
Ind["d" + dg].gotoAndStop(11);
} else {
Ind["d" + dg].gotoAndStop(Number(StrRep.charAt(dg)) + 1);
}
} else {
Ind["d" + dg]._visible = false;
}
dg++;
}
if (Ind != LivesInd) {
Ind._x = 380 - (StrRep.length * 10);
}
}
function AddLevelScore() {
_parent.Score = _parent.Score + (800 + (_parent.CurrLevel * 200));
}
Level = [[2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2], [2, 2, 1, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 1, 2, 2, 1, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 1, 2, 2], [2, 2, 3, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 1, 2, 2, 1, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 3, 2, 2], [2, 2, 1, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 1, 2, 2, 1, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 1, 2, 2], [2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2], [2, 2, 1, 2, 2, 2, 2, 1, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 1, 2, 2, 2, 2, 1, 2, 2], [2, 2, 1, 2, 2, 2, 2, 1, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 1, 2, 2, 2, 2, 1, 2, 2], [2, 2, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 1, 2, 2, 1, 1, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 2, 2], [2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 0, 2, 2, 0, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 0, 2, 2, 0, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 0, 2, 2, 2, 4, 4, 2, 2, 2, 0, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 0, 2, 2, 2, 4, 4, 2, 2, 2, 0, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2], [0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 2, 2, 0, 0, 0, 0, 2, 2, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0], [2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2], [2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2], [2, 2, 1, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 1, 2, 2, 1, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 1, 2, 2], [2, 2, 1, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 1, 2, 2, 1, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 1, 2, 2], [2, 2, 3, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 3, 2, 2], [2, 2, 2, 2, 1, 2, 2, 1, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 1, 2, 2, 1, 2, 2, 2, 2], [2, 2, 2, 2, 1, 2, 2, 1, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 1, 2, 2, 1, 2, 2, 2, 2], [2, 2, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 1, 2, 2, 1, 1, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 2, 2], [2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2], [2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2], [2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]];
DirsX = [0, 0, 1, 0, -1];
DirsY = [0, -1, 0, 1, 0];
EatDot = new Sound(this);
EatDot.attachSound("EATDOT");
BigDot = new Sound(this);
BigDot.attachSound("BIGDOT");
PacmanDie = new Sound(this);
PacmanDie.attachSound("PACMANDIE");
GhostDie = new Sound(this);
GhostDie.attachSound("GHOSTDIE");
EatBonus = new Sound(this);
EatBonus.attachSound("EATBONUS");
if (_parent.MusicOn) {
_parent.Music.start(0, 1000000000);
}
Paused = false;
Characters = new Array();
switch (_parent.CurrLevel) {
case 1 :
GhostsNum = 4;
MoveSpeed = 3;
Mode = 1;
break;
case 2 :
GhostsNum = 3;
MoveSpeed = 3;
Mode = 1;
break;
case 3 :
GhostsNum = 2;
MoveSpeed = 3;
Mode = 1;
break;
case 4 :
GhostsNum = 4;
MoveSpeed = 5;
Mode = 1;
break;
case 5 :
GhostsNum = 3;
MoveSpeed = 5;
Mode = 1;
break;
case 6 :
GhostsNum = 2;
MoveSpeed = 5;
Mode = 1;
break;
case 7 :
GhostsNum = 2;
MoveSpeed = 3;
Mode = 2;
break;
case 8 :
GhostsNum = 3;
MoveSpeed = 3;
Mode = 2;
break;
case 9 :
GhostsNum = 4;
MoveSpeed = 3;
Mode = 2;
break;
case 10 :
GhostsNum = 2;
MoveSpeed = 5;
Mode = 2;
break;
case 11 :
GhostsNum = 3;
MoveSpeed = 5;
Mode = 2;
break;
case 12 :
GhostsNum = 4;
MoveSpeed = 5;
Mode = 2;
}
LivesInd.Sign.gotoAndStop(Mode);
_parent.GameMode = Mode;
if (Mode == 1) {
BlueTime = 200 + (_parent.CurrLevel * (60 / MoveSpeed));
} else {
BlueTime = 200 - ((_parent.CurrLevel * 2) * MoveSpeed);
}
if (Mode == 1) {
LevelRep = 7 - _parent.CurrLevel;
} else {
LevelRep = _parent.CurrLevel - 6;
}
BonusOut = false;
BonusCounter = 0;
AnyGhostsAlive = true;
if (Mode == 2) {
UnderControl = 0;
} else {
UnderControl = 1;
}
init = 0;
while (init <= GhostsNum) {
Characters[init] = new Object();
Characters[init].UnderControl = false;
if (init == 0) {
Characters[init].x = 225;
Characters[init].y = 360;
Characters[init].SquareX = 15;
Characters[init].SquareY = 24;
if (Mode == 2) {
Characters[init].Dir = 0;
} else {
Characters[init].Dir = 2;
}
} else {
Characters[init].x = (12 + init) * 15;
Characters[init].y = 225;
Characters[init].SquareX = 12 + init;
Characters[init].SquareY = 15;
Characters[init].Dir = 2;
}
switch (init) {
case 1 :
Characters[init].R = 100;
Characters[init].G = 0;
Characters[init].B = 0;
break;
case 2 :
Characters[init].R = 120;
Characters[init].G = 90;
Characters[init].B = 95;
break;
case 3 :
Characters[init].R = 0;
Characters[init].G = 100;
Characters[init].B = 100;
break;
case 4 :
Characters[init].R = 120;
Characters[init].G = 90;
Characters[init].B = 0;
}
init++;
}
GhostsBlue = false;
EatenDots = 0;
Level = ReverseXY(Level);
DrawLevel();
SquareSample._visible = false;
PacmanSample._visible = false;
GhostSample._visible = false;
duplicateMovieClip (PacmanSample, "Pacman", this.getNextHighestDepth());
duplicateMovieClip (PacmanSample, "PacmanCopy", this.getNextHighestDepth());
g = 1;
while (g <= GhostsNum) {
duplicateMovieClip (GhostSample, "G" + g, this.getNextHighestDepth());
duplicateMovieClip (GhostSample, ("G" + g) + "Copy", this.getNextHighestDepth());
Characters[g].Symbol = this["G" + g];
Characters[g].Copy = this[("G" + g) + "Copy"];
Characters[g].Symbol.Num.gotoAndStop(g);
Characters[g].BCol = new Color(this["G" + g].Body);
Characters[g].BCol.setTransform({ra:Characters[g].R, rb:0, ga:Characters[g].G, gb:0, ba:Characters[g].B, bb:0, aa:100, ab:0});
Characters[g].NCol = new Color(this["G" + g].Num);
Characters[g].CBCol = new Color(this[("G" + g) + "Copy"].Body);
Characters[g].CBCol.setTransform({ra:Characters[g].R, rb:0, ga:Characters[g].G, gb:0, ba:Characters[g].B, bb:0, aa:100, ab:0});
Characters[g].CNCol = new Color(this[("G" + g) + "Copy"].Num);
g++;
}
Characters[0].Symbol = Pacman;
Characters[0].Copy = PacmanCopy;
if (Mode == 2) {
Characters[0].Symbol.gotoAndStop(4);
Characters[0].Symbol.Inside.gotoAndStop(3);
Characters[0].Symbol.Eye.gotoAndStop(3);
}
TP._visible = true;
TP.swapDepths(this.getNextHighestDepth());
init = 1;
while (init <= 4) {
if (init <= GhostsNum) {
this["GI" + init]._visible = true;
this["GI" + init].BCol = new Color(this["GI" + init].Body);
this["GI" + init].BCol.setTransform({ra:Characters[init].R, rb:0, ga:Characters[init].G, gb:0, ba:Characters[init].B, bb:0, aa:100, ab:0});
this["GI" + init].NCol = new Color(this["GI" + init].Num);
this["GI" + init].NCol.setTransform({ra:Characters[init].R, rb:0, ga:Characters[init].G, gb:0, ba:Characters[init].B, bb:0, aa:100, ab:0});
this["GI" + init].Num.gotoAndStop(init);
} else {
this["GI" + init]._visible = false;
}
init++;
}
PauseScreenSample.duplicateMovieClip("PauseScreen", this.getNextHighestDepth());
PauseScreenSample._visible = false;
PauseScreen.gotoAndStop(1);
Symbol 182 MovieClip Frame 2
if (Key.isDown(77)) {
if (!MPressed) {
_parent.MusicOn = !_parent.MusicOn;
if (_parent.MusicOn) {
_parent.Music.start(0, 1000000000);
} else {
_parent.Music.stop();
}
}
MPressed = true;
} else {
MPressed = false;
}
if (Key.isDown(83)) {
if (!SPressed) {
_parent.SFXOn = !_parent.SFXOn;
if (_parent.SFXOn) {
EatDot.setVolume(100);
} else {
EatDot.setVolume(0);
}
}
SPressed = true;
} else {
SPressed = false;
}
if (Key.isDown(80)) {
if (!PPressed) {
Paused = !Paused;
}
PPressed = true;
PauseScreen.gotoAndStop(1);
} else {
PPressed = false;
}
if (Paused) {
PauseScreen.RL._visible = _parent.Lives > 1;
PauseScreen._visible = true;
if (PauseScreen._currentframe == 1) {
if (Key.isDown(69)) {
if (!EPressed) {
PauseScreen.gotoAndStop(2);
}
EPressed = true;
} else {
EPressed = false;
}
if ((_parent.Lives > 1) and Key.isDown(82)) {
if (!RPressed) {
PauseScreen.gotoAndStop(3);
}
RPressed = true;
} else {
RPressed = false;
}
}
if (PauseScreen._currentframe == 2) {
if (Key.isDown(89)) {
if (!YPressed) {
_parent.gotoAndStop("Game Over");
}
YPressed = true;
} else {
YPressed = false;
}
if (Key.isDown(78)) {
if (!NPressed) {
PauseScreen.gotoAndStop(1);
}
NPressed = true;
} else {
NPressed = false;
}
}
if (PauseScreen._currentframe == 3) {
if (Key.isDown(89)) {
if (!YPressed) {
_parent.gotoAndStop("Life Lost");
}
YPressed = true;
} else {
YPressed = false;
}
if (Key.isDown(78)) {
if (!NPressed) {
PauseScreen.gotoAndStop(1);
}
NPressed = true;
} else {
NPressed = false;
}
}
} else {
PauseScreen._visible = false;
if (Mode == 1) {
if ((Key.isDown(49) and (GhostsNum >= 1)) and (!Characters[1].Dead)) {
UnderControl = 1;
}
if ((Key.isDown(50) and (GhostsNum >= 2)) and (!Characters[2].Dead)) {
UnderControl = 2;
}
if ((Key.isDown(51) and (GhostsNum >= 3)) and (!Characters[3].Dead)) {
UnderControl = 3;
}
if ((Key.isDown(52) and (GhostsNum >= 4)) and (!Characters[4].Dead)) {
UnderControl = 4;
}
}
if (Key.isDown(37)) {
Characters[UnderControl].PendingDir = 4;
}
if (Key.isDown(39)) {
Characters[UnderControl].PendingDir = 2;
}
if (Key.isDown(38)) {
Characters[UnderControl].PendingDir = 1;
}
if (Key.isDown(40)) {
Characters[UnderControl].PendingDir = 3;
}
for (cr in Characters) {
if (Characters[cr].Dir != 0) {
Characters[cr].CameFrom = Characters[cr].Dir;
}
if ((cr == 0) and (Mode == 1)) {
FillMatrix(Characters[0].AppSquareX, Characters[0].AppSquareY);
MaxPref = Number.NEGATIVE_INFINITY;
SelDir = 0;
AllZero = true;
sd = 1;
while (sd <= 4) {
if (!DirsPref[sd].Zero) {
AllZero = false;
break;
}
sd++;
}
if (!AllZero) {
sd = 1;
while (sd <= 4) {
if (((Level[Characters[0].AppSquareX + DirsX[sd]][Characters[0].AppSquareY + DirsY[sd]] != 2) and (Level[Characters[0].AppSquareX + DirsX[sd]][Characters[0].AppSquareY + DirsY[sd]] != 4)) and (DirsPref[sd].Score > MaxPref)) {
MaxPref = DirsPref[sd].Score;
SelDir = sd;
}
sd++;
}
Characters[0].PendingDir = SelDir;
} else {
ClosestOne = Infinity;
ClosestX = Number.NaN;
ClosestY = Number.NaN;
xx = 2;
while (xx < (Level.length - 2)) {
yy = 2;
while (yy < (Level[xx].length - 2)) {
Dist = Math.abs(xx - Characters[0].SquareX) + Math.abs(yy - Characters[0].SquareY);
if ((Level[xx][yy] == 1) and (Dist < ClosestOne)) {
ClosestOne = Dist;
ClosestX = xx;
ClosestY = yy;
}
yy++;
}
xx++;
}
Characters[0].PendingDir = FindDir(cr, Characters[0].AppSquareX, Characters[0].AppSquareY, ClosestX, ClosestY);
}
}
if ((cr > 0) and (Mode == 2)) {
if (((((Characters[cr].SquareX > 12) and (Characters[cr].SquareX < 17)) and (Characters[cr].SquareY > 12)) and (Characters[cr].SquareY < 16)) and (!GhostsBlue)) {
Characters[cr].PendingDir = FindDir(cr, Characters[cr].SquareX, Characters[cr].SquareY, 15, 0);
}
FillGhostMatrix(cr, Characters[cr].AppSquareX, Characters[cr].AppSquareY);
MaxPref = Number.NEGATIVE_INFINITY;
SelDir = 0;
AllZero = true;
sd = 1;
while (sd <= 4) {
if (!DirsPref[sd].Zero) {
AllZero = false;
break;
}
sd++;
}
if (!AllZero) {
sd = 1;
while (sd <= 4) {
if ((Level[Characters[cr].AppSquareX + DirsX[sd]][Characters[cr].AppSquareY + DirsY[sd]] != 2) and (DirsPref[sd].Score > MaxPref)) {
MaxPref = DirsPref[sd].Score;
if (!DirsPref[sd].Zero) {
AllZero = false;
}
SelDir = sd;
}
sd++;
}
Characters[cr].PendingDir = SelDir;
} else if ((Characters[cr].Dir == 0) or (random(25) == 0)) {
RandomDirection(Character[cr]);
}
}
if ((((Mode == 1) and (cr > 0)) and (cr != UnderControl)) and (Characters[cr].Dir == 0)) {
RandomDirection(Characters[cr]);
Characters[cr].PendingDir = 0;
}
if ((cr != 0) and (cr == UnderControl)) {
Characters[cr].Symbol.Glow._visible = true;
sd = 1;
while (sd <= GhostsNum) {
if (Characters[cr].Symbol.getDepth() < Characters[sd].Symbol.getDepth()) {
Characters[cr].Symbol.swapDepths(Characters[sd].Symbol);
}
sd++;
}
}
if ((cr != 0) and (cr != UnderControl)) {
Characters[cr].Symbol.Glow._visible = false;
}
if ((((cr > 0) and (Mode == 1)) and (cr != UnderControl)) and (random(25) == 0)) {
Characters[cr].PendingDir = random(4) + 1;
}
Characters[cr].MoveX = DirsX[Characters[cr].Dir];
Characters[cr].MoveY = DirsY[Characters[cr].Dir];
Characters[cr].NewX = Characters[cr].x + (Characters[cr].MoveX * MoveSpeed);
Characters[cr].NewY = Characters[cr].y + (Characters[cr].MoveY * MoveSpeed);
Characters[cr].AppSquareX = Math.round(Characters[cr].NewX / 15);
Characters[cr].AppSquareY = Math.round(Characters[cr].NewY / 15);
if ((Characters[cr].NewX == (Characters[cr].AppSquareX * 15)) and (Characters[cr].NewY == (Characters[cr].AppSquareY * 15))) {
Characters[cr].SquareX = Characters[cr].AppSquareX;
Characters[cr].SquareY = Characters[cr].AppSquareY;
if ((Level[Characters[cr].SquareX + Characters[cr].MoveX][Characters[cr].SquareY + Characters[cr].MoveY] == 2) or ((cr == 0) and (Level[Characters[cr].SquareX + Characters[cr].MoveX][Characters[cr].SquareY + Characters[cr].MoveY] == 4))) {
if ((cr != UnderControl) and (cr != 0)) {
RandomDirection(Characters[cr]);
} else {
Characters[cr].Dir = 0;
if (cr == 0) {
Characters[cr].Symbol.Inside.gotoAndStop(3);
Characters[cr].Symbol.Eye.gotoAndStop(3);
}
}
}
if (((Characters[cr].PendingDir > 0) and (Level[Characters[cr].SquareX + DirsX[Characters[cr].PendingDir]][Characters[cr].SquareY + DirsY[Characters[cr].PendingDir]] != 2)) and ((cr != 0) or (Level[Characters[cr].SquareX + DirsX[Characters[cr].PendingDir]][Characters[cr].SquareY + DirsY[Characters[cr].PendingDir]] != 4))) {
Characters[cr].Dir = Characters[cr].PendingDir;
Characters[cr].PendingDir = 0;
}
}
if ((cr == 0) and (Characters[cr].Dir != 0)) {
Characters[cr].Symbol.Inside.play();
Characters[cr].Symbol.Eye.play();
}
if ((cr == 0) and ((Level[Characters[cr].SquareX][Characters[cr].SquareY] == 1) or (Level[Characters[cr].SquareX][Characters[cr].SquareY] == 3))) {
this[(("S" + Characters[cr].SquareX) + "x") + Characters[cr].SquareY]._visible = false;
if (Level[Characters[cr].SquareX][Characters[cr].SquareY] == 3) {
if (_parent.SFXOn) {
BigDot.start();
}
TurnGhostsBlue();
if (Mode == 1) {
_parent.Score = _parent.Score - 20;
} else {
_parent.Score = _parent.Score + 20;
}
}
if (Level[Characters[cr].SquareX][Characters[cr].SquareY] == 1) {
if (_parent.SFXOn) {
EatDot.start();
}
EatenDots++;
if (Mode == 1) {
_parent.Score--;
} else {
_parent.Score++;
}
if (EatenDots == 241) {
if (Mode == 1) {
_parent.gotoAndStop("Life Lost");
} else {
AddLevelScore();
_parent.gotoAndStop("Level Complete");
}
}
}
Level[Characters[cr].SquareX][Characters[cr].SquareY] = 0;
}
if (Characters[cr].Fading) {
Characters[cr].FadeCounter = Characters[cr].FadeCounter + Characters[cr].FadeDir;
if (Characters[cr].FadeCounter > 10) {
Characters[cr].FadeCounter = 10;
}
if (Characters[cr].FadeCounter < 0) {
Characters[cr].FadeCounter = 0;
}
Characters[cr].BCol.setTransform({ra:Characters[cr].R * (1 - (Characters[cr].FadeCounter / 10)), rb:0, ga:Characters[cr].G * (1 - (Characters[cr].FadeCounter / 10)), gb:0, ba:Characters[cr].B * (1 - (Characters[cr].FadeCounter / 10)), bb:Characters[cr].FadeCounter * 20, aa:100 - (Characters[cr].FadeCounter * 5), ab:0});
Characters[cr].NCol.setTransform({ra:Characters[cr].FadeCounter * 10, rb:0, ga:Characters[cr].FadeCounter * 10, gb:0, ba:Characters[cr].FadeCounter * 10, bb:0, aa:100, ab:0});
if ((Characters[cr].FadeCounter == 10) or (Characters[cr].FadeCounter == 0)) {
Characters[cr].Fading = false;
if (Characters[cr].FadeCounter == 0) {
GhostsBlue = false;
}
}
}
if (cr != 0) {
switch (Characters[cr].Dir) {
case 1 :
Characters[cr].Symbol.Num._x = 0;
Characters[cr].Symbol.Num._y = 5.5;
Characters[cr].Symbol.Num._xscale = 75;
Characters[cr].Symbol.Num._yscale = 75;
break;
case 2 :
Characters[cr].Symbol.Num._x = 5;
Characters[cr].Symbol.Num._y = 6.5;
Characters[cr].Symbol.Num._xscale = 50;
Characters[cr].Symbol.Num._yscale = 75;
break;
case 3 :
Characters[cr].Symbol.Num._x = 0;
Characters[cr].Symbol.Num._y = 7.5;
Characters[cr].Symbol.Num._xscale = 75;
Characters[cr].Symbol.Num._yscale = 60;
break;
case 4 :
Characters[cr].Symbol.Num._x = -5;
Characters[cr].Symbol.Num._y = 6.5;
Characters[cr].Symbol.Num._xscale = 50;
Characters[cr].Symbol.Num._yscale = 75;
}
}
if (!Characters[cr].Dead) {
Characters[cr].x = Characters[cr].NewX;
Characters[cr].y = Characters[cr].NewY;
Characters[cr].Symbol._x = Characters[cr].x + 5;
Characters[cr].Symbol._y = Characters[cr].y + 5;
Characters[cr].Symbol.gotoAndStop(Characters[cr].Dir);
}
if (((Characters[cr].SquareX == 0) and (Characters[cr].SquareY == 15)) and (Characters[cr].Dir == 4)) {
Characters[cr].HasCopy = true;
Characters[cr].x = Characters[cr].x + 435;
Characters[cr].Symbol._x = Characters[cr].x + 5;
Characters[cr].SquareX = Characters[cr].SquareX + 29;
Characters[cr].CopyShift = -435;
}
if (((Characters[cr].SquareX == 29) and (Characters[cr].SquareY == 15)) and (Characters[cr].Dir == 2)) {
Characters[cr].HasCopy = true;
Characters[cr].x = Characters[cr].x - 435;
Characters[cr].Symbol._x = Characters[cr].x + 5;
Characters[cr].SquareX = Characters[cr].SquareX - 29;
Characters[cr].CopyShift = 435;
}
if (Characters[cr].HasCopy) {
Characters[cr].Copy._visible = true;
Characters[cr].Copy._x = Characters[cr].Symbol._x + Characters[cr].CopyShift;
Characters[cr].Copy._y = Characters[cr].Symbol._y;
Characters[cr]._alpha = Characters[cr].Symbol._alpha;
Characters[cr].Copy.gotoAndStop(Characters[cr].Symbol._currentframe);
if (cr == 0) {
Characters[cr].Copy.Inside.gotoAndStop(Characters[cr].Symbol.Inside._currentframe);
Characters[cr].Copy.Eye.gotoAndStop(Characters[cr].Symbol.Eye._currentframe);
} else {
Characters[cr].Copy.Num.gotoAndStop(Characters[cr].Symbol.Num._currentframe);
Characters[cr].Copy.Num._x = Characters[cr].Symbol.Num._x;
Characters[cr].Copy.Num._y = Characters[cr].Symbol.Num._y;
Characters[cr].Copy.Num._xscale = Characters[cr].Symbol.Num._xscale;
Characters[cr].Copy.Num._yscale = Characters[cr].Symbol.Num._yscale;
Characters[cr].Copy.Glow._visible = Characters[cr].Symbol.Glow._visible;
Characters[cr].CBCol.setTransform(Characters[cr].BCol.getTransform());
Characters[cr].CNCol.setTransform(Characters[cr].NCol.getTransform());
Characters[cr].Copy.swapDepths(Characters[cr].Symbol.getDepth() + 1);
}
} else {
Characters[cr].Copy._visible = false;
}
if ((((cr != 0) and (!Characters[cr].Dead)) and (!Characters[0].Dead)) and ((Math.abs(Characters[cr].x - Characters[0].x) + Math.abs(Characters[cr].y - Characters[0].y)) <= 20)) {
if (GhostsBlue) {
if (_parent.SFXOn) {
GhostDie.start();
}
Characters[cr].Dead = true;
Characters[cr].Die = true;
Characters[cr].DieCounter = 0;
if (cr == UnderControl) {
UnderControl = undefined;
}
this["GI" + cr].BCol.setTransform({ra:100, rb:0, ga:100, gb:0, ba:100, bb:0, aa:100, ab:0});
this["GI" + cr].NCol.setTransform({ra:100, rb:0, ga:100, gb:0, ba:100, bb:0, aa:100, ab:0});
if (Mode == 1) {
_parent.Score = _parent.Score - 100;
} else {
_parent.Score = _parent.Score + 100;
}
} else {
if (_parent.SFXOn) {
PacmanDie.start();
}
Characters[0].Dead = true;
Characters[0].Die = true;
Characters[0].DieCounter = 0;
}
}
if (Characters[cr].Die) {
Characters[cr].DieCounter++;
Characters[cr].Symbol._alpha = 100 - (Characters[cr].DieCounter * 10);
if (Characters[cr].DieCounter == 10) {
Characters[cr].Die = false;
Characters[cr]._visible = false;
if (cr > 0) {
AllDead = true;
tg = 1;
while (tg <= GhostsNum) {
if (!Characters[tg].Dead) {
AllDead = false;
break;
}
tg++;
}
AnyGhostsAlive = !AllDead;
}
if (Mode == 1) {
if (cr == 0) {
AddLevelScore();
_parent.gotoAndStop("Level Complete");
} else if (!AnyGhostsAlive) {
_parent.gotoAndStop("Life Lost");
}
}
if (Mode == 2) {
if (cr == 0) {
_parent.gotoAndStop("Life Lost");
}
}
}
}
}
if (GhostsBlue) {
BlueCounter++;
if (BlueCounter == BlueTime) {
gh = 1;
while (gh <= GhostsNum) {
Characters[gh].Fading = true;
Characters[gh].FadeDir = -1;
Characters[gh].FadeCounter = 10;
gh++;
}
}
}
Bonuses._visible = BonusOut;
if ((((Mode == 2) and AnyGhostsAlive) and (!BonusOut)) and (random(250) == 0)) {
BonusOut = true;
BonusCounter = 250;
BonusType = random(Bonuses._totalframes) + 1;
Bonuses.gotoAndStop(BonusType);
}
if (BonusOut) {
BonusCounter--;
if (BonusCounter >= 200) {
Bonuses._alpha = (250 - BonusCounter) * 2;
}
if (BonusCounter < 50) {
Bonuses._alpha = BonusCounter * 2;
}
if (BonusCounter == 0) {
BonusOut = false;
}
if (((Characters[0].SquareX == 14) or (Characters[0].SquareX == 15)) and (Characters[0].SquareY == 18)) {
BonusOut = false;
switch (BonusType) {
case 1 :
_parent.Score = _parent.Score + 100;
break;
case 2 :
_parent.Score = _parent.Score + 200;
break;
case 3 :
_parent.Score = _parent.Score + 300;
break;
case 4 :
_parent.Lives++;
break;
case 5 :
TurnGhostsBlue();
}
if (_parent.SFXOn) {
EatBonus.start();
}
}
}
gi = 1;
while (gi <= GhostsNum) {
if (gi == UnderControl) {
this["GI" + gi].Selected._visible = true;
} else {
this["GI" + gi].Selected._visible = false;
}
gi++;
}
UpdateIndicator(ScoreInd, _parent.Score);
UpdateIndicator(LevelInd, LevelRep);
UpdateIndicator(LivesInd, _parent.Lives);
}
MusicOff._visible = !_parent.MusicOn;
SFXOff._visible = !_parent.SFXOn;
Symbol 182 MovieClip Frame 3
gotoAndPlay ("Cycle");
Symbol 187 Button
on (release) {
gotoAndStop ("Game");
}
Symbol 196 Button
on (release) {
CurrLevel++;
gotoAndStop ("Game");
}
Symbol 201 Button
on (release) {
gotoAndStop ("Submit Score");
}
Symbol 204 MovieClip Frame 1
function InitGhost(TheGhost) {
TheGhost._x = random(450);
TheGhost._y = -20;
TheGhost.Delay = random(100);
TheGhost.Fall = false;
TheGhost.N = random(4) + 1;
switch (TheGhost.N) {
case 1 :
TheGhost.R = 100;
TheGhost.G = 0;
TheGhost.B = 0;
break;
case 2 :
TheGhost.R = 120;
TheGhost.G = 90;
TheGhost.B = 95;
break;
case 3 :
TheGhost.R = 0;
TheGhost.G = 100;
TheGhost.B = 100;
break;
case 4 :
TheGhost.R = 120;
TheGhost.G = 90;
TheGhost.B = 0;
}
TheGhost._visible = true;
TheGhost.BCol = new Color(TheGhost.Body);
TheGhost.BCol.setTransform({ra:TheGhost.R, rb:0, ga:TheGhost.G, gb:0, ba:TheGhost.B, bb:0, aa:100, ab:0});
TheGhost.Num.gotoAndStop(TheGhost.N);
TheGhost.gotoAndStop(1);
TheGhost.Speed = 2 + (Math.random() * 2);
}
TotalGhosts = 20;
cg = 1;
while (cg <= TotalGhosts) {
duplicateMovieClip ("GhostSample", "g" + cg, this.getNextHighestDepth());
InitGhost(this["g" + cg]);
cg++;
}
GhostSample._visible = false;
Symbol 204 MovieClip Frame 2
g = 1;
while (g <= TotalGhosts) {
if (!this["g" + g].Fall) {
this["g" + g].Delay--;
if (this["g" + g].Delay == 0) {
this["g" + g].Fall = true;
}
}
if (this["g" + g].Fall) {
if (this["g" + g].Speed == 0) {
this["g" + g].Speed = 3;
} else if (this["g" + g].Speed < 10) {
this["g" + g].Speed = this["g" + g].Speed * 1.05;
}
this["g" + g]._y = this["g" + g]._y + this["g" + g].Speed;
if (this["g" + g]._y > 450) {
InitGhost(this["g" + g]);
}
}
g++;
}
Symbol 204 MovieClip Frame 3
gotoAndPlay ("Cycle");
Symbol 213 MovieClip Frame 1
TotalBalls = 20;
dblPI = (Math.PI*2);
Reflect = [undefined, Math.PI, 4.71238898038469, 0, (Math.PI/2)];
i = 1;
while (i <= TotalBalls) {
duplicateMovieClip ("Pacman", "P" + i, this.getNextHighestDepth());
this["P" + i].x = (this["P" + i]._x = random(450));
this["P" + i].y = (this["P" + i]._y = random(425));
this["P" + i].Dir = Math.random() * dblPI;
this["P" + i].Speed = 5 + (Math.random() * 7);
i++;
}
Pacman._visible = false;
Symbol 213 MovieClip Frame 2
i = 1;
while (i <= TotalBalls) {
this["P" + i].PrevX = this["P" + i].x;
this["P" + i].PrevY = this["P" + i].y;
this["P" + i].x = this["P" + i].x + (this["P" + i].Speed * Math.cos(this["P" + i].Dir));
this["P" + i].y = this["P" + i].y - (this["P" + i].Speed * Math.sin(this["P" + i].Dir));
if (this["P" + i].Dir > dblPI) {
this["P" + i].Dir = this["P" + i].Dir - dblPI;
}
if (this["P" + i].Dir < 0) {
this["P" + i].Dir = this["P" + i].Dir + dblPI;
}
Hit = 0;
if (this["P" + i].y <= 12) {
Hit = 1;
this["P" + i].y = 12;
}
if (this["P" + i].x >= 437) {
Hit = 2;
this["P" + i].x = 437;
}
if (this["P" + i].y >= 428) {
Hit = 3;
this["P" + i].y = 428;
}
if (this["P" + i].x <= 12) {
Hit = 4;
this["P" + i].x = 12;
}
if ((Hit == 1) or (Hit == 3)) {
this["P" + i]._xscale = 120;
this["P" + i]._yscale = 80;
}
if ((Hit == 2) or (Hit == 4)) {
this["P" + i]._xscale = 80;
this["P" + i]._yscale = 120;
}
if (Hit > 0) {
AngleDiff = this["P" + i].Dir - Reflect[Hit];
this["P" + i].Dir = Reflect[Hit] - AngleDiff;
}
if (Hit == 0) {
if (this["P" + i]._xscale > 100) {
this["P" + i]._xscale = this["P" + i]._xscale - 5;
}
if (this["P" + i]._xscale < 100) {
this["P" + i]._xscale = this["P" + i]._xscale + 5;
}
if (this["P" + i]._yscale > 100) {
this["P" + i]._yscale = this["P" + i]._yscale - 5;
}
if (this["P" + i]._yscale < 100) {
this["P" + i]._yscale = this["P" + i]._yscale + 5;
}
}
this["P" + i]._x = this["P" + i].x;
this["P" + i]._y = this["P" + i].y;
i++;
}
Symbol 213 MovieClip Frame 3
gotoAndPlay ("Cycle");
Symbol 246 Button
on (press) {
if (UserName.length > 0) {
Masks = new Array("DSKJHiurhg987jsdlLJHjkdsfhiriurehgKJDh9i", "ujhfLJKDFHuiefo8909(9904985", "asFREfpirgj8(UJUhhljhh&dkjhfuEWru", "sdgajghjJHuoweppsdnniuhfr(%$", "jkhgtro88)(rgh435&84657/", "3590820687H985HHUuehuefwoianfnHNurehfruUHFEouh", "RIngiuoirenuiNU9987Hu774t0y/9898yhrgu", "RE98548ghNhr09gh87097y5t7hh08(=/CFH704t57h7hNH0958uy-?(u", "54t958(987y667980=)(7598y7987fyruchuih0/9875y87");
Data = new Array();
Data[0] = random(Masks.length);
Data[1] = random(Masks[Data[0]].length);
Data[2] = UserName.length;
ScoreSt = UserScore.toString();
Data[3] = ScoreSt.length;
i = 0;
while (i < Data[2]) {
Data[5 + i] = ord(UserName.charAt(i));
i++;
}
i = 0;
while (i < Data[3]) {
Data[(5 + Data[2]) + i] = ord(ScoreSt.charAt(i));
i++;
}
CheckSum = 0;
i = 5;
while (i < Data.length) {
CheckSum = CheckSum + Data[i];
i++;
}
Data[4] = CheckSum % 100;
COS = Data[1];
i = 2;
while (i < Data.length) {
MaskCo = ord(Masks[Data[0]].charAt(COS)) % 40;
if (MaskCo == 0) {
MaskCo = 40;
}
Data[i] = Data[i] + ord(Masks[Data[0]].charAt(COS));
Data[i] = Data[i] * MaskCo;
COS++;
if (COS >= Masks[Data[0]].length) {
COS = 0;
}
i++;
}
Output = Data.join("x");
Dt.res = Output;
SendData = true;
RName = UserName;
RScore = UserScore;
gotoAndStop (2);
} else {
Nm.gotoAndPlay(2);
}
}
Symbol 250 MovieClip Frame 1
stop();
Symbol 251 Button
on (press) {
_parent.gotoAndStop("Main Menu");
}
Symbol 259 Button
on (press) {
getURL ("http://www.sugar-free-games.com", "_blank");
}
Symbol 265 Button
on (press) {
SendData = true;
}
Symbol 268 MovieClip Frame 1
Ind = ScoreInd;
Par = _parent.Score;
StrRep = String(Par);
dg = 0;
while (dg <= 10) {
if (dg < StrRep.length) {
Ind["d" + dg]._visible = true;
if (StrRep.charAt(dg) == "-") {
Ind["d" + dg].gotoAndStop(11);
} else {
Ind["d" + dg].gotoAndStop(Number(StrRep.charAt(dg)) + 1);
}
} else {
Ind["d" + dg]._visible = false;
}
dg++;
}
Ind._x = -(StrRep.length * 5);
UserScore = _parent.Score;
Selection.setFocus("UserName");
_parent.Score = 0;
stop();
Instance of Symbol 260 MovieClip "Dt" in Symbol 268 MovieClip Frame 1
onClipEvent (enterFrame) {
if (_parent.SendData) {
getURL ("http://www.sugar-free-games.com/antipacman.php", "_blank", "POST");
_parent.SendData = false;
}
}
Symbol 268 MovieClip Frame 2
RName = "Name: " + RName;
RScore = "Score: " + RScore;
stop();