home *** CD-ROM | disk | FTP | other *** search
Text File | 2006-06-13 | 32.3 KB | 1,111 lines |
- class Player
- {
- var sName;
- var nBoardPosX;
- var nBoardPosY;
- var aLastShape;
- var nScore;
- var nLines;
- var nLevel;
- var nSpeed;
- var bPaused;
- var nAttack;
- var nDelay;
- var bMultiplayer;
- var nStars;
- var nNextShape;
- var nShape;
- var nRotation;
- var nPosX;
- var nPosY;
- var bNotMoved;
- var mcStatsBoard;
- var bGameOver;
- var aBoard;
- var mcBoard;
- var aShapes;
- var mcNextShapeBoard;
- var keyLeft;
- var keyRight;
- var keyMoveDown;
- var keyDrop;
- var keyRotate;
- var nTimerBlockFall;
- var nFillCounter;
- var nTimerFillBoard;
- function Player(param_sName, param_nBoardPosX, param_nBoardPosY)
- {
- this.sName = param_sName;
- this.nBoardPosX = param_nBoardPosX;
- this.nBoardPosY = param_nBoardPosY;
- this.aLastShape = new Array();
- this.nScore = 0;
- this.nLines = 0;
- this.nLevel = 0;
- this.nSpeed = 500;
- this.bPaused = true;
- this.nAttack = 0;
- this.nDelay = 0;
- this.bMultiplayer = false;
- this.nStars = 0;
- this.initShapes();
- this.initBoard();
- this.initNextShapeBoard();
- this.initStatsBoard();
- this.nNextShape = int(Math.random() * 7);
- this.nShape = this.nNextShape;
- this.nRotation = 0;
- this.nPosX = 3;
- this.nPosY = -1;
- this.bNotMoved = true;
- this.drawShape();
- this.drawNextShape();
- this.drawStats();
- }
- function setMultiplayer()
- {
- this.bMultiplayer = true;
- this.mcStatsBoard.StatsBoard.mcStarBoard._visible = true;
- }
- function reinitiateGame()
- {
- this.nScore = 0;
- this.nLines = 0;
- this.nLevel = 0;
- this.nSpeed = 500;
- this.bPaused = true;
- this.nAttack = 0;
- this.nDelay = 0;
- this.bGameOver = false;
- var _loc4_ = 0;
- while(_loc4_ < 18)
- {
- var _loc2_ = 0;
- while(_loc2_ < 10)
- {
- this.aBoard[_loc2_][_loc4_] = 0;
- _loc2_ = _loc2_ + 1;
- }
- _loc4_ = _loc4_ + 1;
- }
- _loc4_ = 0;
- while(_loc4_ < 18)
- {
- _loc2_ = 0;
- while(_loc2_ < 10)
- {
- var _loc3_ = _loc4_ * 10 + _loc2_;
- this.mcBoard[_loc3_]._x = _loc2_ * 20;
- this.mcBoard[_loc3_]._y = _loc4_ * 20;
- this.mcBoard[_loc3_].mcExplosion.gotoAndStop(1);
- _loc2_ = _loc2_ + 1;
- }
- _loc4_ = _loc4_ + 1;
- }
- this.mcBoard.Board.mcBoardBG.mcColones._visible = false;
- this.nNextShape = int(Math.random() * 7);
- this.nShape = this.nNextShape;
- this.nRotation = 0;
- this.nPosX = 3;
- this.nPosY = -1;
- this.bNotMoved = true;
- this.mcBoard.GameoverClip.removeMovieClip();
- this.drawShape();
- this.drawNextShape();
- this.drawStats();
- }
- function initShapes()
- {
- this.aShapes = [];
- var _loc4_ = 0;
- while(_loc4_ < 40)
- {
- this.aShapes[_loc4_] = [];
- var _loc3_ = 0;
- while(_loc3_ < 4)
- {
- this.aShapes[_loc4_][_loc3_] = [];
- var _loc2_ = 0;
- while(_loc2_ < 4)
- {
- this.aShapes[_loc4_][_loc3_][_loc2_] = 0;
- _loc2_ = _loc2_ + 1;
- }
- _loc3_ = _loc3_ + 1;
- }
- _loc4_ = _loc4_ + 1;
- }
- this.aShapes[0][0][1] = 5;
- this.aShapes[0][0][2] = 5;
- this.aShapes[0][1][1] = 5;
- this.aShapes[0][2][1] = 5;
- this.aShapes[1][0][1] = 5;
- this.aShapes[1][1][1] = 5;
- this.aShapes[1][1][2] = 5;
- this.aShapes[1][1][3] = 5;
- this.aShapes[2][2][1] = 5;
- this.aShapes[2][2][2] = 5;
- this.aShapes[2][1][2] = 5;
- this.aShapes[2][0][2] = 5;
- this.aShapes[3][0][1] = 5;
- this.aShapes[3][0][2] = 5;
- this.aShapes[3][0][3] = 5;
- this.aShapes[3][1][3] = 5;
- this.aShapes[4][2][2] = 6;
- this.aShapes[4][2][1] = 6;
- this.aShapes[4][1][1] = 6;
- this.aShapes[4][0][1] = 6;
- this.aShapes[5][1][1] = 6;
- this.aShapes[5][1][2] = 6;
- this.aShapes[5][1][3] = 6;
- this.aShapes[5][0][3] = 6;
- this.aShapes[6][0][2] = 6;
- this.aShapes[6][0][1] = 6;
- this.aShapes[6][1][2] = 6;
- this.aShapes[6][2][2] = 6;
- this.aShapes[7][1][1] = 6;
- this.aShapes[7][0][1] = 6;
- this.aShapes[7][0][2] = 6;
- this.aShapes[7][0][3] = 6;
- this.aShapes[8][1][1] = 2;
- this.aShapes[8][0][2] = 2;
- this.aShapes[8][1][2] = 2;
- this.aShapes[8][2][2] = 2;
- this.aShapes[9][0][1] = 2;
- this.aShapes[9][0][2] = 2;
- this.aShapes[9][1][2] = 2;
- this.aShapes[9][0][3] = 2;
- this.aShapes[10][0][1] = 2;
- this.aShapes[10][1][1] = 2;
- this.aShapes[10][2][1] = 2;
- this.aShapes[10][1][2] = 2;
- this.aShapes[11][1][1] = 2;
- this.aShapes[11][0][2] = 2;
- this.aShapes[11][1][2] = 2;
- this.aShapes[11][1][3] = 2;
- this.aShapes[12][0][1] = 7;
- this.aShapes[12][1][1] = 7;
- this.aShapes[12][2][1] = 7;
- this.aShapes[12][3][1] = 7;
- this.aShapes[13][1][0] = 7;
- this.aShapes[13][1][1] = 7;
- this.aShapes[13][1][2] = 7;
- this.aShapes[13][1][3] = 7;
- this.aShapes[14][0][1] = 7;
- this.aShapes[14][1][1] = 7;
- this.aShapes[14][2][1] = 7;
- this.aShapes[14][3][1] = 7;
- this.aShapes[15][1][0] = 7;
- this.aShapes[15][1][1] = 7;
- this.aShapes[15][1][2] = 7;
- this.aShapes[15][1][3] = 7;
- this.aShapes[16][1][1] = 1;
- this.aShapes[16][2][1] = 1;
- this.aShapes[16][1][2] = 1;
- this.aShapes[16][2][2] = 1;
- this.aShapes[17][1][1] = 1;
- this.aShapes[17][2][1] = 1;
- this.aShapes[17][1][2] = 1;
- this.aShapes[17][2][2] = 1;
- this.aShapes[18][1][1] = 1;
- this.aShapes[18][2][1] = 1;
- this.aShapes[18][1][2] = 1;
- this.aShapes[18][2][2] = 1;
- this.aShapes[19][1][1] = 1;
- this.aShapes[19][2][1] = 1;
- this.aShapes[19][1][2] = 1;
- this.aShapes[19][2][2] = 1;
- this.aShapes[20][0][1] = 3;
- this.aShapes[20][1][1] = 3;
- this.aShapes[20][1][2] = 3;
- this.aShapes[20][2][2] = 3;
- this.aShapes[21][1][1] = 3;
- this.aShapes[21][0][2] = 3;
- this.aShapes[21][1][2] = 3;
- this.aShapes[21][0][3] = 3;
- this.aShapes[22][0][1] = 3;
- this.aShapes[22][1][1] = 3;
- this.aShapes[22][1][2] = 3;
- this.aShapes[22][2][2] = 3;
- this.aShapes[23][1][1] = 3;
- this.aShapes[23][0][2] = 3;
- this.aShapes[23][1][2] = 3;
- this.aShapes[23][0][3] = 3;
- this.aShapes[24][1][1] = 4;
- this.aShapes[24][2][1] = 4;
- this.aShapes[24][0][2] = 4;
- this.aShapes[24][1][2] = 4;
- this.aShapes[25][0][1] = 4;
- this.aShapes[25][0][2] = 4;
- this.aShapes[25][1][2] = 4;
- this.aShapes[25][1][3] = 4;
- this.aShapes[26][1][1] = 4;
- this.aShapes[26][2][1] = 4;
- this.aShapes[26][0][2] = 4;
- this.aShapes[26][1][2] = 4;
- this.aShapes[27][0][1] = 4;
- this.aShapes[27][0][2] = 4;
- this.aShapes[27][1][2] = 4;
- this.aShapes[27][1][3] = 4;
- this.aShapes[28][0][0] = 4;
- this.aShapes[28][1][1] = 4;
- this.aShapes[28][2][2] = 4;
- this.aShapes[28][3][3] = 4;
- this.aShapes[28][3][0] = 4;
- this.aShapes[29][3][0] = 4;
- this.aShapes[29][2][1] = 4;
- this.aShapes[29][1][2] = 4;
- this.aShapes[29][0][3] = 4;
- this.aShapes[29][3][3] = 4;
- this.aShapes[30][0][0] = 4;
- this.aShapes[30][1][1] = 4;
- this.aShapes[30][2][2] = 4;
- this.aShapes[30][3][3] = 4;
- this.aShapes[30][0][3] = 4;
- this.aShapes[31][3][0] = 4;
- this.aShapes[31][2][1] = 4;
- this.aShapes[31][1][2] = 4;
- this.aShapes[31][0][3] = 4;
- this.aShapes[31][0][0] = 4;
- this.aShapes[32][0][0] = 4;
- this.aShapes[32][0][1] = 4;
- this.aShapes[32][0][2] = 4;
- this.aShapes[32][2][0] = 4;
- this.aShapes[32][3][0] = 4;
- this.aShapes[32][3][1] = 4;
- this.aShapes[33][1][0] = 4;
- this.aShapes[33][2][0] = 4;
- this.aShapes[33][3][0] = 4;
- this.aShapes[33][3][2] = 4;
- this.aShapes[33][3][3] = 4;
- this.aShapes[33][2][3] = 4;
- this.aShapes[34][3][1] = 4;
- this.aShapes[34][3][2] = 4;
- this.aShapes[34][3][3] = 4;
- this.aShapes[34][0][2] = 4;
- this.aShapes[34][0][3] = 4;
- this.aShapes[34][1][3] = 4;
- this.aShapes[35][0][0] = 4;
- this.aShapes[35][1][0] = 4;
- this.aShapes[35][0][1] = 4;
- this.aShapes[35][0][3] = 4;
- this.aShapes[35][1][3] = 4;
- this.aShapes[35][2][3] = 4;
- this.aShapes[36][0][0] = 4;
- this.aShapes[36][2][0] = 4;
- this.aShapes[36][3][1] = 4;
- this.aShapes[36][0][2] = 4;
- this.aShapes[36][1][3] = 4;
- this.aShapes[36][3][3] = 4;
- this.aShapes[37][1][0] = 4;
- this.aShapes[37][3][0] = 4;
- this.aShapes[37][0][1] = 4;
- this.aShapes[37][3][2] = 4;
- this.aShapes[37][0][3] = 4;
- this.aShapes[37][2][3] = 4;
- this.aShapes[38][0][0] = 4;
- this.aShapes[38][2][0] = 4;
- this.aShapes[38][3][1] = 4;
- this.aShapes[38][0][2] = 4;
- this.aShapes[38][1][3] = 4;
- this.aShapes[38][3][3] = 4;
- this.aShapes[39][1][0] = 4;
- this.aShapes[39][3][0] = 4;
- this.aShapes[39][0][1] = 4;
- this.aShapes[39][3][2] = 4;
- this.aShapes[39][0][3] = 4;
- this.aShapes[39][2][3] = 4;
- }
- function initBoard()
- {
- this.mcBoard = _root.createEmptyMovieClip(this.sName,_root.getNextHighestDepth());
- this.mcBoard.attachMovie("Board","Board",this.mcBoard.getNextHighestDepth(),{_x:0,_y:0});
- this.mcBoard.Board.TextPlayerName.text = this.sName;
- this.mcBoard.Board.mcBoardBG.mcColones._visible = false;
- this.mcBoard.Board.mcPause._visible = false;
- this.mcBoard._x = this.nBoardPosX;
- this.mcBoard._y = this.nBoardPosY;
- this.aBoard = [];
- var _loc3_ = 0;
- while(_loc3_ < 10)
- {
- this.aBoard[_loc3_] = [];
- var _loc5_ = 0;
- while(_loc5_ < 18)
- {
- this.aBoard[_loc3_][_loc5_] = 0;
- _loc5_ = _loc5_ + 1;
- }
- _loc3_ = _loc3_ + 1;
- }
- _loc5_ = 0;
- while(_loc5_ < 18)
- {
- _loc3_ = 0;
- while(_loc3_ < 10)
- {
- var _loc4_ = _loc5_ * 10 + _loc3_;
- this.mcBoard.attachMovie("Block",_loc4_,this.mcBoard.getNextHighestDepth(),{_x:_loc3_ * 20,_y:_loc5_ * 20});
- this.mcBoard[_loc4_].gotoAndStop(1);
- this.mcBoard[_loc4_].mcExplosion.gotoAndStop(1);
- _loc3_ = _loc3_ + 1;
- }
- _loc5_ = _loc5_ + 1;
- }
- }
- function initNextShapeBoard()
- {
- this.mcNextShapeBoard = _root.createEmptyMovieClip(this.sName + "NextShape",_root.getNextHighestDepth());
- this.mcNextShapeBoard.attachMovie("NextBlockBoard","NextBlockBoard",this.mcNextShapeBoard.getNextHighestDepth(),{_x:0,_y:0});
- this.mcNextShapeBoard._x = this.nBoardPosX + 200 + 10;
- this.mcNextShapeBoard._y = this.nBoardPosY;
- var _loc5_ = 0;
- while(_loc5_ < 4)
- {
- var _loc3_ = 0;
- while(_loc3_ < 4)
- {
- var _loc4_ = _loc5_ * 4 + _loc3_;
- this.mcNextShapeBoard.attachMovie("NextBlockClip",_loc4_,this.mcNextShapeBoard.getNextHighestDepth(),{_x:_loc3_ * 13,_y:_loc5_ * 13});
- this.mcNextShapeBoard[_loc4_].gotoAndStop(1);
- _loc3_ = _loc3_ + 1;
- }
- _loc5_ = _loc5_ + 1;
- }
- }
- function initStatsBoard()
- {
- this.mcStatsBoard = _root.createEmptyMovieClip(this.sName + "Stats",_root.getNextHighestDepth());
- this.mcStatsBoard._x = this.nBoardPosX + 200 + 10;
- this.mcStatsBoard._y = this.nBoardPosY + 61;
- this.mcStatsBoard.attachMovie("StatsBoard","StatsBoard",this.mcStatsBoard.getNextHighestDepth(),{_x:0,_y:0});
- this.mcStatsBoard.StatsBoard.mcStarBoard._visible = false;
- this.mcStatsBoard.StatsBoard.mcStarBoard.mcStar1.gotoAndStop(1);
- this.mcStatsBoard.StatsBoard.mcStarBoard.mcStar1._visible = false;
- this.mcStatsBoard.StatsBoard.mcStarBoard.mcStar2.gotoAndStop(1);
- this.mcStatsBoard.StatsBoard.mcStarBoard.mcStar2._visible = false;
- }
- function setKeys(param_keyLeft, param_keyRight, param_keyDrop, param_keyRotate, param_keyMoveDown)
- {
- this.keyLeft = param_keyLeft;
- this.keyRight = param_keyRight;
- this.keyMoveDown = param_keyMoveDown;
- this.keyDrop = param_keyDrop;
- this.keyRotate = param_keyRotate;
- }
- function startGame()
- {
- if(this.bPaused)
- {
- this.bPaused = false;
- var _loc4_ = 0;
- while(_loc4_ < 18)
- {
- var _loc2_ = 0;
- while(_loc2_ < 10)
- {
- var _loc3_ = _loc4_ * 10 + _loc2_;
- this.mcBoard[_loc3_]._visible = true;
- _loc2_ = _loc2_ + 1;
- }
- _loc4_ = _loc4_ + 1;
- }
- this.mcBoard.Board.mcPause._visible = false;
- this.moveDown();
- }
- clearInterval(this.nTimerBlockFall);
- this.nTimerBlockFall = setInterval(this,"blockFall",this.nSpeed);
- }
- function pauseGame()
- {
- this.bPaused = true;
- clearInterval(this.nTimerBlockFall);
- var _loc4_ = 0;
- while(_loc4_ < 18)
- {
- var _loc2_ = 0;
- while(_loc2_ < 10)
- {
- var _loc3_ = _loc4_ * 10 + _loc2_;
- this.mcBoard[_loc3_]._visible = false;
- _loc2_ = _loc2_ + 1;
- }
- _loc4_ = _loc4_ + 1;
- }
- this.mcBoard.Board.mcPause._visible = true;
- this.mcBoard.Board.mcPause.gotoAndPlay(1);
- }
- function stopGame()
- {
- clearInterval(this.nTimerBlockFall);
- }
- function blockFall()
- {
- if(this.isDelayed())
- {
- return undefined;
- }
- this.moveDown();
- updateAfterEvent();
- }
- function isDelayed()
- {
- if(this.nDelay <= 0)
- {
- return false;
- }
- if(--this.nDelay == 0)
- {
- this.clearFullLines();
- }
- return true;
- }
- function moveLeft()
- {
- if(this.nDelay > 0)
- {
- return undefined;
- }
- if(!this.collision(this.nPosX - 1,this.nPosY,this.nRotation))
- {
- this.nPosX = this.nPosX - 1;
- this.drawShape();
- }
- }
- function moveRight()
- {
- if(this.nDelay > 0)
- {
- return undefined;
- }
- if(!this.collision(this.nPosX + 1,this.nPosY,this.nRotation))
- {
- this.nPosX = this.nPosX + 1;
- this.drawShape();
- }
- }
- function rotate()
- {
- if(this.nDelay > 0)
- {
- return undefined;
- }
- var _loc2_ = this.nRotation + 1;
- if(_loc2_ > 3)
- {
- _loc2_ = 0;
- }
- if(!this.collision(this.nPosX,this.nPosY,_loc2_))
- {
- this.nRotation = _loc2_;
- this.drawShape();
- }
- }
- function dropDown()
- {
- if(this.nDelay > 0)
- {
- return undefined;
- }
- while(true)
- {
- if(this.collision(this.nPosX,this.nPosY + 1,this.nRotation))
- {
- this.drawShape();
- break;
- }
- this.nPosY = this.nPosY + 1;
- this.nScore = this.nScore + 1;
- }
- this.moveDown();
- }
- function moveDown()
- {
- if(this.nDelay > 0)
- {
- return undefined;
- }
- if(!this.collision(this.nPosX,this.nPosY + 1,this.nRotation))
- {
- this.nPosY = this.nPosY + 1;
- this.drawShape();
- this.nScore = this.nScore + 1;
- }
- else
- {
- this.checkLines();
- this.nShape = this.nNextShape;
- this.nRotation = 0;
- this.nPosX = 3;
- this.nPosY = -99;
- var _loc3_ = 0;
- while(_loc3_ < 4)
- {
- var _loc2_ = 0;
- while(_loc2_ < 4)
- {
- if(this.aShapes[this.nShape * 4 + this.nRotation][_loc2_][_loc3_] != 0 && this.nPosY == -99)
- {
- this.nPosY = - _loc3_;
- }
- _loc2_ = _loc2_ + 1;
- }
- _loc3_ = _loc3_ + 1;
- }
- this.bNotMoved = true;
- this.nNextShape = int(Math.random() * 7);
- this.drawShape();
- this.drawNextShape();
- this.drawStats();
- if(this.collision(this.nPosX,this.nPosY,this.nRotation))
- {
- this.gameOver();
- }
- }
- }
- function collision(param_nPosX, param_nPosY, param_nRotation)
- {
- var _loc5_ = 0;
- while(_loc5_ < 4)
- {
- var _loc2_ = 0;
- while(_loc2_ < 4)
- {
- if(this.aShapes[this.nShape * 4 + param_nRotation][_loc2_][_loc5_] != 0)
- {
- var _loc3_ = _loc2_ + param_nPosX;
- var _loc4_ = _loc5_ + param_nPosY;
- if(_loc3_ < 0 || _loc3_ > 9 || _loc4_ > 17)
- {
- return true;
- }
- if(this.aBoard[_loc3_][_loc4_] != 0)
- {
- return true;
- }
- }
- _loc2_ = _loc2_ + 1;
- }
- _loc5_ = _loc5_ + 1;
- }
- }
- function checkLines()
- {
- var _loc3_ = 0;
- while(_loc3_ < 4)
- {
- var _loc2_ = 0;
- while(_loc2_ < 4)
- {
- if(this.aShapes[this.nShape * 4 + this.nRotation][_loc2_][_loc3_] != 0)
- {
- var _loc5_ = _loc2_ + this.nPosX;
- var _loc4_ = _loc3_ + this.nPosY;
- this.aBoard[_loc5_][_loc4_] = this.aShapes[this.nShape * 4 + this.nRotation][_loc2_][_loc3_];
- }
- _loc2_ = _loc2_ + 1;
- }
- _loc3_ = _loc3_ + 1;
- }
- var _loc7_ = 0;
- _loc3_ = 0;
- while(_loc3_ < 18)
- {
- var _loc6_ = false;
- _loc2_ = 0;
- while(_loc2_ < 10)
- {
- if(this.aBoard[_loc2_][_loc3_] == 0)
- {
- _loc6_ = true;
- }
- _loc2_ = _loc2_ + 1;
- }
- if(!_loc6_)
- {
- _loc2_ = 0;
- while(_loc2_ < 10)
- {
- this.mcBoard[_loc3_ * 10 + _loc2_].mcExplosion.gotoAndPlay(2);
- _loc2_ = _loc2_ + 1;
- }
- _loc7_ = _loc7_ + 1;
- }
- _loc3_ = _loc3_ + 1;
- }
- if(_loc7_ > 0)
- {
- switch(_loc7_)
- {
- case 1:
- this.nScore += 40;
- this.nDelay = 1;
- break;
- case 2:
- this.nScore += 100;
- this.nDelay = 1;
- break;
- case 3:
- this.nScore += 300;
- this.nDelay = 1;
- break;
- case 4:
- this.nScore += 1200;
- this.nDelay = 2;
- this.applyBonus();
- }
- this.nAttack = _loc7_;
- this.nLines += _loc7_;
- if(Math.floor(this.nLines / 10) > this.nLevel)
- {
- this.nLevel = Math.floor(this.nLines / 10);
- }
- if(this.nLevel > 9)
- {
- this.nLevel = 9;
- }
- this.ajustSpeed();
- this.startGame();
- }
- }
- function clearFullLines()
- {
- var _loc5_ = 0;
- while(_loc5_ < 18)
- {
- var _loc6_ = false;
- var _loc4_ = 0;
- while(_loc4_ < 10)
- {
- if(this.aBoard[_loc4_][_loc5_] == 0)
- {
- _loc6_ = true;
- }
- _loc4_ = _loc4_ + 1;
- }
- if(!_loc6_)
- {
- var _loc3_ = _loc5_;
- while(_loc3_ >= 0)
- {
- var _loc2_ = 0;
- while(_loc2_ < 10)
- {
- if(_loc3_ == 0)
- {
- this.aBoard[_loc2_][_loc3_] = 0;
- }
- else
- {
- this.aBoard[_loc2_][_loc3_] = this.aBoard[_loc2_][_loc3_ - 1];
- }
- this.mcBoard[_loc3_ * 10 + _loc2_].mcExplosion.gotoAndStop(1);
- _loc2_ = _loc2_ + 1;
- }
- _loc3_ = _loc3_ - 1;
- }
- }
- _loc5_ = _loc5_ + 1;
- }
- this.fullBoardRedraw();
- }
- function applyAttack(param_nAttack)
- {
- if(param_nAttack == 0)
- {
- return undefined;
- }
- switch(param_nAttack)
- {
- case 2:
- var _loc4_ = 0;
- while(_loc4_ < 17)
- {
- var _loc2_ = 0;
- while(_loc2_ < 10)
- {
- this.aBoard[_loc2_][_loc4_] = this.aBoard[_loc2_][_loc4_ + 1];
- _loc2_ = _loc2_ + 1;
- }
- _loc4_ = _loc4_ + 1;
- }
- var _loc5_ = Math.floor(Math.random() * 10);
- _loc2_ = 0;
- while(_loc2_ < 10)
- {
- if(_loc2_ == _loc5_)
- {
- this.aBoard[_loc2_][17] = 0;
- }
- else
- {
- this.aBoard[_loc2_][17] = 25;
- }
- _loc2_ = _loc2_ + 1;
- }
- break;
- case 3:
- _loc4_ = 0;
- while(_loc4_ < 16)
- {
- _loc2_ = 0;
- while(_loc2_ < 10)
- {
- this.aBoard[_loc2_][_loc4_] = this.aBoard[_loc2_][_loc4_ + 2];
- _loc2_ = _loc2_ + 1;
- }
- _loc4_ = _loc4_ + 1;
- }
- _loc5_ = Math.floor(Math.random() * 10);
- _loc2_ = 0;
- while(_loc2_ < 10)
- {
- _loc4_ = 16;
- while(_loc4_ < 18)
- {
- if(_loc2_ == _loc5_)
- {
- this.aBoard[_loc2_][_loc4_] = 0;
- }
- else
- {
- this.aBoard[_loc2_][_loc4_] = 25;
- }
- _loc4_ = _loc4_ + 1;
- }
- _loc2_ = _loc2_ + 1;
- }
- break;
- case 4:
- this.mcBoard.Board.mcBoardBG.mcColones._visible = false;
- switch(Math.floor(Math.random() * 6))
- {
- case 0:
- _loc4_ = 0;
- while(_loc4_ < 15)
- {
- _loc2_ = 0;
- while(_loc2_ < 10)
- {
- this.aBoard[_loc2_][_loc4_] = this.aBoard[_loc2_][_loc4_ + 3];
- _loc2_ = _loc2_ + 1;
- }
- _loc4_ = _loc4_ + 1;
- }
- _loc5_ = Math.floor(Math.random() * 10);
- _loc2_ = 0;
- while(_loc2_ < 10)
- {
- _loc4_ = 15;
- while(_loc4_ < 18)
- {
- if(_loc2_ == _loc5_ || Math.floor(Math.random() * 10) > 5)
- {
- this.aBoard[_loc2_][_loc4_] = 0;
- }
- else
- {
- this.aBoard[_loc2_][_loc4_] = 25;
- }
- _loc4_ = _loc4_ + 1;
- }
- _loc2_ = _loc2_ + 1;
- }
- break;
- case 1:
- this.nNextShape = 7;
- this.drawNextShapeSurprise();
- break;
- case 2:
- this.nNextShape = 8;
- this.drawNextShapeSurprise();
- break;
- case 3:
- this.nNextShape = 9;
- this.drawNextShapeSurprise();
- break;
- case 4:
- _loc4_ = 0;
- while(_loc4_ < 18)
- {
- _loc2_ = 0;
- while(_loc2_ < 10)
- {
- var _loc3_ = _loc4_ * 10 + _loc2_;
- this.mcBoard[_loc3_]._x = 180 - _loc2_ * 20;
- this.mcBoard[_loc3_]._y = 340 - _loc4_ * 20;
- _loc2_ = _loc2_ + 1;
- }
- _loc4_ = _loc4_ + 1;
- }
- break;
- case 5:
- _loc4_ = 0;
- while(_loc4_ < 18)
- {
- _loc2_ = 0;
- while(_loc2_ < 10)
- {
- if(_loc2_ % 2)
- {
- this.aBoard[_loc2_][_loc4_] = 0;
- }
- _loc2_ = _loc2_ + 1;
- }
- _loc4_ = _loc4_ + 1;
- }
- }
- }
- this.fullBoardRedraw();
- }
- function applyBonus()
- {
- var _loc4_ = 0;
- while(_loc4_ < 18)
- {
- var _loc2_ = 0;
- while(_loc2_ < 10)
- {
- var _loc3_ = _loc4_ * 10 + _loc2_;
- this.mcBoard[_loc3_]._x = _loc2_ * 20;
- this.mcBoard[_loc3_]._y = _loc4_ * 20;
- _loc2_ = _loc2_ + 1;
- }
- _loc4_ = _loc4_ + 1;
- }
- this.mcBoard.Board.mcBoardBG.mcColones._visible = true;
- this.fullBoardRedraw();
- }
- function drawShape()
- {
- if(this.bNotMoved)
- {
- this.bNotMoved = false;
- }
- else
- {
- var _loc8_ = this.aLastShape.length;
- var _loc7_ = 0;
- while(_loc7_ < _loc8_)
- {
- this.mcBoard[this.aLastShape[_loc7_]].gotoAndStop(1);
- _loc7_ = _loc7_ + 1;
- }
- }
- this.aLastShape = [];
- _loc7_ = 0;
- var _loc5_ = 0;
- while(_loc5_ < 4)
- {
- var _loc2_ = 0;
- while(_loc2_ < 4)
- {
- var _loc6_ = undefined;
- if((_loc6_ = this.aShapes[this.nShape * 4 + this.nRotation][_loc2_][_loc5_]) != 0)
- {
- var _loc4_ = _loc2_ + this.nPosX;
- var _loc3_ = _loc5_ + this.nPosY;
- this.mcBoard[_loc3_ * 10 + _loc4_].gotoAndStop(_loc6_ + 1);
- this.aLastShape[_loc7_++] = _loc3_ * 10 + _loc4_;
- }
- _loc2_ = _loc2_ + 1;
- }
- _loc5_ = _loc5_ + 1;
- }
- }
- function fullBoardRedraw()
- {
- var _loc3_ = 0;
- while(_loc3_ < 18)
- {
- var _loc2_ = 0;
- while(_loc2_ < 10)
- {
- this.mcBoard[_loc3_ * 10 + _loc2_].gotoAndStop(this.aBoard[_loc2_][_loc3_] + 1);
- _loc2_ = _loc2_ + 1;
- }
- _loc3_ = _loc3_ + 1;
- }
- _loc3_ = 0;
- while(_loc3_ < 4)
- {
- _loc2_ = 0;
- while(_loc2_ < 4)
- {
- var _loc6_ = undefined;
- if((_loc6_ = this.aShapes[this.nShape * 4 + this.nRotation][_loc2_][_loc3_]) != 0)
- {
- var _loc5_ = _loc2_ + this.nPosX;
- var _loc4_ = _loc3_ + this.nPosY;
- this.mcBoard[_loc4_ * 10 + _loc5_].gotoAndStop(_loc6_ + 1);
- }
- _loc2_ = _loc2_ + 1;
- }
- _loc3_ = _loc3_ + 1;
- }
- }
- function drawNextShape()
- {
- var _loc4_ = 0;
- while(_loc4_ < 16)
- {
- this.mcNextShapeBoard[_loc4_].gotoAndStop(1);
- _loc4_ = _loc4_ + 1;
- }
- this.mcNextShapeBoard.NextBlockSurprise.removeMovieClip();
- var _loc5_ = int(Math.random() * 3) * 16 + 2;
- var _loc3_ = 0;
- while(_loc3_ < 4)
- {
- var _loc2_ = 0;
- while(_loc2_ < 4)
- {
- if(this.aShapes[this.nNextShape * 4 + this.nRotation][_loc2_][_loc3_] > 0)
- {
- this.mcNextShapeBoard[_loc3_ * 4 + _loc2_].gotoAndPlay(_loc5_);
- }
- _loc2_ = _loc2_ + 1;
- }
- _loc3_ = _loc3_ + 1;
- }
- }
- function drawNextShapeSurprise()
- {
- var _loc2_ = 0;
- while(_loc2_ < 16)
- {
- this.mcNextShapeBoard[_loc2_].gotoAndStop(1);
- _loc2_ = _loc2_ + 1;
- }
- this.mcNextShapeBoard.attachMovie("NextBlockSurprise","NextBlockSurprise",this.mcBoard.getNextHighestDepth(),{_x:0,_y:0});
- this.mcNextShapeBoard.NextBlockSurprise._x = 13;
- this.mcNextShapeBoard.NextBlockSurprise._y = 6;
- }
- function drawStats()
- {
- this.mcStatsBoard.StatsBoard.TextLevel.text = this.nLevel;
- this.mcStatsBoard.StatsBoard.TextScore.text = this.nScore;
- this.mcStatsBoard.StatsBoard.TextLines.text = this.nLines;
- }
- function gameOver()
- {
- this.bGameOver = true;
- this.stopGame();
- this.nFillCounter = 179;
- }
- function fillBoard()
- {
- var _loc2_ = 0;
- while(_loc2_ < 10)
- {
- this.mcBoard[this.nFillCounter--].gotoAndStop(25);
- _loc2_ = _loc2_ + 1;
- }
- if(this.nFillCounter < 0)
- {
- clearInterval(this.nTimerFillBoard);
- }
- updateAfterEvent();
- }
- function gameover()
- {
- this.mcBoard.attachMovie("GameoverClip","GameoverClip",this.mcBoard.getNextHighestDepth(),{_x:0,_y:0});
- }
- function win()
- {
- this.mcBoard.attachMovie("WinClip","GameoverClip",this.mcBoard.getNextHighestDepth(),{_x:0,_y:0});
- this.nStars = this.nStars + 1;
- if(this.nStars == 1)
- {
- this.mcStatsBoard.StatsBoard.mcStarBoard.mcStar1._visible = true;
- this.mcStatsBoard.StatsBoard.mcStarBoard.mcStar1.gotoAndPlay(1);
- }
- if(this.nStars == 2)
- {
- this.mcStatsBoard.StatsBoard.mcStarBoard.mcStar2._visible = true;
- this.mcStatsBoard.StatsBoard.mcStarBoard.mcStar2.gotoAndPlay(1);
- this.mcBoard.attachMovie("Trophy anim","Trophy anim",this.mcBoard.getNextHighestDepth(),{_x:56,_y:230});
- }
- }
- function setStars(nNumStars)
- {
- this.nStars = nNumStars;
- if(this.nStars < 0)
- {
- this.nStars = 0;
- }
- if(this.nStars > 2)
- {
- this.nStars = 2;
- }
- if(this.nStars >= 1)
- {
- this.mcStatsBoard.StatsBoard.mcStarBoard.mcStar1._visible = true;
- this.mcStatsBoard.StatsBoard.mcStarBoard.mcStar1.gotoAndStop(1);
- }
- if(this.nStars >= 2)
- {
- this.mcStatsBoard.StatsBoard.mcStarBoard.mcStar2._visible = true;
- this.mcStatsBoard.StatsBoard.mcStarBoard.mcStar2.gotoAndStop(1);
- }
- }
- function lose()
- {
- this.mcBoard.attachMovie("LoseClip","GameoverClip",this.mcBoard.getNextHighestDepth(),{_x:0,_y:0});
- }
- function destroy()
- {
- this.mcBoard.removeMovieClip();
- this.mcNextShapeBoard.removeMovieClip();
- this.mcStatsBoard.removeMovieClip();
- }
- function ajustSpeed()
- {
- this.nSpeed = 500 - this.nLevel * 40;
- }
- function jumpToLevel(param_nLevel)
- {
- this.nLevel = param_nLevel;
- this.ajustSpeed();
- this.drawStats();
- }
- function handicap(param_nHandicap)
- {
- var _loc4_ = Math.floor(Math.random() * 10);
- var _loc3_ = 0;
- while(_loc3_ < 10)
- {
- var _loc2_ = 18 - param_nHandicap * 2;
- while(_loc2_ < 18)
- {
- if(_loc3_ == _loc4_ || Math.floor(Math.random() * 10) > 5)
- {
- this.aBoard[_loc3_][_loc2_] = 0;
- }
- else
- {
- this.aBoard[_loc3_][_loc2_] = 25;
- }
- _loc2_ = _loc2_ + 1;
- }
- _loc3_ = _loc3_ + 1;
- }
- this.fullBoardRedraw();
- }
- function test(param_nLignes)
- {
- var _loc3_ = 0;
- while(_loc3_ < 9)
- {
- var _loc2_ = 18 - param_nLignes;
- while(_loc2_ < 18)
- {
- this.aBoard[_loc3_][_loc2_] = 25;
- _loc2_ = _loc2_ + 1;
- }
- _loc3_ = _loc3_ + 1;
- }
- this.nNextShape = 3;
- }
- }
-