Ejemplo n.º 1
0
        // hàm đánh cờ
        public bool Chess(Graphics g, int x, int y)
        {
            if ((x % Cells.WIDTH == 0) || (y % Cells.HEIGHT == 0))
            {
                return(false);
            }
            int col = x / Cells.WIDTH;
            int row = y / Cells.HEIGHT;

            if (arrayCells[row, col].Owned != 0)
            {
                return(false);
            }
            switch (turn)
            {
            case 1:
                arrayCells[row, col].Owned = 1;
                board.DrawPawn(g, arrayCells[row, col].Location, MyPaint.solidBlack());
                turn = 2;
                break;

            case 2:
                arrayCells[row, col].Owned = 2;
                board.DrawPawn(g, arrayCells[row, col].Location, MyPaint.solidRed());
                turn = 1;
                break;
            }
            Cells cells = new Cells(arrayCells[row, col].Rows, arrayCells[row, col].Column, arrayCells[row, col].Location, arrayCells[row, col].Owned);

            cacNuocDaDi.Push(cells);
            return(true);
        }
Ejemplo n.º 2
0
 // vẽ các đường dọc, ngang trong bàn cờ (Vẽ Bàn cờ)
 public void DrawBoardGame(Graphics g)
 {
     // vẽ các đường dọc
     for (int i = 0; i <= numberOfColumn; i++)
     {
         g.DrawLine(MyPaint.GetPen(), i * Cells.WIDTH, 0, i * Cells.WIDTH, numberOfRow * Cells.HEIGHT);
     }
     // vẽ đường ngang
     for (int j = 0; j <= numberOfRow; j++)
     {
         g.DrawLine(MyPaint.GetPen(), 0, j * Cells.HEIGHT, numberOfColumn * Cells.WIDTH, j * Cells.HEIGHT);
     }
 }
Ejemplo n.º 3
0
 // vẽ lại các quân cờ - Trường hợp người chơi nhấn vào nút minimum
 public void DrawPawnAgain(Graphics gr)
 {
     foreach (Cells cel in cacNuocDaDi)
     {
         if (cel.Owned == 1)
         {
             board.DrawPawn(gr, cel.Location, MyPaint.solidBlack());
         }
         else if (cel.Owned == 2)
         {
             board.DrawPawn(gr, cel.Location, MyPaint.solidRed());
         }
     }
 }