home *** CD-ROM | disk | FTP | other *** search
- function BuildMattrix()
- {
- arrMatrix = new Array();
- arrMatrix.push(new Array(0,1,1,1,1,1,1,1,1,1,1,0));
- arrMatrix.push(new Array(1,1,1,1,1,1,1,1,1,1,1,1));
- arrMatrix.push(new Array(1,1,1,1,1,1,1,1,1,1,1,1));
- arrMatrix.push(new Array(1,1,1,1,1,1,1,1,1,1,1,1));
- arrMatrix.push(new Array(1,1,1,1,1,1,1,1,1,1,1,1));
- arrMatrix.push(new Array(0,1,1,1,1,1,1,1,1,1,1,0));
- arrMatrix1 = new Array();
- arrMatrix1.push(new Array(0,0,0,1,1,1,1,1,1,0,0,0));
- arrMatrix1.push(new Array(0,0,1,1,1,1,1,1,1,1,0,0));
- arrMatrix1.push(new Array(0,1,1,1,1,1,1,1,1,1,1,0));
- arrMatrix1.push(new Array(0,1,1,1,1,1,1,1,1,1,1,0));
- arrMatrix1.push(new Array(0,0,1,1,1,1,1,1,1,1,0,0));
- arrMatrix1.push(new Array(0,0,0,1,1,1,1,1,1,0,0,0));
- arrMatrix11 = new Array();
- arrMatrix11.push(new Array(0,0,0,0,0,0,0,0,0,0,0,0));
- arrMatrix11.push(new Array(0,0,0,1,1,1,1,1,1,0,0,0));
- arrMatrix11.push(new Array(0,0,1,1,1,1,1,1,1,1,0,0));
- arrMatrix11.push(new Array(0,0,1,1,1,1,1,1,1,1,0,0));
- arrMatrix11.push(new Array(0,0,0,1,1,1,1,1,1,0,0,0));
- arrMatrix11.push(new Array(0,0,0,0,0,0,0,0,0,0,0,0));
- }
- function loadEnd()
- {
- loadMovie(endURL,endFeature);
- blnLoad = true;
- }
- function Initialize()
- {
- mcDialog._visible = false;
- removeAll();
- BuildMattrix();
- firstTile = "empty";
- arrTilesOnTeScreen = new Array();
- arrTiles = new Array();
- i = 1;
- while(34 >= i)
- {
- n = 0;
- while(n < 4)
- {
- arrTiles.push(String(i));
- n++;
- }
- i++;
- }
- i = 35;
- while(42 >= i)
- {
- arrTiles.push(String(i));
- i++;
- }
- i = 0;
- while(i < arrTiles.length)
- {
- saveTile = arrTiles[i];
- numRandom = getRandomValue(arrTiles.length);
- arrTiles[i] = arrTiles[numRandom];
- arrTiles[numRandom] = saveTile;
- i++;
- }
- x = 470;
- y = 60;
- count = 10;
- f = 0;
- PlaceTiles();
- UpdateCount();
- }
- function PlaceTiles()
- {
- i = 0;
- while(i < 6)
- {
- n = 12;
- while(n >= 0)
- {
- if(arrMatrix[i][n] == 1)
- {
- arrTilesOnTeScreen.push(String(f));
- _root.attachMovie(arrTiles[f],String(f),count);
- _root[String(f)]._x = x;
- _root[String(f)]._y = y;
- _root[String(f)].arr = "arrMatrix";
- _root[String(f)].x = i;
- _root[String(f)].y = n;
- getValues(arrTiles[f],String(f));
- var arrToDelete = new Array();
- arrToDelete.push(new Array(i,n));
- _root[String(f)].arrToDelete = arrToDelete;
- count++;
- f++;
- }
- x -= 37;
- y += 12;
- n--;
- }
- x = 470 + 22 * (i + 1);
- y = 60 + 40 * (i + 1);
- i++;
- }
- x = 473;
- y = 48;
- i = 0;
- while(i < 6)
- {
- n = 12;
- while(n >= 0)
- {
- if(arrMatrix1[i][n] == 1)
- {
- arrTilesOnTeScreen.push(String(f));
- _root.attachMovie(arrTiles[f],String(f),count);
- _root[String(f)]._x = x;
- _root[String(f)]._y = y;
- _root[String(f)].arr = "arrMatrix1";
- _root[String(f)].x = i;
- _root[String(f)].y = n;
- getValues(arrTiles[f],String(f));
- var arrToDelete = new Array();
- arrToDelete.push(new Array(i,n));
- _root[String(f)].arrToDelete = arrToDelete;
- count++;
- f++;
- }
- x -= 37;
- y += 12;
- n--;
- }
- x = 473 + 22 * (i + 1);
- y = 48 + 40 * (i + 1);
- i++;
- }
- x = 476;
- y = 36;
- i = 0;
- while(i < 6)
- {
- n = 12;
- while(n >= 0)
- {
- if(arrMatrix11[i][n] == 1)
- {
- arrTilesOnTeScreen.push(String(f));
- _root.attachMovie(arrTiles[f],String(f),count);
- _root[String(f)]._x = x;
- _root[String(f)]._y = y;
- _root[String(f)].arr = "arrMatrix11";
- _root[String(f)].x = i;
- _root[String(f)].y = n;
- getValues(arrTiles[f],String(f));
- var arrToDelete = new Array();
- arrToDelete.push(new Array(i,n));
- _root[String(f)].arrToDelete = arrToDelete;
- count++;
- f++;
- }
- x -= 37;
- y += 12;
- n--;
- }
- x = 476 + 22 * (i + 1);
- y = 36 + 40 * (i + 1);
- i++;
- }
- }
- function getValues(tile, movie)
- {
- var num = parseInt(tile);
- if(num >= 35 && 38 >= num)
- {
- _root[movie].value = "flower";
- _root[movie].score = 6;
- }
- else if(num >= 39 && 42 >= num)
- {
- _root[movie].value = "season";
- _root[movie].score = 6;
- }
- else
- {
- _root[movie].value = tile;
- if(num >= 1 && 9 >= num)
- {
- _root[movie].score = 3;
- }
- else if(num >= 10 && 18 >= num)
- {
- _root[movie].score = 1;
- }
- else if(num >= 19 && 27 >= num)
- {
- _root[movie].score = 2;
- }
- else if(num >= 28 && 30 >= num)
- {
- _root[movie].score = 5;
- }
- else if(num >= 31 && 34 >= num)
- {
- _root[movie].score = 4;
- }
- }
- }
- function RollOverTile(name)
- {
- if(endGame == true)
- {
- return undefined;
- }
- if(_root[name]._currentframe < 3)
- {
- _root[name].gotoAndStop(2);
- }
- }
- function RollOutTile(name)
- {
- if(endGame == true)
- {
- return undefined;
- }
- if(_root[name]._currentframe < 3)
- {
- _root[name].gotoAndStop(1);
- }
- }
- function PressTile(tile)
- {
- if(endGame == true)
- {
- return undefined;
- }
- soundPress.start();
- if(firstTile == tile)
- {
- firstTile = "empty";
- _root[tile].gotoAndStop(1);
- }
- else if(firstTile == "empty")
- {
- if(CheckTile(tile) == 1)
- {
- _root[tile].gotoAndStop(3);
- firstTile = tile;
- }
- else
- {
- soundWrong.start();
- }
- }
- else if(CheckTile(tile) == 1)
- {
- if(_root[firstTile].value == _root[tile].value)
- {
- _root[tile].gotoAndStop(3);
- mcRemover.tile1 = firstTile;
- mcRemover.tile2 = tile;
- soundCorrect.start();
- AddScore();
- }
- else
- {
- _root[firstTile].gotoAndStop(1);
- _root[tile].gotoAndStop(1);
- firstTile = "empty";
- soundWrong.start();
- }
- }
- else
- {
- _root[firstTile].gotoAndStop(1);
- _root[tile].gotoAndStop(1);
- firstTile = "empty";
- soundWrong.start();
- }
- }
- function CheckTile(tile)
- {
- if(CheckTop(tile) == 0)
- {
- if(CheckRight(tile) == 0)
- {
- _root[tile].course = "right";
- return 1;
- }
- if(CheckLeft(tile) == 0)
- {
- _root[tile].course = "left";
- return 1;
- }
- return 0;
- }
- }
- function CheckTop(tile)
- {
- var arr = _root[tile].arr;
- var x = _root[tile].x;
- var y = _root[tile].y;
- if(_root[arr + "1"][x][y] == 0 || _root[arr + "1"][x][y] == undefined)
- {
- return 0;
- }
- return 1;
- }
- function CheckRight(tile)
- {
- var arr = _root[tile].arr;
- var x = _root[tile].x;
- var y = _root[tile].y;
- if(_root[arr][x][y + 1] == 0 || _root[arr][x][y + 1] == undefined)
- {
- return 0;
- }
- return 1;
- }
- function CheckLeft(tile)
- {
- var arr = _root[tile].arr;
- var x = _root[tile].x;
- var y = _root[tile].y;
- if(_root[arr][x][y - 1] == 0 || _root[arr][x][y - 1] == undefined)
- {
- return 0;
- }
- return 1;
- }
- function RemoveTile(tile)
- {
- var arr = _root[tile].arr;
- var arrToDelete = _root[tile].arrToDelete;
- i = 0;
- while(i < arrToDelete.length)
- {
- _root[arr][arrToDelete[i][0]][arrToDelete[i][1]] = 0;
- i++;
- }
- removeMovieClip(_root[tile]);
- RemoveFromArray(tile);
- firstTile = "empty";
- }
- function RemoveFromArray(tile)
- {
- i = 0;
- while(i < arrTilesOnTeScreen.length)
- {
- if(arrTilesOnTeScreen[i] == tile)
- {
- arrTilesOnTeScreen.splice(i,1);
- break;
- }
- i++;
- }
- mcChecker.gotoAndPlay(2);
- UpdateCount();
- }
- function UpdateCount()
- {
- tilesLeft = arrTilesOnTeScreen.length;
- }
- function AddScore()
- {
- var m = tilesLeft / 2;
- var score = eval(firstTile).score;
- totalPoints += m * score;
- if(m == 1)
- {
- endGame = true;
- mcNewShuffle.gotoAndStop(2);
- mcTimer.gotoAndPlay(5);
- }
- }
- function RemoveAll()
- {
- i = 0;
- while(i < arrTilesOnTeScreen.length)
- {
- removeMovieClip(eval(arrTilesOnTeScreen[i]));
- i++;
- }
- }
- function SoundOn()
- {
- soundPress.setVolume(100);
- soundCorrect.setVolume(100);
- soundStart.setVolume(100);
- soundTomer.setVolume(100);
- soundWrong.setVolume(100);
- }
- function SoundOff()
- {
- soundPress.setVolume(0);
- soundCorrect.setVolume(0);
- soundStart.setVolume(0);
- soundTomer.setVolume(0);
- soundWrong.setVolume(0);
- }
- function TimeBonus()
- {
- totalPoints += 10;
- }
- function GameOver()
- {
- endGame = true;
- gameOver = true;
- mcNewShuffle.gotoAndStop(2);
- mcDialog._visible = false;
- mcTimer.gotoAndStop(2);
- mcStart.swapDepths(1000);
- mcStart._y = 212;
- mcStart.gotoAndPlay("gameover");
- trace("");
- play();
- }
- function ShowDialog()
- {
- endGame = true;
- mcDialog.swapDepths(1010);
- mcDialog._visible = true;
- }
- function Continue()
- {
- endGame = false;
- mcDialog._visible = false;
- }
- stop();
- Initialize();
- soundStart.start();
- mcTimer.play();
- endGame = false;
-