Last active
          October 26, 2017 16:41 
        
      - 
      
- 
        Save rdeioris/37b22e74859796f1986f4513ccfbc9dd to your computer and use it in GitHub Desktop. 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | static void DrawChessboard(int width, int height) | |
| { | |
| // iterate each y | |
| for (int y = 0; y < height; y++) | |
| { | |
| // iterate each x | |
| for (int x = 0; x < width; x++) | |
| { | |
| // on pair y, draw black odd x | |
| if (y % 2 == 0) | |
| { | |
| if (x % 2 == 0) | |
| { | |
| // set white | |
| Console.BackgroundColor = ConsoleColor.White; | |
| } | |
| else | |
| { | |
| // set black | |
| Console.BackgroundColor = ConsoleColor.Black; | |
| } | |
| } | |
| else | |
| { | |
| if (x % 2 == 0) | |
| { | |
| // set black | |
| Console.BackgroundColor = ConsoleColor.Black; | |
| } | |
| else | |
| { | |
| // set white | |
| Console.BackgroundColor = ConsoleColor.White; | |
| } | |
| } | |
| // draw the cell | |
| Console.Write(" "); | |
| } | |
| // end of a line, go below | |
| Console.WriteLine(); | |
| } | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment