home *** CD-ROM | disk | FTP | other *** search
- 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 = -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 = NaN;
- ClosestY = 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 = -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 -= 20;
- }
- else
- {
- _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 = _parent.Score + 1;
- }
- 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].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 += 435;
- Characters[cr].Symbol._x = Characters[cr].x + 5;
- 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 -= 435;
- Characters[cr].Symbol._x = Characters[cr].x + 5;
- 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 -= 100;
- }
- else
- {
- _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].DieCounter + 1;
- 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 += 100;
- break;
- case 2:
- _parent.Score += 200;
- break;
- case 3:
- _parent.Score += 300;
- break;
- case 4:
- _parent.Lives = _parent.Lives + 1;
- 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;
-