home *** CD-ROM | disk | FTP | other *** search
/ 600 Games / 600games.iso / Puzzle / arixtetris.swf / scripts / __Packages / Player.as
Encoding:
Text File  |  2006-06-13  |  32.3 KB  |  1,111 lines

  1. class Player
  2. {
  3.    var sName;
  4.    var nBoardPosX;
  5.    var nBoardPosY;
  6.    var aLastShape;
  7.    var nScore;
  8.    var nLines;
  9.    var nLevel;
  10.    var nSpeed;
  11.    var bPaused;
  12.    var nAttack;
  13.    var nDelay;
  14.    var bMultiplayer;
  15.    var nStars;
  16.    var nNextShape;
  17.    var nShape;
  18.    var nRotation;
  19.    var nPosX;
  20.    var nPosY;
  21.    var bNotMoved;
  22.    var mcStatsBoard;
  23.    var bGameOver;
  24.    var aBoard;
  25.    var mcBoard;
  26.    var aShapes;
  27.    var mcNextShapeBoard;
  28.    var keyLeft;
  29.    var keyRight;
  30.    var keyMoveDown;
  31.    var keyDrop;
  32.    var keyRotate;
  33.    var nTimerBlockFall;
  34.    var nFillCounter;
  35.    var nTimerFillBoard;
  36.    function Player(param_sName, param_nBoardPosX, param_nBoardPosY)
  37.    {
  38.       this.sName = param_sName;
  39.       this.nBoardPosX = param_nBoardPosX;
  40.       this.nBoardPosY = param_nBoardPosY;
  41.       this.aLastShape = new Array();
  42.       this.nScore = 0;
  43.       this.nLines = 0;
  44.       this.nLevel = 0;
  45.       this.nSpeed = 500;
  46.       this.bPaused = true;
  47.       this.nAttack = 0;
  48.       this.nDelay = 0;
  49.       this.bMultiplayer = false;
  50.       this.nStars = 0;
  51.       this.initShapes();
  52.       this.initBoard();
  53.       this.initNextShapeBoard();
  54.       this.initStatsBoard();
  55.       this.nNextShape = int(Math.random() * 7);
  56.       this.nShape = this.nNextShape;
  57.       this.nRotation = 0;
  58.       this.nPosX = 3;
  59.       this.nPosY = -1;
  60.       this.bNotMoved = true;
  61.       this.drawShape();
  62.       this.drawNextShape();
  63.       this.drawStats();
  64.    }
  65.    function setMultiplayer()
  66.    {
  67.       this.bMultiplayer = true;
  68.       this.mcStatsBoard.StatsBoard.mcStarBoard._visible = true;
  69.    }
  70.    function reinitiateGame()
  71.    {
  72.       this.nScore = 0;
  73.       this.nLines = 0;
  74.       this.nLevel = 0;
  75.       this.nSpeed = 500;
  76.       this.bPaused = true;
  77.       this.nAttack = 0;
  78.       this.nDelay = 0;
  79.       this.bGameOver = false;
  80.       var _loc4_ = 0;
  81.       while(_loc4_ < 18)
  82.       {
  83.          var _loc2_ = 0;
  84.          while(_loc2_ < 10)
  85.          {
  86.             this.aBoard[_loc2_][_loc4_] = 0;
  87.             _loc2_ = _loc2_ + 1;
  88.          }
  89.          _loc4_ = _loc4_ + 1;
  90.       }
  91.       _loc4_ = 0;
  92.       while(_loc4_ < 18)
  93.       {
  94.          _loc2_ = 0;
  95.          while(_loc2_ < 10)
  96.          {
  97.             var _loc3_ = _loc4_ * 10 + _loc2_;
  98.             this.mcBoard[_loc3_]._x = _loc2_ * 20;
  99.             this.mcBoard[_loc3_]._y = _loc4_ * 20;
  100.             this.mcBoard[_loc3_].mcExplosion.gotoAndStop(1);
  101.             _loc2_ = _loc2_ + 1;
  102.          }
  103.          _loc4_ = _loc4_ + 1;
  104.       }
  105.       this.mcBoard.Board.mcBoardBG.mcColones._visible = false;
  106.       this.nNextShape = int(Math.random() * 7);
  107.       this.nShape = this.nNextShape;
  108.       this.nRotation = 0;
  109.       this.nPosX = 3;
  110.       this.nPosY = -1;
  111.       this.bNotMoved = true;
  112.       this.mcBoard.GameoverClip.removeMovieClip();
  113.       this.drawShape();
  114.       this.drawNextShape();
  115.       this.drawStats();
  116.    }
  117.    function initShapes()
  118.    {
  119.       this.aShapes = [];
  120.       var _loc4_ = 0;
  121.       while(_loc4_ < 40)
  122.       {
  123.          this.aShapes[_loc4_] = [];
  124.          var _loc3_ = 0;
  125.          while(_loc3_ < 4)
  126.          {
  127.             this.aShapes[_loc4_][_loc3_] = [];
  128.             var _loc2_ = 0;
  129.             while(_loc2_ < 4)
  130.             {
  131.                this.aShapes[_loc4_][_loc3_][_loc2_] = 0;
  132.                _loc2_ = _loc2_ + 1;
  133.             }
  134.             _loc3_ = _loc3_ + 1;
  135.          }
  136.          _loc4_ = _loc4_ + 1;
  137.       }
  138.       this.aShapes[0][0][1] = 5;
  139.       this.aShapes[0][0][2] = 5;
  140.       this.aShapes[0][1][1] = 5;
  141.       this.aShapes[0][2][1] = 5;
  142.       this.aShapes[1][0][1] = 5;
  143.       this.aShapes[1][1][1] = 5;
  144.       this.aShapes[1][1][2] = 5;
  145.       this.aShapes[1][1][3] = 5;
  146.       this.aShapes[2][2][1] = 5;
  147.       this.aShapes[2][2][2] = 5;
  148.       this.aShapes[2][1][2] = 5;
  149.       this.aShapes[2][0][2] = 5;
  150.       this.aShapes[3][0][1] = 5;
  151.       this.aShapes[3][0][2] = 5;
  152.       this.aShapes[3][0][3] = 5;
  153.       this.aShapes[3][1][3] = 5;
  154.       this.aShapes[4][2][2] = 6;
  155.       this.aShapes[4][2][1] = 6;
  156.       this.aShapes[4][1][1] = 6;
  157.       this.aShapes[4][0][1] = 6;
  158.       this.aShapes[5][1][1] = 6;
  159.       this.aShapes[5][1][2] = 6;
  160.       this.aShapes[5][1][3] = 6;
  161.       this.aShapes[5][0][3] = 6;
  162.       this.aShapes[6][0][2] = 6;
  163.       this.aShapes[6][0][1] = 6;
  164.       this.aShapes[6][1][2] = 6;
  165.       this.aShapes[6][2][2] = 6;
  166.       this.aShapes[7][1][1] = 6;
  167.       this.aShapes[7][0][1] = 6;
  168.       this.aShapes[7][0][2] = 6;
  169.       this.aShapes[7][0][3] = 6;
  170.       this.aShapes[8][1][1] = 2;
  171.       this.aShapes[8][0][2] = 2;
  172.       this.aShapes[8][1][2] = 2;
  173.       this.aShapes[8][2][2] = 2;
  174.       this.aShapes[9][0][1] = 2;
  175.       this.aShapes[9][0][2] = 2;
  176.       this.aShapes[9][1][2] = 2;
  177.       this.aShapes[9][0][3] = 2;
  178.       this.aShapes[10][0][1] = 2;
  179.       this.aShapes[10][1][1] = 2;
  180.       this.aShapes[10][2][1] = 2;
  181.       this.aShapes[10][1][2] = 2;
  182.       this.aShapes[11][1][1] = 2;
  183.       this.aShapes[11][0][2] = 2;
  184.       this.aShapes[11][1][2] = 2;
  185.       this.aShapes[11][1][3] = 2;
  186.       this.aShapes[12][0][1] = 7;
  187.       this.aShapes[12][1][1] = 7;
  188.       this.aShapes[12][2][1] = 7;
  189.       this.aShapes[12][3][1] = 7;
  190.       this.aShapes[13][1][0] = 7;
  191.       this.aShapes[13][1][1] = 7;
  192.       this.aShapes[13][1][2] = 7;
  193.       this.aShapes[13][1][3] = 7;
  194.       this.aShapes[14][0][1] = 7;
  195.       this.aShapes[14][1][1] = 7;
  196.       this.aShapes[14][2][1] = 7;
  197.       this.aShapes[14][3][1] = 7;
  198.       this.aShapes[15][1][0] = 7;
  199.       this.aShapes[15][1][1] = 7;
  200.       this.aShapes[15][1][2] = 7;
  201.       this.aShapes[15][1][3] = 7;
  202.       this.aShapes[16][1][1] = 1;
  203.       this.aShapes[16][2][1] = 1;
  204.       this.aShapes[16][1][2] = 1;
  205.       this.aShapes[16][2][2] = 1;
  206.       this.aShapes[17][1][1] = 1;
  207.       this.aShapes[17][2][1] = 1;
  208.       this.aShapes[17][1][2] = 1;
  209.       this.aShapes[17][2][2] = 1;
  210.       this.aShapes[18][1][1] = 1;
  211.       this.aShapes[18][2][1] = 1;
  212.       this.aShapes[18][1][2] = 1;
  213.       this.aShapes[18][2][2] = 1;
  214.       this.aShapes[19][1][1] = 1;
  215.       this.aShapes[19][2][1] = 1;
  216.       this.aShapes[19][1][2] = 1;
  217.       this.aShapes[19][2][2] = 1;
  218.       this.aShapes[20][0][1] = 3;
  219.       this.aShapes[20][1][1] = 3;
  220.       this.aShapes[20][1][2] = 3;
  221.       this.aShapes[20][2][2] = 3;
  222.       this.aShapes[21][1][1] = 3;
  223.       this.aShapes[21][0][2] = 3;
  224.       this.aShapes[21][1][2] = 3;
  225.       this.aShapes[21][0][3] = 3;
  226.       this.aShapes[22][0][1] = 3;
  227.       this.aShapes[22][1][1] = 3;
  228.       this.aShapes[22][1][2] = 3;
  229.       this.aShapes[22][2][2] = 3;
  230.       this.aShapes[23][1][1] = 3;
  231.       this.aShapes[23][0][2] = 3;
  232.       this.aShapes[23][1][2] = 3;
  233.       this.aShapes[23][0][3] = 3;
  234.       this.aShapes[24][1][1] = 4;
  235.       this.aShapes[24][2][1] = 4;
  236.       this.aShapes[24][0][2] = 4;
  237.       this.aShapes[24][1][2] = 4;
  238.       this.aShapes[25][0][1] = 4;
  239.       this.aShapes[25][0][2] = 4;
  240.       this.aShapes[25][1][2] = 4;
  241.       this.aShapes[25][1][3] = 4;
  242.       this.aShapes[26][1][1] = 4;
  243.       this.aShapes[26][2][1] = 4;
  244.       this.aShapes[26][0][2] = 4;
  245.       this.aShapes[26][1][2] = 4;
  246.       this.aShapes[27][0][1] = 4;
  247.       this.aShapes[27][0][2] = 4;
  248.       this.aShapes[27][1][2] = 4;
  249.       this.aShapes[27][1][3] = 4;
  250.       this.aShapes[28][0][0] = 4;
  251.       this.aShapes[28][1][1] = 4;
  252.       this.aShapes[28][2][2] = 4;
  253.       this.aShapes[28][3][3] = 4;
  254.       this.aShapes[28][3][0] = 4;
  255.       this.aShapes[29][3][0] = 4;
  256.       this.aShapes[29][2][1] = 4;
  257.       this.aShapes[29][1][2] = 4;
  258.       this.aShapes[29][0][3] = 4;
  259.       this.aShapes[29][3][3] = 4;
  260.       this.aShapes[30][0][0] = 4;
  261.       this.aShapes[30][1][1] = 4;
  262.       this.aShapes[30][2][2] = 4;
  263.       this.aShapes[30][3][3] = 4;
  264.       this.aShapes[30][0][3] = 4;
  265.       this.aShapes[31][3][0] = 4;
  266.       this.aShapes[31][2][1] = 4;
  267.       this.aShapes[31][1][2] = 4;
  268.       this.aShapes[31][0][3] = 4;
  269.       this.aShapes[31][0][0] = 4;
  270.       this.aShapes[32][0][0] = 4;
  271.       this.aShapes[32][0][1] = 4;
  272.       this.aShapes[32][0][2] = 4;
  273.       this.aShapes[32][2][0] = 4;
  274.       this.aShapes[32][3][0] = 4;
  275.       this.aShapes[32][3][1] = 4;
  276.       this.aShapes[33][1][0] = 4;
  277.       this.aShapes[33][2][0] = 4;
  278.       this.aShapes[33][3][0] = 4;
  279.       this.aShapes[33][3][2] = 4;
  280.       this.aShapes[33][3][3] = 4;
  281.       this.aShapes[33][2][3] = 4;
  282.       this.aShapes[34][3][1] = 4;
  283.       this.aShapes[34][3][2] = 4;
  284.       this.aShapes[34][3][3] = 4;
  285.       this.aShapes[34][0][2] = 4;
  286.       this.aShapes[34][0][3] = 4;
  287.       this.aShapes[34][1][3] = 4;
  288.       this.aShapes[35][0][0] = 4;
  289.       this.aShapes[35][1][0] = 4;
  290.       this.aShapes[35][0][1] = 4;
  291.       this.aShapes[35][0][3] = 4;
  292.       this.aShapes[35][1][3] = 4;
  293.       this.aShapes[35][2][3] = 4;
  294.       this.aShapes[36][0][0] = 4;
  295.       this.aShapes[36][2][0] = 4;
  296.       this.aShapes[36][3][1] = 4;
  297.       this.aShapes[36][0][2] = 4;
  298.       this.aShapes[36][1][3] = 4;
  299.       this.aShapes[36][3][3] = 4;
  300.       this.aShapes[37][1][0] = 4;
  301.       this.aShapes[37][3][0] = 4;
  302.       this.aShapes[37][0][1] = 4;
  303.       this.aShapes[37][3][2] = 4;
  304.       this.aShapes[37][0][3] = 4;
  305.       this.aShapes[37][2][3] = 4;
  306.       this.aShapes[38][0][0] = 4;
  307.       this.aShapes[38][2][0] = 4;
  308.       this.aShapes[38][3][1] = 4;
  309.       this.aShapes[38][0][2] = 4;
  310.       this.aShapes[38][1][3] = 4;
  311.       this.aShapes[38][3][3] = 4;
  312.       this.aShapes[39][1][0] = 4;
  313.       this.aShapes[39][3][0] = 4;
  314.       this.aShapes[39][0][1] = 4;
  315.       this.aShapes[39][3][2] = 4;
  316.       this.aShapes[39][0][3] = 4;
  317.       this.aShapes[39][2][3] = 4;
  318.    }
  319.    function initBoard()
  320.    {
  321.       this.mcBoard = _root.createEmptyMovieClip(this.sName,_root.getNextHighestDepth());
  322.       this.mcBoard.attachMovie("Board","Board",this.mcBoard.getNextHighestDepth(),{_x:0,_y:0});
  323.       this.mcBoard.Board.TextPlayerName.text = this.sName;
  324.       this.mcBoard.Board.mcBoardBG.mcColones._visible = false;
  325.       this.mcBoard.Board.mcPause._visible = false;
  326.       this.mcBoard._x = this.nBoardPosX;
  327.       this.mcBoard._y = this.nBoardPosY;
  328.       this.aBoard = [];
  329.       var _loc3_ = 0;
  330.       while(_loc3_ < 10)
  331.       {
  332.          this.aBoard[_loc3_] = [];
  333.          var _loc5_ = 0;
  334.          while(_loc5_ < 18)
  335.          {
  336.             this.aBoard[_loc3_][_loc5_] = 0;
  337.             _loc5_ = _loc5_ + 1;
  338.          }
  339.          _loc3_ = _loc3_ + 1;
  340.       }
  341.       _loc5_ = 0;
  342.       while(_loc5_ < 18)
  343.       {
  344.          _loc3_ = 0;
  345.          while(_loc3_ < 10)
  346.          {
  347.             var _loc4_ = _loc5_ * 10 + _loc3_;
  348.             this.mcBoard.attachMovie("Block",_loc4_,this.mcBoard.getNextHighestDepth(),{_x:_loc3_ * 20,_y:_loc5_ * 20});
  349.             this.mcBoard[_loc4_].gotoAndStop(1);
  350.             this.mcBoard[_loc4_].mcExplosion.gotoAndStop(1);
  351.             _loc3_ = _loc3_ + 1;
  352.          }
  353.          _loc5_ = _loc5_ + 1;
  354.       }
  355.    }
  356.    function initNextShapeBoard()
  357.    {
  358.       this.mcNextShapeBoard = _root.createEmptyMovieClip(this.sName + "NextShape",_root.getNextHighestDepth());
  359.       this.mcNextShapeBoard.attachMovie("NextBlockBoard","NextBlockBoard",this.mcNextShapeBoard.getNextHighestDepth(),{_x:0,_y:0});
  360.       this.mcNextShapeBoard._x = this.nBoardPosX + 200 + 10;
  361.       this.mcNextShapeBoard._y = this.nBoardPosY;
  362.       var _loc5_ = 0;
  363.       while(_loc5_ < 4)
  364.       {
  365.          var _loc3_ = 0;
  366.          while(_loc3_ < 4)
  367.          {
  368.             var _loc4_ = _loc5_ * 4 + _loc3_;
  369.             this.mcNextShapeBoard.attachMovie("NextBlockClip",_loc4_,this.mcNextShapeBoard.getNextHighestDepth(),{_x:_loc3_ * 13,_y:_loc5_ * 13});
  370.             this.mcNextShapeBoard[_loc4_].gotoAndStop(1);
  371.             _loc3_ = _loc3_ + 1;
  372.          }
  373.          _loc5_ = _loc5_ + 1;
  374.       }
  375.    }
  376.    function initStatsBoard()
  377.    {
  378.       this.mcStatsBoard = _root.createEmptyMovieClip(this.sName + "Stats",_root.getNextHighestDepth());
  379.       this.mcStatsBoard._x = this.nBoardPosX + 200 + 10;
  380.       this.mcStatsBoard._y = this.nBoardPosY + 61;
  381.       this.mcStatsBoard.attachMovie("StatsBoard","StatsBoard",this.mcStatsBoard.getNextHighestDepth(),{_x:0,_y:0});
  382.       this.mcStatsBoard.StatsBoard.mcStarBoard._visible = false;
  383.       this.mcStatsBoard.StatsBoard.mcStarBoard.mcStar1.gotoAndStop(1);
  384.       this.mcStatsBoard.StatsBoard.mcStarBoard.mcStar1._visible = false;
  385.       this.mcStatsBoard.StatsBoard.mcStarBoard.mcStar2.gotoAndStop(1);
  386.       this.mcStatsBoard.StatsBoard.mcStarBoard.mcStar2._visible = false;
  387.    }
  388.    function setKeys(param_keyLeft, param_keyRight, param_keyDrop, param_keyRotate, param_keyMoveDown)
  389.    {
  390.       this.keyLeft = param_keyLeft;
  391.       this.keyRight = param_keyRight;
  392.       this.keyMoveDown = param_keyMoveDown;
  393.       this.keyDrop = param_keyDrop;
  394.       this.keyRotate = param_keyRotate;
  395.    }
  396.    function startGame()
  397.    {
  398.       if(this.bPaused)
  399.       {
  400.          this.bPaused = false;
  401.          var _loc4_ = 0;
  402.          while(_loc4_ < 18)
  403.          {
  404.             var _loc2_ = 0;
  405.             while(_loc2_ < 10)
  406.             {
  407.                var _loc3_ = _loc4_ * 10 + _loc2_;
  408.                this.mcBoard[_loc3_]._visible = true;
  409.                _loc2_ = _loc2_ + 1;
  410.             }
  411.             _loc4_ = _loc4_ + 1;
  412.          }
  413.          this.mcBoard.Board.mcPause._visible = false;
  414.          this.moveDown();
  415.       }
  416.       clearInterval(this.nTimerBlockFall);
  417.       this.nTimerBlockFall = setInterval(this,"blockFall",this.nSpeed);
  418.    }
  419.    function pauseGame()
  420.    {
  421.       this.bPaused = true;
  422.       clearInterval(this.nTimerBlockFall);
  423.       var _loc4_ = 0;
  424.       while(_loc4_ < 18)
  425.       {
  426.          var _loc2_ = 0;
  427.          while(_loc2_ < 10)
  428.          {
  429.             var _loc3_ = _loc4_ * 10 + _loc2_;
  430.             this.mcBoard[_loc3_]._visible = false;
  431.             _loc2_ = _loc2_ + 1;
  432.          }
  433.          _loc4_ = _loc4_ + 1;
  434.       }
  435.       this.mcBoard.Board.mcPause._visible = true;
  436.       this.mcBoard.Board.mcPause.gotoAndPlay(1);
  437.    }
  438.    function stopGame()
  439.    {
  440.       clearInterval(this.nTimerBlockFall);
  441.    }
  442.    function blockFall()
  443.    {
  444.       if(this.isDelayed())
  445.       {
  446.          return undefined;
  447.       }
  448.       this.moveDown();
  449.       updateAfterEvent();
  450.    }
  451.    function isDelayed()
  452.    {
  453.       if(this.nDelay <= 0)
  454.       {
  455.          return false;
  456.       }
  457.       if(--this.nDelay == 0)
  458.       {
  459.          this.clearFullLines();
  460.       }
  461.       return true;
  462.    }
  463.    function moveLeft()
  464.    {
  465.       if(this.nDelay > 0)
  466.       {
  467.          return undefined;
  468.       }
  469.       if(!this.collision(this.nPosX - 1,this.nPosY,this.nRotation))
  470.       {
  471.          this.nPosX = this.nPosX - 1;
  472.          this.drawShape();
  473.       }
  474.    }
  475.    function moveRight()
  476.    {
  477.       if(this.nDelay > 0)
  478.       {
  479.          return undefined;
  480.       }
  481.       if(!this.collision(this.nPosX + 1,this.nPosY,this.nRotation))
  482.       {
  483.          this.nPosX = this.nPosX + 1;
  484.          this.drawShape();
  485.       }
  486.    }
  487.    function rotate()
  488.    {
  489.       if(this.nDelay > 0)
  490.       {
  491.          return undefined;
  492.       }
  493.       var _loc2_ = this.nRotation + 1;
  494.       if(_loc2_ > 3)
  495.       {
  496.          _loc2_ = 0;
  497.       }
  498.       if(!this.collision(this.nPosX,this.nPosY,_loc2_))
  499.       {
  500.          this.nRotation = _loc2_;
  501.          this.drawShape();
  502.       }
  503.    }
  504.    function dropDown()
  505.    {
  506.       if(this.nDelay > 0)
  507.       {
  508.          return undefined;
  509.       }
  510.       while(true)
  511.       {
  512.          if(this.collision(this.nPosX,this.nPosY + 1,this.nRotation))
  513.          {
  514.             this.drawShape();
  515.             break;
  516.          }
  517.          this.nPosY = this.nPosY + 1;
  518.          this.nScore = this.nScore + 1;
  519.       }
  520.       this.moveDown();
  521.    }
  522.    function moveDown()
  523.    {
  524.       if(this.nDelay > 0)
  525.       {
  526.          return undefined;
  527.       }
  528.       if(!this.collision(this.nPosX,this.nPosY + 1,this.nRotation))
  529.       {
  530.          this.nPosY = this.nPosY + 1;
  531.          this.drawShape();
  532.          this.nScore = this.nScore + 1;
  533.       }
  534.       else
  535.       {
  536.          this.checkLines();
  537.          this.nShape = this.nNextShape;
  538.          this.nRotation = 0;
  539.          this.nPosX = 3;
  540.          this.nPosY = -99;
  541.          var _loc3_ = 0;
  542.          while(_loc3_ < 4)
  543.          {
  544.             var _loc2_ = 0;
  545.             while(_loc2_ < 4)
  546.             {
  547.                if(this.aShapes[this.nShape * 4 + this.nRotation][_loc2_][_loc3_] != 0 && this.nPosY == -99)
  548.                {
  549.                   this.nPosY = - _loc3_;
  550.                }
  551.                _loc2_ = _loc2_ + 1;
  552.             }
  553.             _loc3_ = _loc3_ + 1;
  554.          }
  555.          this.bNotMoved = true;
  556.          this.nNextShape = int(Math.random() * 7);
  557.          this.drawShape();
  558.          this.drawNextShape();
  559.          this.drawStats();
  560.          if(this.collision(this.nPosX,this.nPosY,this.nRotation))
  561.          {
  562.             this.gameOver();
  563.          }
  564.       }
  565.    }
  566.    function collision(param_nPosX, param_nPosY, param_nRotation)
  567.    {
  568.       var _loc5_ = 0;
  569.       while(_loc5_ < 4)
  570.       {
  571.          var _loc2_ = 0;
  572.          while(_loc2_ < 4)
  573.          {
  574.             if(this.aShapes[this.nShape * 4 + param_nRotation][_loc2_][_loc5_] != 0)
  575.             {
  576.                var _loc3_ = _loc2_ + param_nPosX;
  577.                var _loc4_ = _loc5_ + param_nPosY;
  578.                if(_loc3_ < 0 || _loc3_ > 9 || _loc4_ > 17)
  579.                {
  580.                   return true;
  581.                }
  582.                if(this.aBoard[_loc3_][_loc4_] != 0)
  583.                {
  584.                   return true;
  585.                }
  586.             }
  587.             _loc2_ = _loc2_ + 1;
  588.          }
  589.          _loc5_ = _loc5_ + 1;
  590.       }
  591.    }
  592.    function checkLines()
  593.    {
  594.       var _loc3_ = 0;
  595.       while(_loc3_ < 4)
  596.       {
  597.          var _loc2_ = 0;
  598.          while(_loc2_ < 4)
  599.          {
  600.             if(this.aShapes[this.nShape * 4 + this.nRotation][_loc2_][_loc3_] != 0)
  601.             {
  602.                var _loc5_ = _loc2_ + this.nPosX;
  603.                var _loc4_ = _loc3_ + this.nPosY;
  604.                this.aBoard[_loc5_][_loc4_] = this.aShapes[this.nShape * 4 + this.nRotation][_loc2_][_loc3_];
  605.             }
  606.             _loc2_ = _loc2_ + 1;
  607.          }
  608.          _loc3_ = _loc3_ + 1;
  609.       }
  610.       var _loc7_ = 0;
  611.       _loc3_ = 0;
  612.       while(_loc3_ < 18)
  613.       {
  614.          var _loc6_ = false;
  615.          _loc2_ = 0;
  616.          while(_loc2_ < 10)
  617.          {
  618.             if(this.aBoard[_loc2_][_loc3_] == 0)
  619.             {
  620.                _loc6_ = true;
  621.             }
  622.             _loc2_ = _loc2_ + 1;
  623.          }
  624.          if(!_loc6_)
  625.          {
  626.             _loc2_ = 0;
  627.             while(_loc2_ < 10)
  628.             {
  629.                this.mcBoard[_loc3_ * 10 + _loc2_].mcExplosion.gotoAndPlay(2);
  630.                _loc2_ = _loc2_ + 1;
  631.             }
  632.             _loc7_ = _loc7_ + 1;
  633.          }
  634.          _loc3_ = _loc3_ + 1;
  635.       }
  636.       if(_loc7_ > 0)
  637.       {
  638.          switch(_loc7_)
  639.          {
  640.             case 1:
  641.                this.nScore += 40;
  642.                this.nDelay = 1;
  643.                break;
  644.             case 2:
  645.                this.nScore += 100;
  646.                this.nDelay = 1;
  647.                break;
  648.             case 3:
  649.                this.nScore += 300;
  650.                this.nDelay = 1;
  651.                break;
  652.             case 4:
  653.                this.nScore += 1200;
  654.                this.nDelay = 2;
  655.                this.applyBonus();
  656.          }
  657.          this.nAttack = _loc7_;
  658.          this.nLines += _loc7_;
  659.          if(Math.floor(this.nLines / 10) > this.nLevel)
  660.          {
  661.             this.nLevel = Math.floor(this.nLines / 10);
  662.          }
  663.          if(this.nLevel > 9)
  664.          {
  665.             this.nLevel = 9;
  666.          }
  667.          this.ajustSpeed();
  668.          this.startGame();
  669.       }
  670.    }
  671.    function clearFullLines()
  672.    {
  673.       var _loc5_ = 0;
  674.       while(_loc5_ < 18)
  675.       {
  676.          var _loc6_ = false;
  677.          var _loc4_ = 0;
  678.          while(_loc4_ < 10)
  679.          {
  680.             if(this.aBoard[_loc4_][_loc5_] == 0)
  681.             {
  682.                _loc6_ = true;
  683.             }
  684.             _loc4_ = _loc4_ + 1;
  685.          }
  686.          if(!_loc6_)
  687.          {
  688.             var _loc3_ = _loc5_;
  689.             while(_loc3_ >= 0)
  690.             {
  691.                var _loc2_ = 0;
  692.                while(_loc2_ < 10)
  693.                {
  694.                   if(_loc3_ == 0)
  695.                   {
  696.                      this.aBoard[_loc2_][_loc3_] = 0;
  697.                   }
  698.                   else
  699.                   {
  700.                      this.aBoard[_loc2_][_loc3_] = this.aBoard[_loc2_][_loc3_ - 1];
  701.                   }
  702.                   this.mcBoard[_loc3_ * 10 + _loc2_].mcExplosion.gotoAndStop(1);
  703.                   _loc2_ = _loc2_ + 1;
  704.                }
  705.                _loc3_ = _loc3_ - 1;
  706.             }
  707.          }
  708.          _loc5_ = _loc5_ + 1;
  709.       }
  710.       this.fullBoardRedraw();
  711.    }
  712.    function applyAttack(param_nAttack)
  713.    {
  714.       if(param_nAttack == 0)
  715.       {
  716.          return undefined;
  717.       }
  718.       switch(param_nAttack)
  719.       {
  720.          case 2:
  721.             var _loc4_ = 0;
  722.             while(_loc4_ < 17)
  723.             {
  724.                var _loc2_ = 0;
  725.                while(_loc2_ < 10)
  726.                {
  727.                   this.aBoard[_loc2_][_loc4_] = this.aBoard[_loc2_][_loc4_ + 1];
  728.                   _loc2_ = _loc2_ + 1;
  729.                }
  730.                _loc4_ = _loc4_ + 1;
  731.             }
  732.             var _loc5_ = Math.floor(Math.random() * 10);
  733.             _loc2_ = 0;
  734.             while(_loc2_ < 10)
  735.             {
  736.                if(_loc2_ == _loc5_)
  737.                {
  738.                   this.aBoard[_loc2_][17] = 0;
  739.                }
  740.                else
  741.                {
  742.                   this.aBoard[_loc2_][17] = 25;
  743.                }
  744.                _loc2_ = _loc2_ + 1;
  745.             }
  746.             break;
  747.          case 3:
  748.             _loc4_ = 0;
  749.             while(_loc4_ < 16)
  750.             {
  751.                _loc2_ = 0;
  752.                while(_loc2_ < 10)
  753.                {
  754.                   this.aBoard[_loc2_][_loc4_] = this.aBoard[_loc2_][_loc4_ + 2];
  755.                   _loc2_ = _loc2_ + 1;
  756.                }
  757.                _loc4_ = _loc4_ + 1;
  758.             }
  759.             _loc5_ = Math.floor(Math.random() * 10);
  760.             _loc2_ = 0;
  761.             while(_loc2_ < 10)
  762.             {
  763.                _loc4_ = 16;
  764.                while(_loc4_ < 18)
  765.                {
  766.                   if(_loc2_ == _loc5_)
  767.                   {
  768.                      this.aBoard[_loc2_][_loc4_] = 0;
  769.                   }
  770.                   else
  771.                   {
  772.                      this.aBoard[_loc2_][_loc4_] = 25;
  773.                   }
  774.                   _loc4_ = _loc4_ + 1;
  775.                }
  776.                _loc2_ = _loc2_ + 1;
  777.             }
  778.             break;
  779.          case 4:
  780.             this.mcBoard.Board.mcBoardBG.mcColones._visible = false;
  781.             switch(Math.floor(Math.random() * 6))
  782.             {
  783.                case 0:
  784.                   _loc4_ = 0;
  785.                   while(_loc4_ < 15)
  786.                   {
  787.                      _loc2_ = 0;
  788.                      while(_loc2_ < 10)
  789.                      {
  790.                         this.aBoard[_loc2_][_loc4_] = this.aBoard[_loc2_][_loc4_ + 3];
  791.                         _loc2_ = _loc2_ + 1;
  792.                      }
  793.                      _loc4_ = _loc4_ + 1;
  794.                   }
  795.                   _loc5_ = Math.floor(Math.random() * 10);
  796.                   _loc2_ = 0;
  797.                   while(_loc2_ < 10)
  798.                   {
  799.                      _loc4_ = 15;
  800.                      while(_loc4_ < 18)
  801.                      {
  802.                         if(_loc2_ == _loc5_ || Math.floor(Math.random() * 10) > 5)
  803.                         {
  804.                            this.aBoard[_loc2_][_loc4_] = 0;
  805.                         }
  806.                         else
  807.                         {
  808.                            this.aBoard[_loc2_][_loc4_] = 25;
  809.                         }
  810.                         _loc4_ = _loc4_ + 1;
  811.                      }
  812.                      _loc2_ = _loc2_ + 1;
  813.                   }
  814.                   break;
  815.                case 1:
  816.                   this.nNextShape = 7;
  817.                   this.drawNextShapeSurprise();
  818.                   break;
  819.                case 2:
  820.                   this.nNextShape = 8;
  821.                   this.drawNextShapeSurprise();
  822.                   break;
  823.                case 3:
  824.                   this.nNextShape = 9;
  825.                   this.drawNextShapeSurprise();
  826.                   break;
  827.                case 4:
  828.                   _loc4_ = 0;
  829.                   while(_loc4_ < 18)
  830.                   {
  831.                      _loc2_ = 0;
  832.                      while(_loc2_ < 10)
  833.                      {
  834.                         var _loc3_ = _loc4_ * 10 + _loc2_;
  835.                         this.mcBoard[_loc3_]._x = 180 - _loc2_ * 20;
  836.                         this.mcBoard[_loc3_]._y = 340 - _loc4_ * 20;
  837.                         _loc2_ = _loc2_ + 1;
  838.                      }
  839.                      _loc4_ = _loc4_ + 1;
  840.                   }
  841.                   break;
  842.                case 5:
  843.                   _loc4_ = 0;
  844.                   while(_loc4_ < 18)
  845.                   {
  846.                      _loc2_ = 0;
  847.                      while(_loc2_ < 10)
  848.                      {
  849.                         if(_loc2_ % 2)
  850.                         {
  851.                            this.aBoard[_loc2_][_loc4_] = 0;
  852.                         }
  853.                         _loc2_ = _loc2_ + 1;
  854.                      }
  855.                      _loc4_ = _loc4_ + 1;
  856.                   }
  857.             }
  858.       }
  859.       this.fullBoardRedraw();
  860.    }
  861.    function applyBonus()
  862.    {
  863.       var _loc4_ = 0;
  864.       while(_loc4_ < 18)
  865.       {
  866.          var _loc2_ = 0;
  867.          while(_loc2_ < 10)
  868.          {
  869.             var _loc3_ = _loc4_ * 10 + _loc2_;
  870.             this.mcBoard[_loc3_]._x = _loc2_ * 20;
  871.             this.mcBoard[_loc3_]._y = _loc4_ * 20;
  872.             _loc2_ = _loc2_ + 1;
  873.          }
  874.          _loc4_ = _loc4_ + 1;
  875.       }
  876.       this.mcBoard.Board.mcBoardBG.mcColones._visible = true;
  877.       this.fullBoardRedraw();
  878.    }
  879.    function drawShape()
  880.    {
  881.       if(this.bNotMoved)
  882.       {
  883.          this.bNotMoved = false;
  884.       }
  885.       else
  886.       {
  887.          var _loc8_ = this.aLastShape.length;
  888.          var _loc7_ = 0;
  889.          while(_loc7_ < _loc8_)
  890.          {
  891.             this.mcBoard[this.aLastShape[_loc7_]].gotoAndStop(1);
  892.             _loc7_ = _loc7_ + 1;
  893.          }
  894.       }
  895.       this.aLastShape = [];
  896.       _loc7_ = 0;
  897.       var _loc5_ = 0;
  898.       while(_loc5_ < 4)
  899.       {
  900.          var _loc2_ = 0;
  901.          while(_loc2_ < 4)
  902.          {
  903.             var _loc6_ = undefined;
  904.             if((_loc6_ = this.aShapes[this.nShape * 4 + this.nRotation][_loc2_][_loc5_]) != 0)
  905.             {
  906.                var _loc4_ = _loc2_ + this.nPosX;
  907.                var _loc3_ = _loc5_ + this.nPosY;
  908.                this.mcBoard[_loc3_ * 10 + _loc4_].gotoAndStop(_loc6_ + 1);
  909.                this.aLastShape[_loc7_++] = _loc3_ * 10 + _loc4_;
  910.             }
  911.             _loc2_ = _loc2_ + 1;
  912.          }
  913.          _loc5_ = _loc5_ + 1;
  914.       }
  915.    }
  916.    function fullBoardRedraw()
  917.    {
  918.       var _loc3_ = 0;
  919.       while(_loc3_ < 18)
  920.       {
  921.          var _loc2_ = 0;
  922.          while(_loc2_ < 10)
  923.          {
  924.             this.mcBoard[_loc3_ * 10 + _loc2_].gotoAndStop(this.aBoard[_loc2_][_loc3_] + 1);
  925.             _loc2_ = _loc2_ + 1;
  926.          }
  927.          _loc3_ = _loc3_ + 1;
  928.       }
  929.       _loc3_ = 0;
  930.       while(_loc3_ < 4)
  931.       {
  932.          _loc2_ = 0;
  933.          while(_loc2_ < 4)
  934.          {
  935.             var _loc6_ = undefined;
  936.             if((_loc6_ = this.aShapes[this.nShape * 4 + this.nRotation][_loc2_][_loc3_]) != 0)
  937.             {
  938.                var _loc5_ = _loc2_ + this.nPosX;
  939.                var _loc4_ = _loc3_ + this.nPosY;
  940.                this.mcBoard[_loc4_ * 10 + _loc5_].gotoAndStop(_loc6_ + 1);
  941.             }
  942.             _loc2_ = _loc2_ + 1;
  943.          }
  944.          _loc3_ = _loc3_ + 1;
  945.       }
  946.    }
  947.    function drawNextShape()
  948.    {
  949.       var _loc4_ = 0;
  950.       while(_loc4_ < 16)
  951.       {
  952.          this.mcNextShapeBoard[_loc4_].gotoAndStop(1);
  953.          _loc4_ = _loc4_ + 1;
  954.       }
  955.       this.mcNextShapeBoard.NextBlockSurprise.removeMovieClip();
  956.       var _loc5_ = int(Math.random() * 3) * 16 + 2;
  957.       var _loc3_ = 0;
  958.       while(_loc3_ < 4)
  959.       {
  960.          var _loc2_ = 0;
  961.          while(_loc2_ < 4)
  962.          {
  963.             if(this.aShapes[this.nNextShape * 4 + this.nRotation][_loc2_][_loc3_] > 0)
  964.             {
  965.                this.mcNextShapeBoard[_loc3_ * 4 + _loc2_].gotoAndPlay(_loc5_);
  966.             }
  967.             _loc2_ = _loc2_ + 1;
  968.          }
  969.          _loc3_ = _loc3_ + 1;
  970.       }
  971.    }
  972.    function drawNextShapeSurprise()
  973.    {
  974.       var _loc2_ = 0;
  975.       while(_loc2_ < 16)
  976.       {
  977.          this.mcNextShapeBoard[_loc2_].gotoAndStop(1);
  978.          _loc2_ = _loc2_ + 1;
  979.       }
  980.       this.mcNextShapeBoard.attachMovie("NextBlockSurprise","NextBlockSurprise",this.mcBoard.getNextHighestDepth(),{_x:0,_y:0});
  981.       this.mcNextShapeBoard.NextBlockSurprise._x = 13;
  982.       this.mcNextShapeBoard.NextBlockSurprise._y = 6;
  983.    }
  984.    function drawStats()
  985.    {
  986.       this.mcStatsBoard.StatsBoard.TextLevel.text = this.nLevel;
  987.       this.mcStatsBoard.StatsBoard.TextScore.text = this.nScore;
  988.       this.mcStatsBoard.StatsBoard.TextLines.text = this.nLines;
  989.    }
  990.    function gameOver()
  991.    {
  992.       this.bGameOver = true;
  993.       this.stopGame();
  994.       this.nFillCounter = 179;
  995.    }
  996.    function fillBoard()
  997.    {
  998.       var _loc2_ = 0;
  999.       while(_loc2_ < 10)
  1000.       {
  1001.          this.mcBoard[this.nFillCounter--].gotoAndStop(25);
  1002.          _loc2_ = _loc2_ + 1;
  1003.       }
  1004.       if(this.nFillCounter < 0)
  1005.       {
  1006.          clearInterval(this.nTimerFillBoard);
  1007.       }
  1008.       updateAfterEvent();
  1009.    }
  1010.    function gameover()
  1011.    {
  1012.       this.mcBoard.attachMovie("GameoverClip","GameoverClip",this.mcBoard.getNextHighestDepth(),{_x:0,_y:0});
  1013.    }
  1014.    function win()
  1015.    {
  1016.       this.mcBoard.attachMovie("WinClip","GameoverClip",this.mcBoard.getNextHighestDepth(),{_x:0,_y:0});
  1017.       this.nStars = this.nStars + 1;
  1018.       if(this.nStars == 1)
  1019.       {
  1020.          this.mcStatsBoard.StatsBoard.mcStarBoard.mcStar1._visible = true;
  1021.          this.mcStatsBoard.StatsBoard.mcStarBoard.mcStar1.gotoAndPlay(1);
  1022.       }
  1023.       if(this.nStars == 2)
  1024.       {
  1025.          this.mcStatsBoard.StatsBoard.mcStarBoard.mcStar2._visible = true;
  1026.          this.mcStatsBoard.StatsBoard.mcStarBoard.mcStar2.gotoAndPlay(1);
  1027.          this.mcBoard.attachMovie("Trophy anim","Trophy anim",this.mcBoard.getNextHighestDepth(),{_x:56,_y:230});
  1028.       }
  1029.    }
  1030.    function setStars(nNumStars)
  1031.    {
  1032.       this.nStars = nNumStars;
  1033.       if(this.nStars < 0)
  1034.       {
  1035.          this.nStars = 0;
  1036.       }
  1037.       if(this.nStars > 2)
  1038.       {
  1039.          this.nStars = 2;
  1040.       }
  1041.       if(this.nStars >= 1)
  1042.       {
  1043.          this.mcStatsBoard.StatsBoard.mcStarBoard.mcStar1._visible = true;
  1044.          this.mcStatsBoard.StatsBoard.mcStarBoard.mcStar1.gotoAndStop(1);
  1045.       }
  1046.       if(this.nStars >= 2)
  1047.       {
  1048.          this.mcStatsBoard.StatsBoard.mcStarBoard.mcStar2._visible = true;
  1049.          this.mcStatsBoard.StatsBoard.mcStarBoard.mcStar2.gotoAndStop(1);
  1050.       }
  1051.    }
  1052.    function lose()
  1053.    {
  1054.       this.mcBoard.attachMovie("LoseClip","GameoverClip",this.mcBoard.getNextHighestDepth(),{_x:0,_y:0});
  1055.    }
  1056.    function destroy()
  1057.    {
  1058.       this.mcBoard.removeMovieClip();
  1059.       this.mcNextShapeBoard.removeMovieClip();
  1060.       this.mcStatsBoard.removeMovieClip();
  1061.    }
  1062.    function ajustSpeed()
  1063.    {
  1064.       this.nSpeed = 500 - this.nLevel * 40;
  1065.    }
  1066.    function jumpToLevel(param_nLevel)
  1067.    {
  1068.       this.nLevel = param_nLevel;
  1069.       this.ajustSpeed();
  1070.       this.drawStats();
  1071.    }
  1072.    function handicap(param_nHandicap)
  1073.    {
  1074.       var _loc4_ = Math.floor(Math.random() * 10);
  1075.       var _loc3_ = 0;
  1076.       while(_loc3_ < 10)
  1077.       {
  1078.          var _loc2_ = 18 - param_nHandicap * 2;
  1079.          while(_loc2_ < 18)
  1080.          {
  1081.             if(_loc3_ == _loc4_ || Math.floor(Math.random() * 10) > 5)
  1082.             {
  1083.                this.aBoard[_loc3_][_loc2_] = 0;
  1084.             }
  1085.             else
  1086.             {
  1087.                this.aBoard[_loc3_][_loc2_] = 25;
  1088.             }
  1089.             _loc2_ = _loc2_ + 1;
  1090.          }
  1091.          _loc3_ = _loc3_ + 1;
  1092.       }
  1093.       this.fullBoardRedraw();
  1094.    }
  1095.    function test(param_nLignes)
  1096.    {
  1097.       var _loc3_ = 0;
  1098.       while(_loc3_ < 9)
  1099.       {
  1100.          var _loc2_ = 18 - param_nLignes;
  1101.          while(_loc2_ < 18)
  1102.          {
  1103.             this.aBoard[_loc3_][_loc2_] = 25;
  1104.             _loc2_ = _loc2_ + 1;
  1105.          }
  1106.          _loc3_ = _loc3_ + 1;
  1107.       }
  1108.       this.nNextShape = 3;
  1109.    }
  1110. }
  1111.