示例#1
0
 public void addBlockToBoard(TetrisBlock block, int newX, int newY)
 {
     for (int i = 0; i < 4; i++)
     {
         int x = newX + block.get_X(i);
         int y = newY + block.get_Y(i);
         board[x, y] = true;
     }
 }
示例#2
0
 public bool tryMove(TetrisBlock block, int newX, int newY)                          //Check if the block is movable, and then move
 {
     for (int i = 0; i < 4; i++)
     {
         int x = newX + block.get_X(i);
         int y = newY + block.get_Y(i);                                                           //cannot put curBlock on exist blocks
         if (x < 0 || x >= (int)constant.BOARD_HEIGHT || y < 0 || y >= (int)constant.BOARD_WIDTH) //block out of board
         {
             return(false);
         }
         if (board[x, y])
         {
             return(false);
         }
     }
     current_block = block;
     current_block.set_CurrentX(newX);
     current_block.set_CurrentY(newY);
     view.changeView(this);
     return(true);
 }