Exemplo n.º 1
0
    public void createBlock()                                                           //Create the block
    {
        current_block.randomShape();
        current_block.set_CurrentX(1);
        current_block.set_CurrentY((int)constant.BOARD_WIDTH / 2);

        if (!tryMove(current_block, current_block.get_CurrentX(), current_block.get_CurrentY()))
        {
            current_block.setBlockShape(TetrisBlock.Blocks.No_shape);
            started    = false;
            isGameOver = true;
        }
    }
Exemplo n.º 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);
 }