Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <windows.h>
- //#include "cppcolors.h"
- //nity codeleakers tic tac toe program
- using namespace std;
- string board[7][6] = {{ " ", " A ", "", " B ", "", " C " },
- { "1 ", " ", "|", " ", "|", " " },
- { " ", "___", "|", "___", "|", "___" },
- { "2 ", " ", "|", " ", "|", " " },
- { " ", "___", "|", "___", "|", "___" },
- { "3 ", " ", "|", " ", "|", " " },
- { " ", " ", "|", " ", "|", " " }};
- string playerLetters[3] = { "", " X ", " 0 " };
- bool isPlaying = true;
- void draw_board()
- {
- //colors_t colors;
- system( "CLS" );
- //colors.setfg( white );
- for( int i = 0; i < 7; i++ )
- {
- for( int y = 0; y < 6; y++ )
- {
- if( board[i][y] == playerLetters[1] || board[i][y] == playerLetters[2] )
- {
- //colors.setfg( light_yellow );
- cout << board[i][y];
- }
- else
- {
- //colors.setfg( white );
- cout << board[i][y];
- }
- }
- cout << endl;
- }
- }
- bool singlePlayer()
- {
- int option;
- cout << "1 ) Single Player\n2 ) Multiplayer" << endl << "Option: ";
- cin >> option;
- if( option == 1 )
- return true;
- else if( option == 2 )
- return false;
- else
- exit( 0 );
- }
- int main()
- {
- if( singlePlayer() ) //vs computer
- {
- while( isPlaying )
- {
- draw_board();
- //ask for coordinates
- //checks for a winner
- //ai coordinates
- //checks for a winner
- }
- }
- else
- {
- while( isPlaying )
- {
- draw_board();
- //ask for player 1 coordinates
- //checks for a winner
- //ask for player 2 coordinates
- //checks for a winner
- }
- }
- system( "PAUSE" );
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement