Пример #1
0
 public void placeBlock(bool[,] listToPlaceBlock, Tetromino blockToPlace)
 {
     for (int i = 0; i < blockToPlace.Pieces.GetLength(0) - blockToPlace.emptyRowsFromBottom(); i++)
     {
         for (int c = 0; c < blockToPlace.Pieces.GetLength(1) - blockToPlace.emptyColumnsFromRight(); c++)
         {
             if (blockToPlace.Pieces[i, c])
             {
                 listToPlaceBlock[blockToPlace.X + c, blockToPlace.Y + i] = blockToPlace.Pieces[i, c];
             }
         }
     }
 }
Пример #2
0
        public void update(GameTime gameTime)
        {
            currentTetromino.update(gameTime, isLeftCollide(), isRightCollide());
            if (currentTetromino.isBlockFallen() || currentTetromino.IsFallen)
            {
                fallenPieces.Add(currentTetromino);
                chooseBlock();
            }
            if (Keyboard.GetState().IsKeyDown(Keys.Up) && currentTetromino.RotateTimer <= 0 && canRotate() && currentTetromino.X + (4 - currentTetromino.emptyColumnsFromRight()) < 10)
            {
                int[] rotateArray = new int[2];
                rotateArray[0] = 1;
                rotateArray[1] = 1;

                currentTetromino.rotate();
                currentTetromino.updateBlock();
                currentTetromino.RotateTimer = 0.5d;
            }
            List <int> lineInfo = searchForLine();

            if (lineInfo[0] != 0)
            {
                for (int i = 1; i < lineInfo.Count; i++)
                {
                    removeLine(lineInfo[i]);
                }
                for (int c = 1; c < lineInfo.Count; c++)
                {
                    moveFallenBlocksDown(lineInfo[c]);
                }
            }
            if (!canRotate() && currentTetromino.Y == 0)
            {
                gameOver = true;
            }
        }