home *** CD-ROM | disk | FTP | other *** search
Wrap
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,16384 + 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 -= 4; } if(Level[Char.SquareX + DirsX[CheckDir]][Char.SquareY + DirsY[CheckDir]] != 2) { Char.Dir = CheckDir; break; } adr++; } } function FillMatrix(X, Y) { var _loc2_ = undefined; var _loc1_ = undefined; BusyArr = new Array(); DirsPref = new Array(); fd = 1; while(fd <= 4) { DirsPref[fd] = {}; fd++; } _loc2_ = 0; while(_loc2_ < Level.length) { BusyArr[_loc2_] = []; _loc2_ = _loc2_ + 1; } 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) { 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) { _loc1_ = 1; while(_loc1_ <= 4) { NextSquareX = CurrSquare.x + DirsX[_loc1_]; NextSquareY = CurrSquare.y + DirsY[_loc1_]; if(NextSquareX >= 0 and NextSquareX < Level.length and NextSquareY >= 0 and NextSquareY < Level[0].length and Level[CurrSquare.x + DirsX[_loc1_]][CurrSquare.y + DirsY[_loc1_]] != 2 and Level[CurrSquare.x + DirsX[_loc1_]][CurrSquare.y + DirsY[_loc1_]] != 4 and BusyArr[NextSquareX][NextSquareY] == undefined) { if(CurrSquare.Level == 0) { OD = _loc1_; } else { OD = CurrSquare.OD; } FreeSquares.push({x:NextSquareX,y:NextSquareY,Level:CurrSquare.Level + 1,OD:OD}); } _loc1_ = _loc1_ + 1; } } } var _loc6_ = undefined; _loc6_ = Characters[0].CameFrom + 2; if(_loc6_ > 4) { _loc6_ -= 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 == _loc6_) { 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 _loc2_ = undefined; var _loc1_ = undefined; BusyArr = new Array(); DirsPref = new Array(); fd = 1; while(fd <= 4) { DirsPref[fd] = {}; fd++; } _loc2_ = 0; while(_loc2_ < Level.length) { BusyArr[_loc2_] = []; _loc2_ = _loc2_ + 1; } 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) { _loc1_ = 1; while(_loc1_ <= 4) { NextSquareX = CurrSquare.x + DirsX[_loc1_]; NextSquareY = CurrSquare.y + DirsY[_loc1_]; if(NextSquareX >= 0 and NextSquareX < Level.length and NextSquareY >= 0 and NextSquareY < Level[0].length and Level[CurrSquare.x + DirsX[_loc1_]][CurrSquare.y + DirsY[_loc1_]] != 2 and BusyArr[NextSquareX][NextSquareY] == undefined) { if(CurrSquare.Level == 0) { OD = _loc1_; } else { OD = CurrSquare.OD; } FreeSquares.push({x:NextSquareX,y:NextSquareY,Level:CurrSquare.Level + 1,OD:OD}); } _loc1_ = _loc1_ + 1; } } } var _loc6_ = undefined; _loc6_ = Characters[ind].CameFrom + 2; if(_loc6_ > 4) { _loc6_ -= 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 == _loc6_) { DirsPref[pd].Score -= 10; } pd++; } } function FindDir(ind, FromX, FromY, ToX, ToY) { var _loc2_ = new Array(); if(Math.abs(FromX - ToX) > Math.abs(FromY - ToY)) { if(ToX > FromX) { _loc2_.push(2); } else { _loc2_.push(4); } } else if(ToY > FromY) { _loc2_.push(3); } else { _loc2_.push(1); } if(Math.abs(FromX - ToX) > Math.abs(FromY - ToY)) { if(ToY > FromY) { _loc2_.push(3); } else { _loc2_.push(1); } } else if(ToX > FromX) { _loc2_.push(2); } else { _loc2_.push(4); } if(Math.abs(FromX - ToX) > Math.abs(FromY - ToY)) { if(ToY > FromY) { _loc2_.push(1); } else { _loc2_.push(3); } } else if(ToX > FromX) { _loc2_.push(4); } else { _loc2_.push(2); } if(Math.abs(FromX - ToX) > Math.abs(FromY - ToY)) { if(ToX > FromX) { _loc2_.push(4); } else { _loc2_.push(2); } } else if(ToY > FromY) { _loc2_.push(1); } else { _loc2_.push(3); } var _loc1_ = undefined; var _loc5_ = undefined; _loc5_ = Characters[ind].CameFrom + 2; if(_loc5_ > 4) { _loc5_ -= 4; } _loc1_ = 0; while(_loc1_ <= 3) { if(_loc2_[_loc1_] != _loc5_ and Level[FromX + DirsX[_loc2_[_loc1_]]][FromY + DirsY[_loc2_[_loc1_]]] != 2 and (ind != 0 or Level[FromX + DirsX[_loc2_[_loc1_]]][FromY + DirsY[_loc2_[_loc1_]]] != 4)) { return _loc2_[_loc1_]; } _loc1_ = _loc1_ + 1; } } 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 += 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,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,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",16384 + this.getNextHighestDepth()); duplicateMovieClip(PacmanSample,"PacmanCopy",16384 + this.getNextHighestDepth()); g = 1; while(g <= GhostsNum) { duplicateMovieClip(GhostSample,"G" + g,16384 + this.getNextHighestDepth()); duplicateMovieClip(GhostSample,"G" + g + "Copy",16384 + 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);