Guest User

Untitled

a guest
Oct 31st, 2011
45
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <string>
  3. #include <windows.h>
  4. //#include "cppcolors.h"
  5. //nity codeleakers tic tac toe program
  6.  
  7. using namespace std;
  8.  
  9. string board[7][6] = {{ "  ", " A  ", "", " B  ", "", " C  " },
  10.                       { "1 ", "   ", "|", "   ", "|", "   " },
  11.                       { "  ", "___", "|", "___", "|", "___" },
  12.                       { "2 ", "   ", "|", "   ", "|", "   " },
  13.                       { "  ", "___", "|", "___", "|", "___" },
  14.                       { "3 ", "   ", "|", "   ", "|", "   " },
  15.                       { "  ", "   ", "|", "   ", "|", "   " }};
  16.                      
  17. string playerLetters[3] = { "", " X ", " 0 " };
  18. bool isPlaying = true;
  19. void draw_board()
  20. {
  21.    //colors_t colors;
  22.    system( "CLS" );
  23.    //colors.setfg( white );
  24.    for( int i = 0; i < 7; i++ )
  25.    {
  26.       for( int y = 0; y < 6; y++ )
  27.       {
  28.          if( board[i][y] == playerLetters[1] || board[i][y] == playerLetters[2] )
  29.          {
  30.             //colors.setfg( light_yellow );
  31.             cout << board[i][y];
  32.          }
  33.          else
  34.          {
  35.             //colors.setfg( white );
  36.             cout << board[i][y];
  37.          }
  38.       }
  39.       cout << endl;
  40.    }    
  41. }
  42.  
  43. bool singlePlayer()
  44. {
  45.    int option;
  46.    cout << "1 ) Single Player\n2 ) Multiplayer" << endl << "Option: ";
  47.    cin >> option;
  48.    if( option == 1 )
  49.       return true;
  50.    else if( option == 2 )
  51.       return false;
  52.    else
  53.       exit( 0 );
  54. }
  55.  
  56. int main()
  57. {
  58.    if( singlePlayer() )           //vs computer
  59.    {
  60.       while( isPlaying )
  61.       {
  62.          draw_board();
  63.          //ask for coordinates
  64.          //checks for a winner
  65.          //ai coordinates
  66.          //checks for a winner  
  67.       }
  68.    }
  69.    else
  70.    {
  71.       while( isPlaying )
  72.       {
  73.          draw_board();
  74.          //ask for player 1 coordinates
  75.          //checks for a winner
  76.          //ask for player 2 coordinates
  77.          //checks for a winner  
  78.       }  
  79.    }
  80.    system( "PAUSE" );
  81.    return 0;  
  82. }
  83.  
  84.  
RAW Paste Data