Exemplo n.º 1
0
        public GameState()
        {
            this.current = makeTet();
            this.next = makeTet();

            for (int row = 0; row < 21; row++)
            {
                clearLine(row);
            }
        }
Exemplo n.º 2
0
        private void toggleTet(Tetrimino tet)
        {
            // Toggles all checkboxes occupied by the given tetrimino.

            Tetrimino.Cell[,] mask = tet.currentMask();

            for (int row = 0; row < 4; row++)
            {
                for (int col = 0; col < 4; col++)
                {
                    if(mask[row, col] == Tetrimino.Cell.Block)
                    {
                        this.board[row+tet.row, col+tet.col].Checked = !this.board[row+tet.row,col+tet.col].Checked;
                    }
                }
            }
        }
Exemplo n.º 3
0
 public void swapPreview()
 {
     current = next;
     next = makeTet();
 }
Exemplo n.º 4
0
        public Boolean maskCollides(Tetrimino.Cell[,] mask, int rowOffset, int colOffset)
        {
            // Returns true if any cell of the given mask will collide with the background layer
            // or if any cell is outside the boundaries of the board

            for (int row = 0; row < 4; row++)
            {
                for (int col = 0; col < 4; col++)
                {
                    // if the block is present, make sure it's in the game board and not colliding with the background
                    if (mask[row, col] == Tetrimino.Cell.Block &&
                        (rowOffset+row > 20 || rowOffset+row < 0 || colOffset+col > 9 || colOffset+col < 0
                         || background[rowOffset+row, colOffset+col] == Tetrimino.Cell.Block))
                        return true;
                }
            }

            return false;
        }