Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "ccc_win.h"
- int ccc_win_main()
- {
- cwin << Line(Point(-1.0, 3.0), Point(-1.0, -3.0));
- cwin << Line(Point(1.0, 3.0), Point(1.0, -3.0));
- cwin << Line(Point(-3.0, 1.0), Point(3.0, 1.0));
- cwin << Line(Point(-3.0, -1.0), Point(3.0, -1.0));
- Point P1;
- int w = 0;
- int x = 0;
- int y = 0;
- int z = 0;
- int row1y = 0;
- int row2y = 0;
- int row3y = 0;
- int row1x = 0;
- int row2x = 0;
- int row3x = 0;
- int col1y = 0;
- int col2y = 0;
- int col3y = 0;
- int col1x = 0;
- int col2x = 0;
- int col3x = 0;
- int diag1y = 0;
- int diag2y = 0;
- int diag1x = 0;
- int diag2x = 0;
- while (z == 0){
- while (x < 9){
- if (y == 0){
- P1 = cwin.get_mouse("It's X's turn to make a move.");
- }
- if (y == 1){
- P1 = cwin.get_mouse("It's O's turn to make a move.");
- }
- if ((P1.get_x() > 1.0 && P1.get_x() < 3.0) && (P1.get_y() > 1.0) && (P1.get_y() < 3.0)){
- if (y == 0){
- cwin << Line(Point(1.0, 1.0), Point(3.0, 3.0));
- cwin << Line(Point(1.0, 3.0), Point(3.0, 1.0));
- x++;
- y++;
- row1x++;
- col1x++;
- diag1x++;
- }
- if (y == 1){
- cwin << Circle(Point(2.0, 2.0), 1);
- x++;
- y--;
- row1y++;
- col1y++;
- diag1y++;
- }
- }
- if ((P1.get_x() > 1.0 && P1.get_x() < 3.0) && (P1.get_y() > -1.0) && (P1.get_y() < 1.0)){
- if (y == 0){
- cwin << Line(Point(1.0, 1.0), Point(3.0, -1.0));
- cwin << Line(Point(1.0, -1.0), Point(3.0, 1.0));
- x++;
- y++;
- row2x++;
- col1x++;
- }
- if (y == 1){
- cwin << Circle(Point(2.0, 0), 1);
- x++;
- y--;
- row2y++;
- col1y++;
- }
- }
- if ((P1.get_x() > 1.0 && P1.get_x() < 3.0) && (P1.get_y() > -3.0) && (P1.get_y() < -1.0)){
- if (y == 0){
- cwin << Line(Point(1.0, -1.0), Point(3.0, -3.0));
- cwin << Line(Point(1.0, -3.0), Point(3.0, -1.0));
- x++;
- y++;
- row3x++;
- col1x++;
- diag2x++;
- }
- if (y == 1){
- cwin << Circle(Point(2.0, -2.0), 1);
- x++;
- y--;
- row3y++;
- col1y++;
- diag2y++;
- }
- }
- if ((P1.get_x() > -1.0 && P1.get_x() < 1.0) && (P1.get_y() > 1.0) && (P1.get_y() < 3.0)){
- if (y == 0){
- cwin << Line(Point(-1.0, 3.0), Point(1.0, 1.0));
- cwin << Line(Point(-1.0, 1.0), Point(1.0, 3.0));
- x++;
- y++;
- row1x++;
- col2x++;
- }
- if (y == 1){
- cwin << Circle(Point(0, 2.0), 1);
- x++;
- y--;
- row1y++;
- col2y++;
- }
- }
- if ((P1.get_x() > -1.0 && P1.get_x() < 1.0) && (P1.get_y() > -1.0) && (P1.get_y() < 1.0)){
- if (y == 0){
- cwin << Line(Point(-1.0, 1.0), Point(1.0, -1.0));
- cwin << Line(Point(-1.0, -1.0), Point(1.0, 1.0));
- x++;
- y++;
- row2x++;
- col2x++;
- diag1x++;
- diag2x++;
- }
- if (y == 1){
- cwin << Circle(Point(0, 0), 1);
- x++;
- y--;
- row2y++;
- col2y++;
- diag1y++;
- diag2y++;
- }
- }
- if ((P1.get_x() > -1.0 && P1.get_x() < 1.0) && (P1.get_y() > -3.0) && (P1.get_y() < -1.0)){
- if (y == 0){
- cwin << Line(Point(-1.0, -1.0), Point(1.0, -3.0));
- cwin << Line(Point(-1.0, -3.0), Point(1.0, -1.0));
- x++;
- y++;
- row3x++;
- col2x++;
- }
- if (y == 1){
- cwin << Circle(Point(0, -2.0), 1);
- x++;
- y--;
- row3y++;
- col2y++;
- }
- }
- if ((P1.get_x() > -3.0 && P1.get_x() < -1.0) && (P1.get_y() > 1.0) && (P1.get_y() < 3.0)){
- if (y == 0){
- cwin << Line(Point(-3.0, 3.0), Point(-1.0, 1.0));
- cwin << Line(Point(-3.0, 1.0), Point(-1.0, 3.0));
- x++;
- y++;
- row1x++;
- col3x++;
- diag2x++;
- }
- if (y == 1){
- cwin << Circle(Point(-2.0, 2.0), 1);
- x++;
- y--;
- row1y++;
- col3y++;
- diag2y++;
- }
- }
- if ((P1.get_x() > -3.0 && P1.get_x() < -1.0) && (P1.get_y() > -1.0) && (P1.get_y() < 1.0)){
- if (y == 0){
- cwin << Line(Point(-3.0, 1.0), Point(-1.0, -1.0));
- cwin << Line(Point(-3.0, -1.0), Point(-1.0, 1.0));
- x++;
- y++;
- row2x++;
- col3x++;
- }
- if (y == 1){
- cwin << Circle(Point(-2.0, 0), 1);
- x++;
- y--;
- row2y++;
- col3y++;
- }
- }
- if ((P1.get_x() > -3.0 && P1.get_x() < -1.0) && (P1.get_y() > -3.0) && (P1.get_y() < -1.0)){
- if (y == 0){
- cwin << Line(Point(-3.0, -1.0), Point(-1.0, -3.0));
- cwin << Line(Point(-3.0, -3.0), Point(-1.0, -1.0));
- x++;
- y++;
- row3x++;
- col3x++;
- diag1x++;
- }
- if (y == 1){
- cwin << Circle(Point(-2.0, -2.0), 1);
- x++;
- y--;
- row3y++;
- col3y++;
- diag1y++;
- }
- }
- if (row1y == 3){
- x = x + 9;
- w--;
- cwin << Line(Point(-4.0, 2.0), Point(4.0, 2.0));
- }
- if (row2y == 3){
- x = x + 9;
- w--;
- cwin << Line(Point(-4.0, 0), Point(4.0, 0));
- }
- if (row3y == 3){
- x = x + 9;
- w--;
- cwin << Line(Point(-4.0, -2.0), Point(4.0, -2.0));
- }
- if (row1x == 3){
- x = x + 9;
- w++;
- cwin << Line(Point(-4.0, 2.0), Point(4.0, 2.0));
- }
- if (row2x == 3){
- x = x + 9;
- w++;
- cwin << Line(Point(-4.0, 0), Point(4.0, 0));
- }
- if (row3x == 3){
- x = x + 9;
- w++;
- cwin << Line(Point(-4.0, -2.0), Point(4.0, -2.0));
- }
- if (col1y == 3){
- x = x + 9;
- w--;
- cwin << Line(Point(2.0, 4.0), Point(2.0, -4.0));
- }
- if (col2y == 3){
- x = x + 9;
- w--;
- cwin << Line(Point(0, 4.0), Point(0, -4.0));
- }
- if (col3y == 3){
- x = x + 9;
- w--;
- cwin << Line(Point(-2.0, 4.0), Point(-2.0, -4.0));
- }
- if (col1x == 3){
- x = x + 9;
- w++;
- cwin << Line(Point(2.0, 4.0), Point(2.0, -4.0));
- }
- if (col2x == 3){
- x = x + 9;
- w++;
- cwin << Line(Point(0, 4.0), Point(0, -4.0));
- }
- if (col3x == 3){
- x = x + 9;
- w++;
- cwin << Line(Point(-2.0, 4.0), Point(-2.0, -4.0));
- }
- if (diag1x == 3){
- x = x + 9;
- w++;
- cwin << Line(Point(-4.0, -4.0), Point(4.0, 4.0));
- }
- if (diag2x == 3){
- x = x + 9;
- w++;
- cwin << Line(Point(-4.0, 4.0), Point(4.0, -4.0));
- }
- if (diag1y == 3){
- x = x + 9;
- w--;
- cwin << Line(Point(-4.0, -4.0), Point(4.0, 4.0));
- }
- if (diag2y == 3){
- x = x + 9;
- w--;
- cwin << Line(Point(-4.0, 4.0), Point(4.0, -4.0));
- }
- }
- if (x >= 9){
- --y;
- string s;
- cwin << Message(Point(-1.0, -4.0), "Game Over");
- cwin << Message(Point(-2.5, -5.5), "Would you like to play again?");
- cwin << Message(Point(-2.0, -6.0), "Type yes or no please.");
- if (w == 1){
- cwin << Message(Point(-0.5, -4.5), "X Wins!");
- }
- if (w == -1){
- cwin << Message(Point(-0.5, -4.5), "O Wins!");
- }
- if (w == 0){
- cwin << Message(Point(-0.6, -4.5), "No Winner");
- }
- s = cwin.get_string(" ");
- if (s == "yes"){
- cwin.clear();
- cwin << Line(Point(-1.0, 3.0), Point(-1.0, -3.0));
- cwin << Line(Point(1.0, 3.0), Point(1.0, -3.0));
- cwin << Line(Point(-3.0, 1.0), Point(3.0, 1.0));
- cwin << Line(Point(-3.0, -1.0), Point(3.0, -1.0));
- x = x - 9;
- }
- if (s == "no"){
- cwin.clear();
- cwin << Message(Point(-2.0, 0), "Thank you for playing!");
- z++;
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement