├── .gitignore ├── ChessGame.cpp ├── LICENSE ├── README.md ├── chess1.jpg └── chess2.jpg /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Compiled Object files 5 | *.slo 6 | *.lo 7 | *.o 8 | *.obj 9 | 10 | # Precompiled Headers 11 | *.gch 12 | *.pch 13 | 14 | # Compiled Dynamic libraries 15 | *.so 16 | *.dylib 17 | *.dll 18 | 19 | # Fortran module files 20 | *.mod 21 | *.smod 22 | 23 | # Compiled Static libraries 24 | *.lai 25 | *.la 26 | *.a 27 | *.lib 28 | 29 | # Executables 30 | *.exe 31 | *.out 32 | *.app 33 | -------------------------------------------------------------------------------- /ChessGame.cpp: -------------------------------------------------------------------------------- 1 | /*File Information 2 | File Name: Chess.cpp 3 | Language: OOP using C++ 4 | 5 | Developed By: Wajahat Karim 6 | Sheeraz Ahmed 7 | 8 | Supervisior: Sir Shahid Razzaq 9 | */ 10 | 11 | 12 | 13 | /*Game Information 14 | Chess Game using OOP in C++ 15 | Y-Axis Label Coordinates (14,1) 16 | X-Axis Label Coordinates (18,24) 17 | Dimension of Each Square/Step = (5 characters) x (3 Line Break) 18 | X-Distance to First Component = 17 Characters 19 | Y-Distance to First Component = 1 Line Break 20 | Coordinates of First Component = (18,1) 21 | Horizontal Distance from One Component to Other = 5 Characters 22 | Vertical Distance from One Component to Other = 3 Line Breaks 23 | Pawn (Soldier) = 1 24 | Knight (Horse) = 2 25 | Bishop (Camel) = 3 26 | Rook (Elephant/Castle) = 4 27 | Queen = 5 28 | King = 6 29 | */ 30 | #include 31 | #include 32 | #include 33 | using namespace std; 34 | enum pieceName {BLANK = 0, PAWN = 1, KNIGHT = 2, BISHOP = 3, ROOK = 4, QUEEN = 5, KING = 7}; 35 | void gotoxy(int x, int y); 36 | void set_data_highlight (int xx, int yy, int pp, bool uh); 37 | void check_and_unhighlight(); 38 | bool end_game_or_not (); 39 | void tell_about_check(int,int); 40 | //Highlighted Steps Data Structure 41 | struct dataHighlight { 42 | int x_coordinate; 43 | int y_coordinate; 44 | int kept_piece; 45 | bool unhighlight_it; 46 | }; 47 | //Game Board Class__________________________________________________ 48 | class CChessBoard { 49 | public: 50 | bool change; //for alternating rows 51 | //0-Orgument Constructor 52 | CChessBoard(){ 53 | change=0; 54 | } 55 | //Green Step 56 | void greenStep(){ 57 | HANDLE hConsole; 58 | hConsole = GetStdHandle(STD_OUTPUT_HANDLE); 59 | SetConsoleTextAttribute(hConsole, 2); //Green Colour Code = 2 60 | for (int i=0; i<5; i++) { 61 | cout<<"\xB0"; 62 | } 63 | } 64 | //Gray Step 65 | void grayStep(){ 66 | HANDLE hConsole; 67 | hConsole = GetStdHandle(STD_OUTPUT_HANDLE); 68 | SetConsoleTextAttribute(hConsole, 8); //Gray Colour Code = 8 69 | for (int i=0; i<5; i++) { 70 | cout<<"\xDB"; 71 | } 72 | } 73 | //Printing Row starting with Green Step 74 | void printRowGreen() { 75 | for (int i=0; i<4; i++) { 76 | greenStep(); 77 | grayStep(); 78 | } 79 | } 80 | //Printing Row starting with Gray Step 81 | void printRowGray() { 82 | for (int i=0; i<4; i++) { 83 | grayStep(); 84 | greenStep(); 85 | } 86 | } 87 | //Printing Whole Board of the Game 88 | void printBoard () { 89 | change=0; 90 | cout<<"\t\t"; 91 | for (int i=0; i<8; i++) { 92 | if(change==0) { 93 | printRowGreen(); cout<<"\n"; cout<<"\t\t"; 94 | printRowGreen(); cout<<"\n"; cout<<"\t\t"; //Print 3 rows of green 95 | printRowGreen(); cout<<"\n"; cout<<"\t\t"; 96 | change=1; 97 | } 98 | else { 99 | printRowGray(); cout<<"\n"; cout<<"\t\t"; 100 | printRowGray(); cout<<"\n"; cout<<"\t\t"; 101 | printRowGray(); cout<<"\n"; cout<<"\t\t"; 102 | change=0; 103 | } 104 | } 105 | } 106 | //Printing X-Axis Label 107 | void PrintX_Label(){ 108 | HANDLE hConsole; 109 | hConsole = GetStdHandle(STD_OUTPUT_HANDLE); 110 | SetConsoleTextAttribute(hConsole, 12); //Red Colour Code = 12 111 | int cnt = 1; 112 | for(int i=18;i<58;i+=5){ 113 | gotoxy(i,24); 114 | cout<=1;i-=3){ 125 | gotoxy(15,i); 126 | cout<>chx; cin>>chy; 367 | coord_x = chx - '0'; coord_y = chy - '0'; 368 | if (gameSquares[coord_x][coord_y].kill_him != whose_turn ) { goto WRONG_PIECE; } 369 | else { 370 | if ( gameSquares[coord_x][coord_y].selectPiece() ) { 371 | gameSquares[coord_x][coord_y].highlightPiece(coord_x,coord_y,gameSquares[coord_x][coord_y].which_piece); 372 | NEW_MOVE: 373 | if (gameSquares[coord_x][coord_y].kill_him == 1) { pieceColor = 15; } 374 | else { pieceColor = 10; } 375 | gotoxy(0,25); 376 | SetConsoleTextAttribute(hConsole, 14); //Yellow Colour Code = 14 377 | cout<<"Where to Move (New Coordinates): "; 378 | gotoxy(33,25); 379 | //cin>>chx; cin>>chy; 380 | chx = getche(); chy = getche(); 381 | X = chx - '0'; 382 | Y = chy - '0'; 383 | if (X==0 && Y==0) { 384 | check_and_unhighlight(); 385 | gameSquares[coord_x][coord_y].printPiece(coord_x,coord_y,pieceColor,gameSquares[coord_x][coord_y].which_piece); 386 | whose_turn = gameSquares[coord_x][coord_y].kill_him; 387 | goto SELECT_PIECE; 388 | } 389 | if (gameSquares[X][Y].is_highlight==1) { 390 | check_and_unhighlight(); 391 | game1.removePiece(X,Y); 392 | if (gameSquares[coord_x][coord_y].which_piece == PAWN && gameSquares[coord_x][coord_y].kill_him == 0 && Y==8) { 393 | if (X==1 || X==8 ) { gameSquares[coord_x][coord_y].which_piece = ROOK; } 394 | else if (X==2 || X==7) { gameSquares[coord_x][coord_y].which_piece = KNIGHT; } 395 | else if (X==3 || X==6) { gameSquares[coord_x][coord_y].which_piece = BISHOP; } 396 | else if (X==4 || X==5) { gameSquares[coord_x][coord_y].which_piece = QUEEN; } 397 | } 398 | if (gameSquares[coord_x][coord_y].which_piece == PAWN && gameSquares[coord_x][coord_y].kill_him == 1 && Y==1) { 399 | if (X==1 || X==8) { gameSquares[coord_x][coord_y].which_piece = ROOK; } 400 | else if (X==2 || X==7) { gameSquares[coord_x][coord_y].which_piece = KNIGHT; } 401 | else if (X==3 || X==6) { gameSquares[coord_x][coord_y].which_piece = BISHOP; } 402 | else if (X==4 || X==5) { gameSquares[coord_x][coord_y].which_piece = QUEEN; } 403 | } 404 | gameSquares[coord_x][coord_y].printPiece(X,Y,pieceColor,gameSquares[coord_x][coord_y].which_piece); 405 | gameSquares[X][Y].setSquare(X,Y,0,0,gameSquares[coord_x][coord_y].which_piece,gameSquares[coord_x][coord_y].kill_him); 406 | game1.removePiece(coord_x,coord_y); 407 | data[X][Y].unhighlight_it = 0; 408 | gotoxy(5,15); 409 | SetConsoleTextAttribute(hConsole, 0); //RED Colour Code = 207 410 | cout<<" "; 411 | tell_about_check(X,Y); 412 | } 413 | else { 414 | gotoxy(0,27); 415 | SetConsoleTextAttribute(hConsole, 12); //Red Colour Code = 12 416 | cout<<"Invalid Move!"; 417 | goto NEW_MOVE; 418 | } 419 | if (whose_turn == 0) { 420 | whose_turn = 1; 421 | gotoxy(0,10); 422 | cout<<"Green to Move!"; 423 | } 424 | else { 425 | whose_turn = 0; 426 | gotoxy(0,10); 427 | cout<<"White to Move!"; 428 | } 429 | gotoxy(0,27); 430 | SetConsoleTextAttribute(hConsole, 0); //Red Colour Code = 12 431 | cout<<" "; 432 | } 433 | else { 434 | WRONG_PIECE: 435 | gotoxy(0,27); 436 | SetConsoleTextAttribute(hConsole, 12); //Red Colour Code = 12 437 | cout<<"Wrong Piece Selected!"; 438 | } 439 | } 440 | if ( end_game_or_not() ) { break; } 441 | if (whose_turn == 0) { 442 | SetConsoleTextAttribute(hConsole, 10); //Green Colour Code = 10 443 | gotoxy(0,10); 444 | cout<<"Green to Move!"; 445 | } 446 | else { 447 | SetConsoleTextAttribute(hConsole, 15); //White Colour Code = 15 448 | gotoxy(0,10); 449 | cout<<"White to Move!"; 450 | } 451 | } 452 | gotoxy(0,25); 453 | cout<<"Game Over!"; 454 | system("Pause"); 455 | } 456 | //gotoxy Function__________________________________________________ 457 | void gotoxy(int x, int y) 458 | { 459 | HANDLE hConsoleOutput; 460 | COORD dwCursorPosition; 461 | cout.flush(); 462 | dwCursorPosition.X = x; 463 | dwCursorPosition.Y = y; 464 | hConsoleOutput = GetStdHandle(STD_OUTPUT_HANDLE); 465 | SetConsoleCursorPosition(hConsoleOutput,dwCursorPosition); 466 | } 467 | //Set Data Function for dataHighlight stru//////cture 468 | void set_data_highlight (int xx, int yy, int pp, bool uh) { 469 | data[xx][yy].x_coordinate = xx; 470 | data[xx][yy].y_coordinate = yy; 471 | data[xx][yy].kept_piece = pp; 472 | data[xx][yy].unhighlight_it = uh; 473 | } 474 | //Check And Unhighlight the Highlighted Steps 475 | void check_and_unhighlight() { 476 | for (int i=1; i<9; i++) { 477 | for (int j=1; j<9; j++) { 478 | if (data[i][j].unhighlight_it == 1) { 479 | gameSquares[i][j].unhighlightStep(i,j); 480 | data[i][j].unhighlight_it = 0; 481 | } 482 | } 483 | } 484 | } 485 | //To Check whether Game is ended or not 486 | bool end_game_or_not () { 487 | int num=0; 488 | for (int i=1; i<9; i++) { 489 | for (int j=1; j<9; j++) { 490 | if (gameSquares[i][j].which_piece == KING) { 491 | num++; 492 | } 493 | } 494 | } 495 | if (num == 2) { 496 | return 0; 497 | } 498 | else return 1; 499 | } 500 | //Tell About the Check 501 | /*void tell_about_check (int xx, int yy) { 502 | if ( gameSquares[xx][yy].which_piece == KING && gameSquares[xx][yy].kill_him == 1 && gameSquares[xx][yy].is_highlight == 1) { 503 | gotoxy(5,15); 504 | HANDLE hConsole; 505 | hConsole = GetStdHandle(STD_OUTPUT_HANDLE); 506 | SetConsoleTextAttribute(hConsole, 207); //RED Colour Code = 207 507 | cout<<"Check"; 508 | } 509 | }*/ 510 | //Highlight Piece Function_________________________________________ 511 | void CPiece::highlightPiece (int cx, int cy, int thisPiece) { 512 | //_____________________PAWN STEPS______________________// 513 | if (thisPiece == PAWN) { 514 | if (gameSquares[cx][cy].kill_him == 0) { //If it is Player's PAWN 515 | if (cy == 2) { //If this is first action of pawn 516 | printPiece(cx,cy,14,PAWN); 517 | for (int i=cy, j=0; j<2; i++, j++) { //j<2 for 2 steps 518 | if (gameSquares[cx][i+1].is_empty==0 && gameSquares[cx][i+1].kill_him==0) { break; } 519 | else if (gameSquares[cx][i+1].is_empty==0 && gameSquares[cx][i+1].kill_him==1) { break; } 520 | else { 521 | pinkHighlightStep(cx,i,PAWN); 522 | gameSquares[cx][i+1].setSquare(cx,i,1,1,BLANK,0); 523 | set_data_highlight(cx,i+1,BLANK,1); 524 | } 525 | } 526 | if (gameSquares[cx+1][cy+1].is_empty==0 && gameSquares[cx+1][cy+1].kill_him==1) { 527 | pinkHighlightStep(cx+1,cy,gameSquares[cx+1][cy+1].which_piece); 528 | gameSquares[cx+1][cy+1].setSquare(cx+1,cy+1,0,1,gameSquares[cx+1][cy+1].which_piece,1); 529 | set_data_highlight(cx+1,cy+1,gameSquares[cx+1][cy+1].which_piece,1); 530 | gameSquares[cx+1][cy+1].printPiece(cx+1,cy+1,11,gameSquares[cx+1][cy+1].which_piece); 531 | //tell_about_check(cx+1,cy+1); 532 | } 533 | if (gameSquares[cx-1][cy+1].is_empty==0 && gameSquares[cx-1][cy+1].kill_him==1) { 534 | pinkHighlightStep(cx-1,cy,gameSquares[cx-1][cy+1].which_piece); 535 | gameSquares[cx-1][cy+1].setSquare(cx-1,cy+1,0,1,gameSquares[cx-1][cy+1].which_piece,1); 536 | set_data_highlight(cx-1,cy+1,gameSquares[cx-1][cy+1].which_piece,1); 537 | gameSquares[cx-1][cy+1].printPiece(cx-1,cy+1,11,gameSquares[cx-1][cy+1].which_piece); 538 | //tell_about_check(cx+1,cy+1); 539 | } 540 | } 541 | else { //Not First Move 542 | printPiece(cx,cy,14,PAWN); 543 | if (gameSquares[cx][cy+1].is_empty==0 && gameSquares[cx][cy+1].kill_him==0) { } 544 | else if (gameSquares[cx][cy+1].is_empty==0 && gameSquares[cx][cy+1].kill_him==1) { } 545 | else { 546 | pinkHighlightStep(cx,cy,BLANK); 547 | gameSquares[cx][cy+1].setSquare(cx,cy+1,1,1,BLANK,0); 548 | set_data_highlight(cx,cy+1,BLANK,1); 549 | } 550 | if (gameSquares[cx+1][cy+1].is_empty==0 && gameSquares[cx+1][cy+1].kill_him==1) { 551 | pinkHighlightStep(cx+1,cy,gameSquares[cx+1][cy+1].which_piece); 552 | gameSquares[cx+1][cy+1].setSquare(cx+1,cy+1,0,1,gameSquares[cx+1][cy+1].which_piece,1); 553 | set_data_highlight(cx+1,cy+1,gameSquares[cx+1][cy+1].which_piece,1); 554 | gameSquares[cx+1][cy+1].printPiece(cx+1,cy+1,11,gameSquares[cx+1][cy+1].which_piece); 555 | } 556 | if (gameSquares[cx-1][cy+1].is_empty==0 && gameSquares[cx-1][cy+1].kill_him==1) { 557 | pinkHighlightStep(cx-1,cy,gameSquares[cx-1][cy+1].which_piece); 558 | gameSquares[cx-1][cy+1].setSquare(cx-1,cy+1,0,1,gameSquares[cx-1][cy+1].which_piece,1); 559 | set_data_highlight(cx-1,cy+1,gameSquares[cx-1][cy+1].which_piece,1); 560 | gameSquares[cx-1][cy+1].printPiece(cx-1,cy+1,11,gameSquares[cx-1][cy+1].which_piece); 561 | } 562 | } 563 | } 564 | 565 | else { //If it is Computer's PAWN 566 | if (cy == 7) { //If this is first action of pawn 567 | printPiece(cx,cy,14,PAWN); 568 | for (int i=cy-1, j=0; j<2; i--, j++) { //j<2 for 2 steps 569 | if (gameSquares[cx][i].is_empty==0 && gameSquares[cx][i].kill_him==0) { break; } 570 | else if (gameSquares[cx][i].is_empty==0 && gameSquares[cx][i].kill_him==1) { break; } 571 | else { 572 | pinkHighlightStep(cx,i-1,PAWN); 573 | gameSquares[cx][i].setSquare(cx,i,1,1,BLANK,0); 574 | set_data_highlight(cx,i,BLANK,1); 575 | } 576 | } 577 | if (gameSquares[cx+1][cy-1].is_empty==0 && gameSquares[cx+1][cy-1].kill_him==0 && cx!=8) { 578 | pinkHighlightStep(cx+1,cy-2,gameSquares[cx+1][cy-1].which_piece); 579 | gameSquares[cx+1][cy-1].setSquare(cx+1,cy-1,0,1,gameSquares[cx+1][cy-1].which_piece,0); 580 | set_data_highlight(cx+1,cy-1,gameSquares[cx+1][cy-1].which_piece,1); 581 | gameSquares[cx+1][cy-1].printPiece(cx+1,cy-1,11,gameSquares[cx+1][cy-1].which_piece); 582 | } 583 | if (gameSquares[cx-1][cy-1].is_empty==0 && gameSquares[cx-1][cy-1].kill_him==0 && cx!=1) { 584 | pinkHighlightStep(cx-1,cy-2,gameSquares[cx-1][cy-1].which_piece); 585 | gameSquares[cx-1][cy-1].setSquare(cx-1,cy-1,0,1,gameSquares[cx-1][cy-1].which_piece,0); 586 | set_data_highlight(cx-1,cy-1,gameSquares[cx-1][cy-1].which_piece,1); 587 | gameSquares[cx-1][cy-1].printPiece(cx-1,cy-1,11,gameSquares[cx-1][cy-1].which_piece); 588 | } 589 | } 590 | else { 591 | printPiece(cx,cy,14,PAWN); 592 | if (gameSquares[cx][cy-1].is_empty==0 && gameSquares[cx][cy-1].kill_him==1) { } 593 | if (gameSquares[cx][cy-1].is_empty==0 && gameSquares[cx][cy-1].kill_him==0) { } 594 | else { 595 | pinkHighlightStep(cx,cy-2,PAWN); 596 | gameSquares[cx][cy-1].setSquare(cx,cy-1,1,1,BLANK,0); 597 | set_data_highlight(cx,cy-1,BLANK,1); 598 | } 599 | if (gameSquares[cx+1][cy-1].is_empty==0 && gameSquares[cx+1][cy-1].kill_him==0 && cx!=8) { 600 | pinkHighlightStep(cx+1,cy-2,gameSquares[cx+1][cy-1].which_piece); 601 | gameSquares[cx+1][cy-1].setSquare(cx+1,cy-1,0,1,gameSquares[cx+1][cy-1].which_piece,gameSquares[cx+1][cy-1].kill_him); 602 | set_data_highlight(cx+1,cy-1,gameSquares[cx+1][cy-1].which_piece,1); 603 | gameSquares[cx+1][cy-1].printPiece(cx+1,cy-1,11,gameSquares[cx+1][cy-1].which_piece); 604 | } 605 | if (gameSquares[cx-1][cy-1].is_empty==0 && gameSquares[cx-1][cy-1].kill_him==0 && cx!=1) { 606 | pinkHighlightStep(cx-1,cy-2,gameSquares[cx-1][cy-1].which_piece); 607 | gameSquares[cx-1][cy-1].setSquare(cx-1,cy-1,0,1,gameSquares[cx-1][cy-1].which_piece,gameSquares[cx+1][cy-1].kill_him); 608 | set_data_highlight(cx-1,cy-1,gameSquares[cx-1][cy-1].which_piece,1); 609 | gameSquares[cx-1][cy-1].printPiece(cx-1,cy-1,11,gameSquares[cx-1][cy-1].which_piece); 610 | } 611 | } 612 | } 613 | } 614 | //_____________________KNIGHT STEPS______________________// 615 | else if (thisPiece == KNIGHT) { 616 | if (gameSquares[cx][cy].kill_him == 0) { 617 | printPiece(cx,cy,14,KNIGHT); 618 | int temp_x; int temp_y; 619 | //First Step (X-1,Y+2) 620 | temp_x = cx - 1; 621 | temp_y = cy + 1; 622 | if (temp_x < 1 || temp_x > 8 || temp_y < 0 || temp_y >= 8) { } 623 | else { 624 | if (gameSquares[temp_x][temp_y+1].is_empty==0 && gameSquares[temp_x][temp_y+1].kill_him==0) { } 625 | else if (gameSquares[temp_x][temp_y+1].is_empty==0 && gameSquares[temp_x][temp_y+1].kill_him==1) { 626 | pinkHighlightStep(temp_x,temp_y,gameSquares[temp_x][temp_y+1].which_piece); 627 | gameSquares[temp_x][temp_y+1].setSquare(temp_x,temp_y+1,0,1,gameSquares[temp_x][temp_y+1].which_piece,1); 628 | set_data_highlight(temp_x,temp_y+1,gameSquares[temp_x][temp_y+1].which_piece,1); 629 | gameSquares[temp_x][temp_y+1].printPiece(temp_x,temp_y+1,11,gameSquares[temp_x][temp_y+1].which_piece); 630 | } 631 | else { 632 | pinkHighlightStep(temp_x,temp_y,BLANK); 633 | gameSquares[temp_x][temp_y+1].setSquare(temp_x,temp_y+1,1,1,BLANK,0); 634 | set_data_highlight(temp_x,temp_y+1,BLANK,1); 635 | } 636 | } 637 | //Second Step (X-1,Y-2) 638 | temp_x = cx - 1; 639 | temp_y = cy - 3; 640 | if (temp_x < 1 || temp_x > 8 || temp_y < 0 || temp_y >= 8) { } 641 | else { 642 | if (gameSquares[temp_x][temp_y+1].is_empty==0 && gameSquares[temp_x][temp_y+1].kill_him==0 ) { } 643 | else if (gameSquares[temp_x][temp_y+1].is_empty==0 && gameSquares[temp_x][temp_y+1].kill_him==1) { 644 | pinkHighlightStep(temp_x,temp_y,gameSquares[temp_x][temp_y+1].which_piece); 645 | gameSquares[temp_x][temp_y+1].setSquare(temp_x,temp_y+1,0,1,gameSquares[temp_x][temp_y+1].which_piece,1); 646 | set_data_highlight(temp_x,temp_y+1,gameSquares[temp_x][temp_y+1].which_piece,1); 647 | gameSquares[temp_x][temp_y+1].printPiece(temp_x,temp_y+1,11,gameSquares[temp_x][temp_y+1].which_piece); 648 | } 649 | else { 650 | pinkHighlightStep(temp_x,temp_y,BLANK); 651 | gameSquares[temp_x][temp_y+1].setSquare(temp_x,temp_y+1,1,1,BLANK,0); 652 | set_data_highlight(temp_x,temp_y+1,BLANK,1); 653 | } 654 | } 655 | //Third Step (X+1,Y+2) 656 | temp_x = cx + 1; 657 | temp_y = cy + 1; 658 | if (temp_x < 1 || temp_x > 8 || temp_y < 0 || temp_y >= 8) { } 659 | else { 660 | if (gameSquares[temp_x][temp_y+1].is_empty==0 && gameSquares[temp_x][temp_y+1].kill_him==0) { } 661 | else if (gameSquares[temp_x][temp_y+1].is_empty==0 && gameSquares[temp_x][temp_y+1].kill_him==1) { 662 | pinkHighlightStep(temp_x,temp_y,gameSquares[temp_x][temp_y+1].which_piece); 663 | gameSquares[temp_x][temp_y+1].setSquare(temp_x,temp_y+1,0,1,gameSquares[temp_x][temp_y+1].which_piece,1); 664 | set_data_highlight(temp_x,temp_y+1,gameSquares[temp_x][temp_y+1].which_piece,1); 665 | gameSquares[temp_x][temp_y+1].printPiece(temp_x,temp_y+1,11,gameSquares[temp_x][temp_y+1].which_piece); 666 | } 667 | else { 668 | pinkHighlightStep(temp_x,temp_y,BLANK); 669 | gameSquares[temp_x][temp_y+1].setSquare(temp_x,temp_y+1,1,1,BLANK,0); 670 | set_data_highlight(temp_x,temp_y+1,BLANK,1); 671 | } 672 | } 673 | //Fourth Step (X+1,Y-2) 674 | temp_x = cx + 1; 675 | temp_y = cy - 3; 676 | if (temp_x < 1 || temp_x > 8 || temp_y < 0 || temp_y >= 8) { } 677 | else { 678 | if (gameSquares[temp_x][temp_y+1].is_empty==0 && gameSquares[temp_x][temp_y+1].kill_him==0) { } 679 | else if (gameSquares[temp_x][temp_y+1].is_empty==0 && gameSquares[temp_x][temp_y+1].kill_him==1) { 680 | pinkHighlightStep(temp_x,temp_y,gameSquares[temp_x][temp_y+1].which_piece); 681 | gameSquares[temp_x][temp_y+1].setSquare(temp_x,temp_y+1,0,1,gameSquares[temp_x][temp_y+1].which_piece,1); 682 | set_data_highlight(temp_x,temp_y+1,gameSquares[temp_x][temp_y+1].which_piece,1); 683 | gameSquares[temp_x][temp_y+1].printPiece(temp_x,temp_y+1,11,gameSquares[temp_x][temp_y+1].which_piece); 684 | } 685 | else { 686 | pinkHighlightStep(temp_x,temp_y,BLANK); 687 | gameSquares[temp_x][temp_y+1].setSquare(temp_x,temp_y+1,1,1,BLANK,0); 688 | set_data_highlight(temp_x,temp_y+1,BLANK,1); 689 | } 690 | } 691 | //Fifth Step (X-2,Y-1) 692 | temp_x = cx - 2; 693 | temp_y = cy - 2; 694 | if (temp_x < 1 || temp_x > 8 || temp_y < 0 || temp_y >= 8) { } 695 | else { 696 | if (gameSquares[temp_x][temp_y+1].is_empty==0 && gameSquares[temp_x][temp_y+1].kill_him==0) { } 697 | else if (gameSquares[temp_x][temp_y+1].is_empty==0 && gameSquares[temp_x][temp_y+1].kill_him==1) { 698 | pinkHighlightStep(temp_x,temp_y,gameSquares[temp_x][temp_y+1].which_piece); 699 | gameSquares[temp_x][temp_y+1].setSquare(temp_x,temp_y+1,0,1,gameSquares[temp_x][temp_y+1].which_piece,1); 700 | set_data_highlight(temp_x,temp_y+1,gameSquares[temp_x][temp_y+1].which_piece,1); 701 | gameSquares[temp_x][temp_y+1].printPiece(temp_x,temp_y+1,11,gameSquares[temp_x][temp_y+1].which_piece); 702 | } 703 | else { 704 | pinkHighlightStep(temp_x,temp_y,BLANK); 705 | gameSquares[temp_x][temp_y+1].setSquare(temp_x,temp_y+1,1,1,BLANK,0); 706 | set_data_highlight(temp_x,temp_y+1,BLANK,1); 707 | } 708 | } 709 | //Sixth Step (X-2,Y+1) 710 | temp_x = cx - 2; 711 | temp_y = cy + 0; 712 | if (temp_x < 1 || temp_x > 8 || temp_y < 0 || temp_y >= 8) { } 713 | else { 714 | if (gameSquares[temp_x][temp_y+1].is_empty==0 && gameSquares[temp_x][temp_y+1].kill_him==0) { } 715 | else if (gameSquares[temp_x][temp_y+1].is_empty==0 && gameSquares[temp_x][temp_y+1].kill_him==1) { 716 | pinkHighlightStep(temp_x,temp_y,gameSquares[temp_x][temp_y+1].which_piece); 717 | gameSquares[temp_x][temp_y+1].setSquare(temp_x,temp_y+1,0,1,gameSquares[temp_x][temp_y+1].which_piece,1); 718 | set_data_highlight(temp_x,temp_y+1,gameSquares[temp_x][temp_y+1].which_piece,1); 719 | gameSquares[temp_x][temp_y+1].printPiece(temp_x,temp_y+1,11,gameSquares[temp_x][temp_y+1].which_piece); 720 | } 721 | else { 722 | pinkHighlightStep(temp_x,temp_y,BLANK); 723 | gameSquares[temp_x][temp_y+1].setSquare(temp_x,temp_y+1,1,1,BLANK,0); 724 | set_data_highlight(temp_x,temp_y+1,BLANK,1); 725 | } 726 | } 727 | //Seventh Step (X+2,Y-1) 728 | temp_x = cx + 2; 729 | temp_y = cy - 2; 730 | if (temp_x < 1 || temp_x > 8 || temp_y < 0 || temp_y >= 8) { } 731 | else { 732 | if (gameSquares[temp_x][temp_y+1].is_empty==0 && gameSquares[temp_x][temp_y+1].kill_him==0) { } 733 | else if (gameSquares[temp_x][temp_y+1].is_empty==0 && gameSquares[temp_x][temp_y+1].kill_him==1) { 734 | pinkHighlightStep(temp_x,temp_y,gameSquares[temp_x][temp_y+1].which_piece); 735 | gameSquares[temp_x][temp_y+1].setSquare(temp_x,temp_y+1,0,1,gameSquares[temp_x][temp_y+1].which_piece,1); 736 | set_data_highlight(temp_x,temp_y+1,gameSquares[temp_x][temp_y+1].which_piece,1); 737 | gameSquares[temp_x][temp_y+1].printPiece(temp_x,temp_y+1,11,gameSquares[temp_x][temp_y+1].which_piece); 738 | } 739 | else { 740 | pinkHighlightStep(temp_x,temp_y,BLANK); 741 | gameSquares[temp_x][temp_y+1].setSquare(temp_x,temp_y+1,1,1,BLANK,0); 742 | set_data_highlight(temp_x,temp_y+1,BLANK,1); 743 | } 744 | } 745 | //Eighth Step (X+2,Y+1) 746 | temp_x = cx + 2; 747 | temp_y = cy + 0; 748 | if (temp_x < 1 || temp_x > 8 || temp_y < 0 || temp_y >= 8) { } 749 | else { 750 | if (gameSquares[temp_x][temp_y+1].is_empty==0 && gameSquares[temp_x][temp_y+1].kill_him==0) { } 751 | else if (gameSquares[temp_x][temp_y+1].is_empty==0 && gameSquares[temp_x][temp_y+1].kill_him==1) { 752 | pinkHighlightStep(temp_x,temp_y,gameSquares[temp_x][temp_y+1].which_piece); 753 | gameSquares[temp_x][temp_y+1].setSquare(temp_x,temp_y+1,0,1,gameSquares[temp_x][temp_y+1].which_piece,1); 754 | set_data_highlight(temp_x,temp_y+1,gameSquares[temp_x][temp_y+1].which_piece,1); 755 | gameSquares[temp_x][temp_y+1].printPiece(temp_x,temp_y+1,11,gameSquares[temp_x][temp_y+1].which_piece); 756 | } 757 | else { 758 | pinkHighlightStep(temp_x,temp_y,BLANK); 759 | gameSquares[temp_x][temp_y+1].setSquare(temp_x,temp_y+1,1,1,BLANK,0); 760 | set_data_highlight(temp_x,temp_y+1,BLANK,1); 761 | } 762 | } 763 | } 764 | else { 765 | printPiece(cx,cy,14,KNIGHT); 766 | int temp_x; int temp_y; 767 | //First Step (X-1,Y+2) 768 | temp_x = cx - 1; 769 | temp_y = cy + 1; 770 | if (temp_x < 1 || temp_x > 8 || temp_y < 0 || temp_y >= 8) { } 771 | else { 772 | if (gameSquares[temp_x][temp_y+1].is_empty==0 && gameSquares[temp_x][temp_y+1].kill_him==1) { } 773 | else if (gameSquares[temp_x][temp_y+1].is_empty==0 && gameSquares[temp_x][temp_y+1].kill_him==0) { 774 | pinkHighlightStep(temp_x,temp_y,gameSquares[temp_x][temp_y+1].which_piece); 775 | gameSquares[temp_x][temp_y+1].setSquare(temp_x,temp_y+1,0,1,gameSquares[temp_x][temp_y+1].which_piece,gameSquares[temp_x][temp_y+1].kill_him); 776 | set_data_highlight(temp_x,temp_y+1,gameSquares[temp_x][temp_y+1].which_piece,1); 777 | gameSquares[temp_x][temp_y+1].printPiece(temp_x,temp_y+1,11,gameSquares[temp_x][temp_y+1].which_piece); 778 | } 779 | else { 780 | pinkHighlightStep(temp_x,temp_y,BLANK); 781 | gameSquares[temp_x][temp_y+1].setSquare(temp_x,temp_y+1,1,1,BLANK,0); 782 | set_data_highlight(temp_x,temp_y+1,BLANK,1); 783 | } 784 | } 785 | //Second Step (X-1,Y-2) 786 | temp_x = cx - 1; 787 | temp_y = cy - 3; 788 | if (temp_x < 1 || temp_x > 8 || temp_y < 0 || temp_y >= 8) { } 789 | else { 790 | if (gameSquares[temp_x][temp_y+1].is_empty==0 && gameSquares[temp_x][temp_y+1].kill_him==1 ) { } 791 | else if (gameSquares[temp_x][temp_y+1].is_empty==0 && gameSquares[temp_x][temp_y+1].kill_him==0) { 792 | pinkHighlightStep(temp_x,temp_y,gameSquares[temp_x][temp_y+1].which_piece); 793 | gameSquares[temp_x][temp_y+1].setSquare(temp_x,temp_y+1,0,1,gameSquares[temp_x][temp_y+1].which_piece,gameSquares[temp_x][temp_y+1].kill_him); 794 | set_data_highlight(temp_x,temp_y+1,gameSquares[temp_x][temp_y+1].which_piece,1); 795 | gameSquares[temp_x][temp_y+1].printPiece(temp_x,temp_y+1,11,gameSquares[temp_x][temp_y+1].which_piece); 796 | } 797 | else { 798 | pinkHighlightStep(temp_x,temp_y,BLANK); 799 | gameSquares[temp_x][temp_y+1].setSquare(temp_x,temp_y+1,1,1,BLANK,0); 800 | set_data_highlight(temp_x,temp_y+1,BLANK,1); 801 | } 802 | } 803 | //Third Step (X+1,Y+2) 804 | temp_x = cx + 1; 805 | temp_y = cy + 1; 806 | if (temp_x < 1 || temp_x > 8 || temp_y < 0 || temp_y >= 8) { } 807 | else { 808 | if (gameSquares[temp_x][temp_y+1].is_empty==0 && gameSquares[temp_x][temp_y+1].kill_him==1) { } 809 | else if (gameSquares[temp_x][temp_y+1].is_empty==0 && gameSquares[temp_x][temp_y+1].kill_him==0) { 810 | pinkHighlightStep(temp_x,temp_y,gameSquares[temp_x][temp_y+1].which_piece); 811 | gameSquares[temp_x][temp_y+1].setSquare(temp_x,temp_y+1,0,1,gameSquares[temp_x][temp_y+1].which_piece,gameSquares[temp_x][temp_y+1].kill_him); 812 | set_data_highlight(temp_x,temp_y+1,gameSquares[temp_x][temp_y+1].which_piece,1); 813 | gameSquares[temp_x][temp_y+1].printPiece(temp_x,temp_y+1,11,gameSquares[temp_x][temp_y+1].which_piece); 814 | } 815 | else { 816 | pinkHighlightStep(temp_x,temp_y,BLANK); 817 | gameSquares[temp_x][temp_y+1].setSquare(temp_x,temp_y+1,1,1,BLANK,0); 818 | set_data_highlight(temp_x,temp_y+1,BLANK,1); 819 | } 820 | } 821 | //Fourth Step (X+1,Y-2) 822 | temp_x = cx + 1; 823 | temp_y = cy - 3; 824 | if (temp_x < 1 || temp_x > 8 || temp_y < 0 || temp_y >= 8) { } 825 | else { 826 | if (gameSquares[temp_x][temp_y+1].is_empty==0 && gameSquares[temp_x][temp_y+1].kill_him==1) { } 827 | else if (gameSquares[temp_x][temp_y+1].is_empty==0 && gameSquares[temp_x][temp_y+1].kill_him==0) { 828 | pinkHighlightStep(temp_x,temp_y,gameSquares[temp_x][temp_y+1].which_piece); 829 | gameSquares[temp_x][temp_y+1].setSquare(temp_x,temp_y+1,0,1,gameSquares[temp_x][temp_y+1].which_piece,gameSquares[temp_x][temp_y+1].kill_him); 830 | set_data_highlight(temp_x,temp_y+1,gameSquares[temp_x][temp_y+1].which_piece,1); 831 | gameSquares[temp_x][temp_y+1].printPiece(temp_x,temp_y+1,11,gameSquares[temp_x][temp_y+1].which_piece); 832 | } 833 | else { 834 | pinkHighlightStep(temp_x,temp_y,BLANK); 835 | gameSquares[temp_x][temp_y+1].setSquare(temp_x,temp_y+1,1,1,BLANK,0); 836 | set_data_highlight(temp_x,temp_y+1,BLANK,1); 837 | } 838 | } 839 | //Fifth Step (X-2,Y-1) 840 | temp_x = cx - 2; 841 | temp_y = cy - 2; 842 | if (temp_x < 1 || temp_x > 8 || temp_y < 0 || temp_y >= 8) { } 843 | else { 844 | if (gameSquares[temp_x][temp_y+1].is_empty==0 && gameSquares[temp_x][temp_y+1].kill_him==1) { } 845 | else if (gameSquares[temp_x][temp_y+1].is_empty==0 && gameSquares[temp_x][temp_y+1].kill_him==0) { 846 | pinkHighlightStep(temp_x,temp_y,gameSquares[temp_x][temp_y+1].which_piece); 847 | gameSquares[temp_x][temp_y+1].setSquare(temp_x,temp_y+1,0,1,gameSquares[temp_x][temp_y+1].which_piece,gameSquares[temp_x][temp_y+1].kill_him); 848 | set_data_highlight(temp_x,temp_y+1,gameSquares[temp_x][temp_y+1].which_piece,1); 849 | gameSquares[temp_x][temp_y+1].printPiece(temp_x,temp_y+1,11,gameSquares[temp_x][temp_y+1].which_piece); 850 | } 851 | else { 852 | pinkHighlightStep(temp_x,temp_y,BLANK); 853 | gameSquares[temp_x][temp_y+1].setSquare(temp_x,temp_y+1,1,1,BLANK,0); 854 | set_data_highlight(temp_x,temp_y+1,BLANK,1); 855 | } 856 | } 857 | //Sixth Step (X-2,Y+1) 858 | temp_x = cx - 2; 859 | temp_y = cy + 0; 860 | if (temp_x < 1 || temp_x > 8 || temp_y < 0 || temp_y >= 8) { } 861 | else { 862 | if (gameSquares[temp_x][temp_y+1].is_empty==0 && gameSquares[temp_x][temp_y+1].kill_him==1) { } 863 | else if (gameSquares[temp_x][temp_y+1].is_empty==0 && gameSquares[temp_x][temp_y+1].kill_him==0) { 864 | pinkHighlightStep(temp_x,temp_y,gameSquares[temp_x][temp_y+1].which_piece); 865 | gameSquares[temp_x][temp_y+1].setSquare(temp_x,temp_y+1,0,1,gameSquares[temp_x][temp_y+1].which_piece,gameSquares[temp_x][temp_y+1].kill_him); 866 | set_data_highlight(temp_x,temp_y+1,gameSquares[temp_x][temp_y+1].which_piece,1); 867 | gameSquares[temp_x][temp_y+1].printPiece(temp_x,temp_y+1,11,gameSquares[temp_x][temp_y+1].which_piece); 868 | } 869 | else { 870 | pinkHighlightStep(temp_x,temp_y,BLANK); 871 | gameSquares[temp_x][temp_y+1].setSquare(temp_x,temp_y+1,1,1,BLANK,0); 872 | set_data_highlight(temp_x,temp_y+1,BLANK,1); 873 | } 874 | } 875 | //Seventh Step (X+2,Y-1) 876 | temp_x = cx + 2; 877 | temp_y = cy - 2; 878 | if (temp_x < 1 || temp_x > 8 || temp_y < 0 || temp_y >= 8) { } 879 | else { 880 | if (gameSquares[temp_x][temp_y+1].is_empty==0 && gameSquares[temp_x][temp_y+1].kill_him==1) { } 881 | else if (gameSquares[temp_x][temp_y+1].is_empty==0 && gameSquares[temp_x][temp_y+1].kill_him==0) { 882 | pinkHighlightStep(temp_x,temp_y,gameSquares[temp_x][temp_y+1].which_piece); 883 | gameSquares[temp_x][temp_y+1].setSquare(temp_x,temp_y+1,0,1,gameSquares[temp_x][temp_y+1].which_piece,gameSquares[temp_x][temp_y+1].kill_him); 884 | set_data_highlight(temp_x,temp_y+1,gameSquares[temp_x][temp_y+1].which_piece,1); 885 | gameSquares[temp_x][temp_y+1].printPiece(temp_x,temp_y+1,11,gameSquares[temp_x][temp_y+1].which_piece); 886 | } 887 | else { 888 | pinkHighlightStep(temp_x,temp_y,BLANK); 889 | gameSquares[temp_x][temp_y+1].setSquare(temp_x,temp_y+1,1,1,BLANK,0); 890 | set_data_highlight(temp_x,temp_y+1,BLANK,1); 891 | } 892 | } 893 | //Eighth Step (X+2,Y+1) 894 | temp_x = cx + 2; 895 | temp_y = cy + 0; 896 | if (temp_x < 1 || temp_x > 8 || temp_y < 0 || temp_y >= 8) { } 897 | else { 898 | if (gameSquares[temp_x][temp_y+1].is_empty==0 && gameSquares[temp_x][temp_y+1].kill_him==1) { } 899 | else if (gameSquares[temp_x][temp_y+1].is_empty==0 && gameSquares[temp_x][temp_y+1].kill_him==0) { 900 | pinkHighlightStep(temp_x,temp_y,gameSquares[temp_x][temp_y+1].which_piece); 901 | gameSquares[temp_x][temp_y+1].setSquare(temp_x,temp_y+1,0,1,gameSquares[temp_x][temp_y+1].which_piece,gameSquares[temp_x][temp_y+1].kill_him); 902 | set_data_highlight(temp_x,temp_y+1,gameSquares[temp_x][temp_y+1].which_piece,1); 903 | gameSquares[temp_x][temp_y+1].printPiece(temp_x,temp_y+1,11,gameSquares[temp_x][temp_y+1].which_piece); 904 | } 905 | else { 906 | pinkHighlightStep(temp_x,temp_y,BLANK); 907 | gameSquares[temp_x][temp_y+1].setSquare(temp_x,temp_y+1,1,1,BLANK,0); 908 | set_data_highlight(temp_x,temp_y+1,BLANK,1); 909 | } 910 | } 911 | } 912 | } 913 | //_____________________BISHOP STEPS______________________// 914 | else if (thisPiece == BISHOP) { 915 | if (gameSquares[cx][cy].kill_him == 0) { 916 | printPiece(cx,cy,14,BISHOP); 917 | int temp_x, temp_y; 918 | //1st Quadrant (+ve x , +ve y) 919 | temp_x = cx; temp_y = cy; 920 | if (temp_x >= 8 || temp_y >= 8) { } 921 | else { 922 | for (int i=cx+1, j=cy; /**/ ; i++, j++) { 923 | if (i > 8 || j >= 8) { break; } 924 | if (gameSquares[i][j+1].is_empty==0 && gameSquares[i][j+1].kill_him==0) { break; } 925 | if (gameSquares[i][j+1].is_empty==0 && gameSquares[i][j+1].kill_him==1) { 926 | pinkHighlightStep(i,j,gameSquares[i][j+1].which_piece); 927 | gameSquares[i][j+1].setSquare(i,j+1,0,1,gameSquares[i][j+1].which_piece,gameSquares[i][j+1].kill_him); 928 | set_data_highlight(i,j+1,gameSquares[i][j+1].which_piece,1); 929 | gameSquares[i][j+1].printPiece(i,j+1,11,gameSquares[i][j+1].which_piece); 930 | break; 931 | } 932 | pinkHighlightStep(i,j,BLANK); 933 | gameSquares[i][j+1].setSquare(i,j+1,1,1,BLANK,0); 934 | set_data_highlight(i,j+1,BLANK,1); 935 | } 936 | } 937 | //2nd Quadrant (x -ve , y +ve) 938 | if (temp_x < 1 || temp_y >= 8) { } 939 | else { 940 | for (int i=cx-1, j=cy; /**/ ; i--, j++) { 941 | if (i < 1 || j > 7) { break; } 942 | if (gameSquares[i][j+1].is_empty==0 && gameSquares[i][j+1].kill_him==0) { break; } 943 | if (gameSquares[i][j+1].is_empty==0 && gameSquares[i][j+1].kill_him==1) { 944 | pinkHighlightStep(i,j,gameSquares[i][j+1].which_piece); 945 | gameSquares[i][j+1].setSquare(i,j+1,0,1,gameSquares[i][j+1].which_piece,gameSquares[i][j+1].kill_him); 946 | set_data_highlight(i,j+1,gameSquares[i][j+1].which_piece,1); 947 | gameSquares[i][j+1].printPiece(i,j+1,11,gameSquares[i][j+1].which_piece); 948 | break; 949 | } 950 | pinkHighlightStep(i,j,BLANK); 951 | gameSquares[i][j+1].setSquare(i,j+1,1,1,BLANK,0); 952 | set_data_highlight(i,j+1,BLANK,1); 953 | } 954 | } 955 | //3rd Quadrant (x -ve , y -ve) 956 | if (temp_x < 1 || temp_y < 1) { } 957 | else { 958 | for (int i=cx-1, j=cy-2; /**/ ; i--, j--) { 959 | if (i <= 0 || j < 0) { break; } 960 | if (gameSquares[i][j+1].is_empty==0 && gameSquares[i][j+1].kill_him==0) { break; } 961 | if (gameSquares[i][j+1].is_empty==0 && gameSquares[i][j+1].kill_him==1) { 962 | pinkHighlightStep(i,j,gameSquares[i][j+1].which_piece); 963 | gameSquares[i][j+1].setSquare(i,j+1,0,1,gameSquares[i][j+1].which_piece,gameSquares[i][j+1].kill_him); 964 | set_data_highlight(i,j+1,gameSquares[i][j+1].which_piece,1); 965 | gameSquares[i][j+1].printPiece(i,j+1,11,gameSquares[i][j+1].which_piece); 966 | break; 967 | } 968 | pinkHighlightStep(i,j,BLANK); 969 | gameSquares[i][j+1].setSquare(i,j+1,1,1,BLANK,0); 970 | set_data_highlight(i,j+1,BLANK,1); 971 | } 972 | } 973 | //4th Quadrant (x +ve , y -ve) 974 | if (temp_x >= 8 || temp_y < 1) { } 975 | else { 976 | for (int i=cx+1, j=cy-2; /**/ ; i++, j--) { 977 | if (i > 8 || j < 0) { break; } 978 | if (gameSquares[i][j+1].is_empty==0 && gameSquares[i][j+1].kill_him==0) { break; } 979 | if (gameSquares[i][j+1].is_empty==0 && gameSquares[i][j+1].kill_him==1) { 980 | pinkHighlightStep(i,j,gameSquares[i][j+1].which_piece); 981 | gameSquares[i][j+1].setSquare(i,j+1,0,1,gameSquares[i][j+1].which_piece,gameSquares[i][j+1].kill_him); 982 | set_data_highlight(i,j+1,gameSquares[i][j+1].which_piece,1); 983 | gameSquares[i][j+1].printPiece(i,j+1,11,gameSquares[i][j+1].which_piece); 984 | break; 985 | } 986 | pinkHighlightStep(i,j,BLANK); 987 | gameSquares[i][j+1].setSquare(i,j+1,1,1,BLANK,0); 988 | set_data_highlight(i,j+1,BLANK,1); 989 | } 990 | } 991 | } 992 | else { //COMPUTER STEPS 993 | printPiece(cx,cy,14,BISHOP); 994 | int temp_x, temp_y; 995 | //1st Quadrant (+ve x , +ve y) 996 | temp_x = cx; temp_y = cy; 997 | if (temp_x >= 8 || temp_y >= 8) { } 998 | else { 999 | for (int i=cx+1, j=cy; /**/ ; i++, j++) { 1000 | if (i > 8 || j >= 8) { break; } 1001 | if (gameSquares[i][j+1].is_empty==0 && gameSquares[i][j+1].kill_him==1) { break; } 1002 | if (gameSquares[i][j+1].is_empty==0 && gameSquares[i][j+1].kill_him==0) { 1003 | pinkHighlightStep(i,j,gameSquares[i][j+1].which_piece); 1004 | gameSquares[i][j+1].setSquare(i,j+1,0,1,gameSquares[i][j+1].which_piece,gameSquares[i][j+1].kill_him); 1005 | set_data_highlight(i,j+1,gameSquares[i][j+1].which_piece,1); 1006 | gameSquares[i][j+1].printPiece(i,j+1,11,gameSquares[i][j+1].which_piece); 1007 | break; 1008 | } 1009 | pinkHighlightStep(i,j,BLANK); 1010 | gameSquares[i][j+1].setSquare(i,j+1,1,1,BLANK,0); 1011 | set_data_highlight(i,j+1,BLANK,1); 1012 | } 1013 | } 1014 | //2nd Quadrant (x -ve , y +ve) 1015 | if (temp_x < 1 || temp_y >= 8) { } 1016 | else { 1017 | for (int i=cx-1, j=cy; /**/ ; i--, j++) { 1018 | if (i < 1 || j > 7) { break; } 1019 | if (gameSquares[i][j+1].is_empty==0 && gameSquares[i][j+1].kill_him==1) { break; } 1020 | if (gameSquares[i][j+1].is_empty==0 && gameSquares[i][j+1].kill_him==0) { 1021 | pinkHighlightStep(i,j,gameSquares[i][j+1].which_piece); 1022 | gameSquares[i][j+1].setSquare(i,j+1,0,1,gameSquares[i][j+1].which_piece,gameSquares[i][j+1].kill_him); 1023 | set_data_highlight(i,j+1,gameSquares[i][j+1].which_piece,1); 1024 | gameSquares[i][j+1].printPiece(i,j+1,11,gameSquares[i][j+1].which_piece); 1025 | break; 1026 | } 1027 | pinkHighlightStep(i,j,BLANK); 1028 | gameSquares[i][j+1].setSquare(i,j+1,1,1,BLANK,0); 1029 | set_data_highlight(i,j+1,BLANK,1); 1030 | } 1031 | } 1032 | //3rd Quadrant (x -ve , y -ve) 1033 | if (temp_x < 1 || temp_y < 1) { } 1034 | else { 1035 | for (int i=cx-1, j=cy-2; /**/ ; i--, j--) { 1036 | if (i <= 0 || j < 0) { break; } 1037 | if (gameSquares[i][j+1].is_empty==0 && gameSquares[i][j+1].kill_him==1) { break; } 1038 | if (gameSquares[i][j+1].is_empty==0 && gameSquares[i][j+1].kill_him==0) { 1039 | pinkHighlightStep(i,j,gameSquares[i][j+1].which_piece); 1040 | gameSquares[i][j+1].setSquare(i,j+1,0,1,gameSquares[i][j+1].which_piece,gameSquares[i][j+1].kill_him); 1041 | set_data_highlight(i,j+1,gameSquares[i][j+1].which_piece,1); 1042 | gameSquares[i][j+1].printPiece(i,j+1,11,gameSquares[i][j+1].which_piece); 1043 | break; 1044 | } 1045 | pinkHighlightStep(i,j,BLANK); 1046 | gameSquares[i][j+1].setSquare(i,j+1,1,1,BLANK,0); 1047 | set_data_highlight(i,j+1,BLANK,1); 1048 | } 1049 | } 1050 | //4th Quadrant (x +ve , y -ve) 1051 | if (temp_x >= 8 || temp_y < 1) { } 1052 | else { 1053 | for (int i=cx+1, j=cy-2; /**/ ; i++, j--) { 1054 | if (i > 8 || j < 0) { break; } 1055 | if (gameSquares[i][j+1].is_empty==0 && gameSquares[i][j+1].kill_him==1) { break; } 1056 | if (gameSquares[i][j+1].is_empty==0 && gameSquares[i][j+1].kill_him==0) { 1057 | pinkHighlightStep(i,j,gameSquares[i][j+1].which_piece); 1058 | gameSquares[i][j+1].setSquare(i,j+1,0,1,gameSquares[i][j+1].which_piece,gameSquares[i][j+1].kill_him); 1059 | set_data_highlight(i,j+1,gameSquares[i][j+1].which_piece,1); 1060 | gameSquares[i][j+1].printPiece(i,j+1,11,gameSquares[i][j+1].which_piece); 1061 | break; 1062 | } 1063 | pinkHighlightStep(i,j,BLANK); 1064 | gameSquares[i][j+1].setSquare(i,j+1,1,1,BLANK,0); 1065 | set_data_highlight(i,j+1,BLANK,1); 1066 | } 1067 | } 1068 | } 1069 | } 1070 | //_____________________ROOK STEPS______________________// 1071 | else if (thisPiece == ROOK) 1072 | { 1073 | if (gameSquares[cx][cy].kill_him == 0) { 1074 | printPiece(cx,cy,14,ROOK); 1075 | int temp_x, temp_y; 1076 | //1st loop Increasing x, Constanat y 1077 | temp_x = cx; temp_y = cy-1; 1078 | if ( temp_x >= 8 ) { } 1079 | else { 1080 | for (int i=cx+1; /**/ ; i++) { 1081 | if (i > 8) { break; } 1082 | if (gameSquares[i][temp_y+1].is_empty==0 && gameSquares[i][temp_y+1].kill_him==0) { break; } 1083 | if (gameSquares[i][temp_y+1].is_empty==0 && gameSquares[i][temp_y+1].kill_him==1) { 1084 | pinkHighlightStep(i,temp_y,gameSquares[i][temp_y+1].which_piece); 1085 | gameSquares[i][temp_y+1].setSquare(i,temp_y+1,0,1,gameSquares[i][temp_y+1].which_piece,gameSquares[i][temp_y+1].kill_him); 1086 | set_data_highlight(i,temp_y+1,gameSquares[i][temp_y+1].which_piece,1); 1087 | gameSquares[i][temp_y+1].printPiece(i,temp_y+1,11,gameSquares[i][temp_y+1].which_piece); 1088 | break; 1089 | } 1090 | pinkHighlightStep(i,temp_y,BLANK); 1091 | gameSquares[i][temp_y+1].setSquare(i,temp_y+1,1,1,BLANK,0); 1092 | set_data_highlight(i,temp_y+1,BLANK,1); 1093 | } 1094 | } 1095 | //2nd loop Decreasing x, Constanat y 1096 | temp_x = cx; temp_y = cy-1; 1097 | if ( temp_x < 1 ) { } 1098 | else { 1099 | for (int i=cx-1; /**/ ; i--) { 1100 | if (i < 1) { break; } 1101 | if (gameSquares[i][temp_y+1].is_empty==0 && gameSquares[i][temp_y+1].kill_him==0) { break; } 1102 | if (gameSquares[i][temp_y+1].is_empty==0 && gameSquares[i][temp_y+1].kill_him==1) { 1103 | pinkHighlightStep(i,temp_y,gameSquares[i][temp_y+1].which_piece); 1104 | gameSquares[i][temp_y+1].setSquare(i,temp_y+1,0,1,gameSquares[i][temp_y+1].which_piece,gameSquares[i][temp_y+1].kill_him); 1105 | set_data_highlight(i,temp_y+1,gameSquares[i][temp_y+1].which_piece,1); 1106 | gameSquares[i][temp_y+1].printPiece(i,temp_y+1,11,gameSquares[i][temp_y+1].which_piece); 1107 | break; 1108 | } 1109 | pinkHighlightStep(i,temp_y,BLANK); 1110 | gameSquares[i][temp_y+1].setSquare(i,temp_y+1,1,1,BLANK,0); 1111 | set_data_highlight(i,temp_y+1,BLANK,1); 1112 | } 1113 | } 1114 | //3rd loop Constant x, Increasing y 1115 | temp_x = cx; temp_y = cy; 1116 | if ( temp_y >= 8 ) { } 1117 | else { 1118 | for (int i=cy; /**/ ; i++) { 1119 | if (i >= 8) { break; } 1120 | if (gameSquares[temp_x][i+1].is_empty==0 && gameSquares[temp_x][i+1].kill_him==0) { break; } 1121 | if (gameSquares[temp_x][i+1].is_empty==0 && gameSquares[temp_x][i+1].kill_him==1) { 1122 | pinkHighlightStep(temp_x,i,gameSquares[temp_x][i+1].which_piece); 1123 | gameSquares[temp_x][i+1].setSquare(temp_x,i+1,0,1,gameSquares[temp_x][i+1].which_piece,gameSquares[temp_x][i+1].kill_him); 1124 | set_data_highlight(temp_x,i+1,gameSquares[temp_x][i+1].which_piece,1); 1125 | gameSquares[temp_x][i+1].printPiece(temp_x,i+1,11,gameSquares[temp_x][i+1].which_piece); 1126 | break; 1127 | } 1128 | pinkHighlightStep(temp_x,i,BLANK); 1129 | gameSquares[temp_x][i+1].setSquare(temp_x,i+1,1,1,BLANK,0); 1130 | set_data_highlight(temp_x,i+1,BLANK,1); 1131 | } 1132 | } 1133 | //4th loop Constant x, Decreasing y 1134 | temp_x = cx; temp_y = cy; 1135 | if ( temp_y < 0 ) { } 1136 | else { 1137 | for (int i=cy-2; /**/ ; i--) { 1138 | if (i < 0) { break; } 1139 | if (gameSquares[temp_x][i+1].is_empty==0 && gameSquares[temp_x][i+1].kill_him==0) { break; } 1140 | if (gameSquares[temp_x][i+1].is_empty==0 && gameSquares[temp_x][i+1].kill_him==1) { 1141 | pinkHighlightStep(temp_x,i,gameSquares[temp_x][i+1].which_piece); 1142 | gameSquares[temp_x][i+1].setSquare(temp_x,i+1,0,1,gameSquares[temp_x][i+1].which_piece,gameSquares[temp_x][i+1].kill_him); 1143 | set_data_highlight(temp_x,i+1,gameSquares[temp_x][i+1].which_piece,1); 1144 | gameSquares[temp_x][i+1].printPiece(temp_x,i+1,11,gameSquares[temp_x][i+1].which_piece); 1145 | break; 1146 | } 1147 | pinkHighlightStep(temp_x,i,BLANK); 1148 | gameSquares[temp_x][i+1].setSquare(temp_x,i+1,1,1,BLANK,0); 1149 | set_data_highlight(temp_x,i+1,BLANK,1); 1150 | } 1151 | } 1152 | } 1153 | else { //COMPUTER STEPS 1154 | printPiece(cx,cy,14,ROOK); 1155 | int temp_x, temp_y; 1156 | //1st loop Increasing x, Constanat y 1157 | temp_x = cx; temp_y = cy-1; 1158 | if ( temp_x >= 8 ) { } 1159 | else { 1160 | for (int i=cx+1; /**/ ; i++) { 1161 | if (i > 8) { break; } 1162 | if (gameSquares[i][temp_y+1].is_empty==0 && gameSquares[i][temp_y+1].kill_him==1) { break; } 1163 | if (gameSquares[i][temp_y+1].is_empty==0 && gameSquares[i][temp_y+1].kill_him==0) { 1164 | pinkHighlightStep(i,temp_y,gameSquares[i][temp_y+1].which_piece); 1165 | gameSquares[i][temp_y+1].setSquare(i,temp_y+1,0,1,gameSquares[i][temp_y+1].which_piece,gameSquares[i][temp_y+1].kill_him); 1166 | set_data_highlight(i,temp_y+1,gameSquares[i][temp_y+1].which_piece,1); 1167 | gameSquares[i][temp_y+1].printPiece(i,temp_y+1,11,gameSquares[i][temp_y+1].which_piece); 1168 | break; 1169 | } 1170 | pinkHighlightStep(i,temp_y,BLANK); 1171 | gameSquares[i][temp_y+1].setSquare(i,temp_y+1,1,1,BLANK,0); 1172 | set_data_highlight(i,temp_y+1,BLANK,1); 1173 | } 1174 | } 1175 | //2nd loop Decreasing x, Constanat y 1176 | temp_x = cx; temp_y = cy-1; 1177 | if ( temp_x < 1 ) { } 1178 | else { 1179 | for (int i=cx-1; /**/ ; i--) { 1180 | if (i < 1) { break; } 1181 | if (gameSquares[i][temp_y+1].is_empty==0 && gameSquares[i][temp_y+1].kill_him==1) { break; } 1182 | if (gameSquares[i][temp_y+1].is_empty==0 && gameSquares[i][temp_y+1].kill_him==0) { 1183 | pinkHighlightStep(i,temp_y,gameSquares[i][temp_y+1].which_piece); 1184 | gameSquares[i][temp_y+1].setSquare(i,temp_y+1,0,1,gameSquares[i][temp_y+1].which_piece,gameSquares[i][temp_y+1].kill_him); 1185 | set_data_highlight(i,temp_y+1,gameSquares[i][temp_y+1].which_piece,1); 1186 | gameSquares[i][temp_y+1].printPiece(i,temp_y+1,11,gameSquares[i][temp_y+1].which_piece); 1187 | break; 1188 | } 1189 | pinkHighlightStep(i,temp_y,BLANK); 1190 | gameSquares[i][temp_y+1].setSquare(i,temp_y+1,1,1,BLANK,0); 1191 | set_data_highlight(i,temp_y+1,BLANK,1); 1192 | } 1193 | } 1194 | //3rd loop Constant x, Increasing y 1195 | temp_x = cx; temp_y = cy; 1196 | if ( temp_y >= 8 ) { } 1197 | else { 1198 | for (int i=cy; /**/ ; i++) { 1199 | if (i >= 8) { break; } 1200 | if (gameSquares[temp_x][i+1].is_empty==0 && gameSquares[temp_x][i+1].kill_him==1) { break; } 1201 | if (gameSquares[temp_x][i+1].is_empty==0 && gameSquares[temp_x][i+1].kill_him==0) { 1202 | pinkHighlightStep(temp_x,i,gameSquares[temp_x][i+1].which_piece); 1203 | gameSquares[temp_x][i+1].setSquare(temp_x,i+1,0,1,gameSquares[temp_x][i+1].which_piece,gameSquares[temp_x][i+1].kill_him); 1204 | set_data_highlight(temp_x,i+1,gameSquares[temp_x][i+1].which_piece,1); 1205 | gameSquares[temp_x][i+1].printPiece(temp_x,i+1,11,gameSquares[temp_x][i+1].which_piece); 1206 | break; 1207 | } 1208 | pinkHighlightStep(temp_x,i,BLANK); 1209 | gameSquares[temp_x][i+1].setSquare(temp_x,i+1,1,1,BLANK,0); 1210 | set_data_highlight(temp_x,i+1,BLANK,1); 1211 | } 1212 | } 1213 | //4th loop Constant x, Decreasing y 1214 | temp_x = cx; temp_y = cy; 1215 | if ( temp_y < 0 ) { } 1216 | else { 1217 | for (int i=cy-2; /**/ ; i--) { 1218 | if (i < 0) { break; } 1219 | if (gameSquares[temp_x][i+1].is_empty==0 && gameSquares[temp_x][i+1].kill_him==1) { break; } 1220 | if (gameSquares[temp_x][i+1].is_empty==0 && gameSquares[temp_x][i+1].kill_him==0) { 1221 | pinkHighlightStep(temp_x,i,gameSquares[temp_x][i+1].which_piece); 1222 | gameSquares[temp_x][i+1].setSquare(temp_x,i+1,0,1,gameSquares[temp_x][i+1].which_piece,gameSquares[temp_x][i+1].kill_him); 1223 | set_data_highlight(temp_x,i+1,gameSquares[temp_x][i+1].which_piece,1); 1224 | gameSquares[temp_x][i+1].printPiece(temp_x,i+1,11,gameSquares[temp_x][i+1].which_piece); 1225 | break; 1226 | } 1227 | pinkHighlightStep(temp_x,i,BLANK); 1228 | gameSquares[temp_x][i+1].setSquare(temp_x,i+1,1,1,BLANK,0); 1229 | set_data_highlight(temp_x,i+1,BLANK,1); 1230 | } 1231 | } 1232 | } 1233 | } 1234 | //___________________QUEEN STEPS______________________// 1235 | else if (thisPiece == QUEEN) { 1236 | if (gameSquares[cx][cy].kill_him == 0) { 1237 | printPiece(cx,cy,14,QUEEN); 1238 | int temp_x, temp_y; 1239 | //1st Quadrant (+ve x , +ve y) 1240 | temp_x = cx; temp_y = cy; 1241 | if (temp_x >= 8 || temp_y >= 8) { } 1242 | else { 1243 | for (int i=cx+1, j=cy; /**/ ; i++, j++) { 1244 | if (i > 8 || j >= 8) { break; } 1245 | if (gameSquares[i][j+1].is_empty==0 && gameSquares[i][j+1].kill_him==0) { break; } 1246 | if (gameSquares[i][j+1].is_empty==0 && gameSquares[i][j+1].kill_him==1) { 1247 | pinkHighlightStep(i,j,gameSquares[i][j+1].which_piece); 1248 | gameSquares[i][j+1].setSquare(i,j+1,0,1,gameSquares[i][j+1].which_piece,gameSquares[i][j+1].kill_him); 1249 | set_data_highlight(i,j+1,gameSquares[i][j+1].which_piece,1); 1250 | gameSquares[i][j+1].printPiece(i,j+1,11,gameSquares[i][j+1].which_piece); 1251 | break; 1252 | } 1253 | pinkHighlightStep(i,j,BLANK); 1254 | gameSquares[i][j+1].setSquare(i,j+1,1,1,BLANK,0); 1255 | set_data_highlight(i,j+1,BLANK,1); 1256 | } 1257 | } 1258 | //2nd Quadrant (x -ve , y +ve) 1259 | if (temp_x < 1 || temp_y >= 8) { } 1260 | else { 1261 | for (int i=cx-1, j=cy; /**/ ; i--, j++) { 1262 | if (i < 1 || j > 7) { break; } 1263 | if (gameSquares[i][j+1].is_empty==0 && gameSquares[i][j+1].kill_him==0) { break; } 1264 | if (gameSquares[i][j+1].is_empty==0 && gameSquares[i][j+1].kill_him==1) { 1265 | pinkHighlightStep(i,j,gameSquares[i][j+1].which_piece); 1266 | gameSquares[i][j+1].setSquare(i,j+1,0,1,gameSquares[i][j+1].which_piece,gameSquares[i][j+1].kill_him); 1267 | set_data_highlight(i,j+1,gameSquares[i][j+1].which_piece,1); 1268 | gameSquares[i][j+1].printPiece(i,j+1,11,gameSquares[i][j+1].which_piece); 1269 | break; 1270 | } 1271 | pinkHighlightStep(i,j,BLANK); 1272 | gameSquares[i][j+1].setSquare(i,j+1,1,1,BLANK,0); 1273 | set_data_highlight(i,j+1,BLANK,1); 1274 | } 1275 | } 1276 | //3rd Quadrant (x -ve , y -ve) 1277 | if (temp_x < 1 || temp_y < 1) { } 1278 | else { 1279 | for (int i=cx-1, j=cy-2; /**/ ; i--, j--) { 1280 | if (i <= 0 || j < 0) { break; } 1281 | if (gameSquares[i][j+1].is_empty==0 && gameSquares[i][j+1].kill_him==0) { break; } 1282 | if (gameSquares[i][j+1].is_empty==0 && gameSquares[i][j+1].kill_him==1) { 1283 | pinkHighlightStep(i,j,gameSquares[i][j+1].which_piece); 1284 | gameSquares[i][j+1].setSquare(i,j+1,0,1,gameSquares[i][j+1].which_piece,gameSquares[i][j+1].kill_him); 1285 | set_data_highlight(i,j+1,gameSquares[i][j+1].which_piece,1); 1286 | gameSquares[i][j+1].printPiece(i,j+1,11,gameSquares[i][j+1].which_piece); 1287 | break; 1288 | } 1289 | pinkHighlightStep(i,j,BLANK); 1290 | gameSquares[i][j+1].setSquare(i,j+1,1,1,BLANK,0); 1291 | set_data_highlight(i,j+1,BLANK,1); 1292 | } 1293 | } 1294 | //4th Quadrant (x +ve , y -ve) 1295 | if (temp_x >= 8 || temp_y < 1) { } 1296 | else { 1297 | for (int i=cx+1, j=cy-2; /**/ ; i++, j--) { 1298 | if (i > 8 || j < 0) { break; } 1299 | if (gameSquares[i][j+1].is_empty==0 && gameSquares[i][j+1].kill_him==0) { break; } 1300 | if (gameSquares[i][j+1].is_empty==0 && gameSquares[i][j+1].kill_him==1) { 1301 | pinkHighlightStep(i,j,gameSquares[i][j+1].which_piece); 1302 | gameSquares[i][j+1].setSquare(i,j+1,0,1,gameSquares[i][j+1].which_piece,gameSquares[i][j+1].kill_him); 1303 | set_data_highlight(i,j+1,gameSquares[i][j+1].which_piece,1); 1304 | gameSquares[i][j+1].printPiece(i,j+1,11,gameSquares[i][j+1].which_piece); 1305 | break; 1306 | } 1307 | pinkHighlightStep(i,j,BLANK); 1308 | gameSquares[i][j+1].setSquare(i,j+1,1,1,BLANK,0); 1309 | set_data_highlight(i,j+1,BLANK,1); 1310 | } 1311 | } 1312 | //////////////////////////////////////// 1313 | //1st loop Increasing x, Constanat y 1314 | temp_x = cx; temp_y = cy-1; 1315 | if ( temp_x >= 8 ) { } 1316 | else { 1317 | for (int i=cx+1; /**/ ; i++) { 1318 | if (i > 8) { break; } 1319 | if (gameSquares[i][temp_y+1].is_empty==0 && gameSquares[i][temp_y+1].kill_him==0) { break; } 1320 | if (gameSquares[i][temp_y+1].is_empty==0 && gameSquares[i][temp_y+1].kill_him==1) { 1321 | pinkHighlightStep(i,temp_y,gameSquares[i][temp_y+1].which_piece); 1322 | gameSquares[i][temp_y+1].setSquare(i,temp_y+1,0,1,gameSquares[i][temp_y+1].which_piece,gameSquares[i][temp_y+1].kill_him); 1323 | set_data_highlight(i,temp_y+1,gameSquares[i][temp_y+1].which_piece,1); 1324 | gameSquares[i][temp_y+1].printPiece(i,temp_y+1,11,gameSquares[i][temp_y+1].which_piece); 1325 | break; 1326 | } 1327 | pinkHighlightStep(i,temp_y,BLANK); 1328 | gameSquares[i][temp_y+1].setSquare(i,temp_y+1,1,1,BLANK,0); 1329 | set_data_highlight(i,temp_y+1,BLANK,1); 1330 | } 1331 | } 1332 | //2nd loop Decreasing x, Constanat y 1333 | temp_x = cx; temp_y = cy-1; 1334 | if ( temp_x < 1 ) { } 1335 | else { 1336 | for (int i=cx-1; /**/ ; i--) { 1337 | if (i < 1) { break; } 1338 | if (gameSquares[i][temp_y+1].is_empty==0 && gameSquares[i][temp_y+1].kill_him==0) { break; } 1339 | if (gameSquares[i][temp_y+1].is_empty==0 && gameSquares[i][temp_y+1].kill_him==1) { 1340 | pinkHighlightStep(i,temp_y,gameSquares[i][temp_y+1].which_piece); 1341 | gameSquares[i][temp_y+1].setSquare(i,temp_y+1,0,1,gameSquares[i][temp_y+1].which_piece,gameSquares[i][temp_y+1].kill_him); 1342 | set_data_highlight(i,temp_y+1,gameSquares[i][temp_y+1].which_piece,1); 1343 | gameSquares[i][temp_y+1].printPiece(i,temp_y+1,11,gameSquares[i][temp_y+1].which_piece); 1344 | break; 1345 | } 1346 | pinkHighlightStep(i,temp_y,BLANK); 1347 | gameSquares[i][temp_y+1].setSquare(i,temp_y+1,1,1,BLANK,0); 1348 | set_data_highlight(i,temp_y+1,BLANK,1); 1349 | } 1350 | } 1351 | //3rd loop Constant x, Increasing y 1352 | temp_x = cx; temp_y = cy; 1353 | if ( temp_y >= 8 ) { } 1354 | else { 1355 | for (int i=cy; /**/ ; i++) { 1356 | if (i >= 8) { break; } 1357 | if (gameSquares[temp_x][i+1].is_empty==0 && gameSquares[temp_x][i+1].kill_him==0) { break; } 1358 | if (gameSquares[temp_x][i+1].is_empty==0 && gameSquares[temp_x][i+1].kill_him==1) { 1359 | pinkHighlightStep(temp_x,i,gameSquares[temp_x][i+1].which_piece); 1360 | gameSquares[temp_x][i+1].setSquare(temp_x,i+1,0,1,gameSquares[temp_x][i+1].which_piece,gameSquares[temp_x][i+1].kill_him); 1361 | set_data_highlight(temp_x,i+1,gameSquares[temp_x][i+1].which_piece,1); 1362 | gameSquares[temp_x][i+1].printPiece(temp_x,i+1,11,gameSquares[temp_x][i+1].which_piece); 1363 | break; 1364 | } 1365 | pinkHighlightStep(temp_x,i,BLANK); 1366 | gameSquares[temp_x][i+1].setSquare(temp_x,i+1,1,1,BLANK,0); 1367 | set_data_highlight(temp_x,i+1,BLANK,1); 1368 | } 1369 | } 1370 | //4th loop Constant x, Decreasing y 1371 | temp_x = cx; temp_y = cy; 1372 | if ( temp_y < 0 ) { } 1373 | else { 1374 | for (int i=cy-2; /**/ ; i--) { 1375 | if (i < 0) { break; } 1376 | if (gameSquares[temp_x][i+1].is_empty==0 && gameSquares[temp_x][i+1].kill_him==0) { break; } 1377 | if (gameSquares[temp_x][i+1].is_empty==0 && gameSquares[temp_x][i+1].kill_him==1) { 1378 | pinkHighlightStep(temp_x,i,gameSquares[temp_x][i+1].which_piece); 1379 | gameSquares[temp_x][i+1].setSquare(temp_x,i+1,0,1,gameSquares[temp_x][i+1].which_piece,gameSquares[temp_x][i+1].kill_him); 1380 | set_data_highlight(temp_x,i+1,gameSquares[temp_x][i+1].which_piece,1); 1381 | gameSquares[temp_x][i+1].printPiece(temp_x,i+1,11,gameSquares[temp_x][i+1].which_piece); 1382 | break; 1383 | } 1384 | pinkHighlightStep(temp_x,i,BLANK); 1385 | gameSquares[temp_x][i+1].setSquare(temp_x,i+1,1,1,BLANK,0); 1386 | set_data_highlight(temp_x,i+1,BLANK,1); 1387 | } 1388 | } 1389 | } 1390 | else { //COMPUTER STEPS 1391 | printPiece(cx,cy,14,QUEEN); 1392 | int temp_x, temp_y; 1393 | //1st Quadrant (+ve x , +ve y) 1394 | temp_x = cx; temp_y = cy; 1395 | if (temp_x >= 8 || temp_y >= 8) { } 1396 | else { 1397 | for (int i=cx+1, j=cy; /**/ ; i++, j++) { 1398 | if (i > 8 || j >= 8) { break; } 1399 | if (gameSquares[i][j+1].is_empty==0 && gameSquares[i][j+1].kill_him==1) { break; } 1400 | if (gameSquares[i][j+1].is_empty==0 && gameSquares[i][j+1].kill_him==0) { 1401 | pinkHighlightStep(i,j,gameSquares[i][j+1].which_piece); 1402 | gameSquares[i][j+1].setSquare(i,j+1,0,1,gameSquares[i][j+1].which_piece,gameSquares[i][j+1].kill_him); 1403 | set_data_highlight(i,j+1,gameSquares[i][j+1].which_piece,1); 1404 | gameSquares[i][j+1].printPiece(i,j+1,11,gameSquares[i][j+1].which_piece); 1405 | break; 1406 | } 1407 | pinkHighlightStep(i,j,BLANK); 1408 | gameSquares[i][j+1].setSquare(i,j+1,1,1,BLANK,0); 1409 | set_data_highlight(i,j+1,BLANK,1); 1410 | } 1411 | } 1412 | //2nd Quadrant (x -ve , y +ve) 1413 | if (temp_x < 1 || temp_y >= 8) { } 1414 | else { 1415 | for (int i=cx-1, j=cy; /**/ ; i--, j++) { 1416 | if (i < 1 || j > 7) { break; } 1417 | if (gameSquares[i][j+1].is_empty==0 && gameSquares[i][j+1].kill_him==1) { break; } 1418 | if (gameSquares[i][j+1].is_empty==0 && gameSquares[i][j+1].kill_him==0) { 1419 | pinkHighlightStep(i,j,gameSquares[i][j+1].which_piece); 1420 | gameSquares[i][j+1].setSquare(i,j+1,0,1,gameSquares[i][j+1].which_piece,gameSquares[i][j+1].kill_him); 1421 | set_data_highlight(i,j+1,gameSquares[i][j+1].which_piece,1); 1422 | gameSquares[i][j+1].printPiece(i,j+1,11,gameSquares[i][j+1].which_piece); 1423 | break; 1424 | } 1425 | pinkHighlightStep(i,j,BLANK); 1426 | gameSquares[i][j+1].setSquare(i,j+1,1,1,BLANK,0); 1427 | set_data_highlight(i,j+1,BLANK,1); 1428 | } 1429 | } 1430 | //3rd Quadrant (x -ve , y -ve) 1431 | if (temp_x < 1 || temp_y < 1) { } 1432 | else { 1433 | for (int i=cx-1, j=cy-2; /**/ ; i--, j--) { 1434 | if (i <= 0 || j < 0) { break; } 1435 | if (gameSquares[i][j+1].is_empty==0 && gameSquares[i][j+1].kill_him==1) { break; } 1436 | if (gameSquares[i][j+1].is_empty==0 && gameSquares[i][j+1].kill_him==0) { 1437 | pinkHighlightStep(i,j,gameSquares[i][j+1].which_piece); 1438 | gameSquares[i][j+1].setSquare(i,j+1,0,1,gameSquares[i][j+1].which_piece,gameSquares[i][j+1].kill_him); 1439 | set_data_highlight(i,j+1,gameSquares[i][j+1].which_piece,1); 1440 | gameSquares[i][j+1].printPiece(i,j+1,11,gameSquares[i][j+1].which_piece); 1441 | break; 1442 | } 1443 | pinkHighlightStep(i,j,BLANK); 1444 | gameSquares[i][j+1].setSquare(i,j+1,1,1,BLANK,0); 1445 | set_data_highlight(i,j+1,BLANK,1); 1446 | } 1447 | } 1448 | //4th Quadrant (x +ve , y -ve) 1449 | if (temp_x >= 8 || temp_y < 1) { } 1450 | else { 1451 | for (int i=cx+1, j=cy-2; /**/ ; i++, j--) { 1452 | if (i > 8 || j < 0) { break; } 1453 | if (gameSquares[i][j+1].is_empty==0 && gameSquares[i][j+1].kill_him==1) { break; } 1454 | if (gameSquares[i][j+1].is_empty==0 && gameSquares[i][j+1].kill_him==0) { 1455 | pinkHighlightStep(i,j,gameSquares[i][j+1].which_piece); 1456 | gameSquares[i][j+1].setSquare(i,j+1,0,1,gameSquares[i][j+1].which_piece,gameSquares[i][j+1].kill_him); 1457 | set_data_highlight(i,j+1,gameSquares[i][j+1].which_piece,1); 1458 | gameSquares[i][j+1].printPiece(i,j+1,11,gameSquares[i][j+1].which_piece); 1459 | break; 1460 | } 1461 | pinkHighlightStep(i,j,BLANK); 1462 | gameSquares[i][j+1].setSquare(i,j+1,1,1,BLANK,0); 1463 | set_data_highlight(i,j+1,BLANK,1); 1464 | } 1465 | } 1466 | //////////////////////////////////////// 1467 | //1st loop Increasing x, Constanat y 1468 | temp_x = cx; temp_y = cy-1; 1469 | if ( temp_x >= 8 ) { } 1470 | else { 1471 | for (int i=cx+1; /**/ ; i++) { 1472 | if (i > 8) { break; } 1473 | if (gameSquares[i][temp_y+1].is_empty==0 && gameSquares[i][temp_y+1].kill_him==1) { break; } 1474 | if (gameSquares[i][temp_y+1].is_empty==0 && gameSquares[i][temp_y+1].kill_him==0) { 1475 | pinkHighlightStep(i,temp_y,gameSquares[i][temp_y+1].which_piece); 1476 | gameSquares[i][temp_y+1].setSquare(i,temp_y+1,0,1,gameSquares[i][temp_y+1].which_piece,gameSquares[i][temp_y+1].kill_him); 1477 | set_data_highlight(i,temp_y+1,gameSquares[i][temp_y+1].which_piece,1); 1478 | gameSquares[i][temp_y+1].printPiece(i,temp_y+1,11,gameSquares[i][temp_y+1].which_piece); 1479 | break; 1480 | } 1481 | pinkHighlightStep(i,temp_y,BLANK); 1482 | gameSquares[i][temp_y+1].setSquare(i,temp_y+1,1,1,BLANK,0); 1483 | set_data_highlight(i,temp_y+1,BLANK,1); 1484 | } 1485 | } 1486 | //2nd loop Decreasing x, Constanat y 1487 | temp_x = cx; temp_y = cy-1; 1488 | if ( temp_x < 1 ) { } 1489 | else { 1490 | for (int i=cx-1; /**/ ; i--) { 1491 | if (i < 1) { break; } 1492 | if (gameSquares[i][temp_y+1].is_empty==0 && gameSquares[i][temp_y+1].kill_him==1) { break; } 1493 | if (gameSquares[i][temp_y+1].is_empty==0 && gameSquares[i][temp_y+1].kill_him==0) { 1494 | pinkHighlightStep(i,temp_y,gameSquares[i][temp_y+1].which_piece); 1495 | gameSquares[i][temp_y+1].setSquare(i,temp_y+1,0,1,gameSquares[i][temp_y+1].which_piece,gameSquares[i][temp_y+1].kill_him); 1496 | set_data_highlight(i,temp_y+1,gameSquares[i][temp_y+1].which_piece,1); 1497 | gameSquares[i][temp_y+1].printPiece(i,temp_y+1,11,gameSquares[i][temp_y+1].which_piece); 1498 | break; 1499 | } 1500 | pinkHighlightStep(i,temp_y,BLANK); 1501 | gameSquares[i][temp_y+1].setSquare(i,temp_y+1,1,1,BLANK,0); 1502 | set_data_highlight(i,temp_y+1,BLANK,1); 1503 | } 1504 | } 1505 | //3rd loop Constant x, Increasing y 1506 | temp_x = cx; temp_y = cy; 1507 | if ( temp_y >= 8 ) { } 1508 | else { 1509 | for (int i=cy; /**/ ; i++) { 1510 | if (i >= 8) { break; } 1511 | if (gameSquares[temp_x][i+1].is_empty==0 && gameSquares[temp_x][i+1].kill_him==1) { break; } 1512 | if (gameSquares[temp_x][i+1].is_empty==0 && gameSquares[temp_x][i+1].kill_him==0) { 1513 | pinkHighlightStep(temp_x,i,gameSquares[temp_x][i+1].which_piece); 1514 | gameSquares[temp_x][i+1].setSquare(temp_x,i+1,0,1,gameSquares[temp_x][i+1].which_piece,gameSquares[temp_x][i+1].kill_him); 1515 | set_data_highlight(temp_x,i+1,gameSquares[temp_x][i+1].which_piece,1); 1516 | gameSquares[temp_x][i+1].printPiece(temp_x,i+1,11,gameSquares[temp_x][i+1].which_piece); 1517 | break; 1518 | } 1519 | pinkHighlightStep(temp_x,i,BLANK); 1520 | gameSquares[temp_x][i+1].setSquare(temp_x,i+1,1,1,BLANK,0); 1521 | set_data_highlight(temp_x,i+1,BLANK,1); 1522 | } 1523 | } 1524 | //4th loop Constant x, Decreasing y 1525 | temp_x = cx; temp_y = cy; 1526 | if ( temp_y < 0 ) { } 1527 | else { 1528 | for (int i=cy-2; /**/ ; i--) { 1529 | if (i < 0) { break; } 1530 | if (gameSquares[temp_x][i+1].is_empty==0 && gameSquares[temp_x][i+1].kill_him==1) { break; } 1531 | if (gameSquares[temp_x][i+1].is_empty==0 && gameSquares[temp_x][i+1].kill_him==0) { 1532 | pinkHighlightStep(temp_x,i,gameSquares[temp_x][i+1].which_piece); 1533 | gameSquares[temp_x][i+1].setSquare(temp_x,i+1,0,1,gameSquares[temp_x][i+1].which_piece,gameSquares[temp_x][i+1].kill_him); 1534 | set_data_highlight(temp_x,i+1,gameSquares[temp_x][i+1].which_piece,1); 1535 | gameSquares[temp_x][i+1].printPiece(temp_x,i+1,11,gameSquares[temp_x][i+1].which_piece); 1536 | break; 1537 | } 1538 | pinkHighlightStep(temp_x,i,BLANK); 1539 | gameSquares[temp_x][i+1].setSquare(temp_x,i+1,1,1,BLANK,0); 1540 | set_data_highlight(temp_x,i+1,BLANK,1); 1541 | } 1542 | } 1543 | } 1544 | } 1545 | //_____________________KING STEPS______________________// 1546 | else if (thisPiece == KING) { 1547 | if (gameSquares[cx][cy].kill_him == 0) { 1548 | printPiece(cx,cy,14,KING); 1549 | int temp_x, temp_y; 1550 | //Right-Upper Step 1551 | temp_x = cx; temp_y = cy; 1552 | if (temp_x >= 8 || temp_y >= 8) { } 1553 | else { 1554 | temp_x = cx+1; temp_y = cy; 1555 | if (gameSquares[temp_x][temp_y+1].is_empty==0 && gameSquares[temp_x][temp_y+1].kill_him==0) { } 1556 | else if (gameSquares[temp_x][temp_y+1].is_empty==0 && gameSquares[temp_x][temp_y+1].kill_him==1) { 1557 | pinkHighlightStep(temp_x,temp_y,gameSquares[temp_x][temp_y+1].which_piece); 1558 | gameSquares[temp_x][temp_y+1].setSquare(temp_x,temp_y+1,0,1,gameSquares[temp_x][temp_y+1].which_piece,1); 1559 | set_data_highlight(temp_x,temp_y+1,gameSquares[temp_x][temp_y+1].which_piece,1); 1560 | gameSquares[temp_x][temp_y+1].printPiece(temp_x,temp_y+1,11,gameSquares[temp_x][temp_y+1].which_piece); 1561 | } 1562 | else { 1563 | pinkHighlightStep(temp_x,temp_y,BLANK); 1564 | gameSquares[temp_x][temp_y+1].setSquare(temp_x,temp_y+1,1,1,BLANK,0); 1565 | set_data_highlight(temp_x,temp_y+1,BLANK,1); 1566 | } 1567 | } 1568 | //Left-Upper Step 1569 | temp_x = cx; temp_y = cy; 1570 | if (temp_x <= 1 || temp_y >= 8) { } 1571 | else { 1572 | temp_x = cx-1; temp_y = cy; 1573 | if (gameSquares[temp_x][temp_y+1].is_empty==0 && gameSquares[temp_x][temp_y+1].kill_him==0) { } 1574 | else if (gameSquares[temp_x][temp_y+1].is_empty==0 && gameSquares[temp_x][temp_y+1].kill_him==1) { 1575 | pinkHighlightStep(temp_x,temp_y,gameSquares[temp_x][temp_y+1].which_piece); 1576 | gameSquares[temp_x][temp_y+1].setSquare(temp_x,temp_y+1,0,1,gameSquares[temp_x][temp_y+1].which_piece,1); 1577 | set_data_highlight(temp_x,temp_y+1,gameSquares[temp_x][temp_y+1].which_piece,1); 1578 | gameSquares[temp_x][temp_y+1].printPiece(temp_x,temp_y+1,11,gameSquares[temp_x][temp_y+1].which_piece); 1579 | } 1580 | else { 1581 | pinkHighlightStep(temp_x,temp_y,BLANK); 1582 | gameSquares[temp_x][temp_y+1].setSquare(temp_x,temp_y+1,1,1,BLANK,0); 1583 | set_data_highlight(temp_x,temp_y+1,BLANK,1); 1584 | } 1585 | } 1586 | //Right-Lower Step 1587 | temp_x = cx; temp_y = cy; 1588 | if (temp_x >= 8 || temp_y <= 1) { } 1589 | else { 1590 | temp_x = cx+1; temp_y = cy-2; 1591 | if (gameSquares[temp_x][temp_y+1].is_empty==0 && gameSquares[temp_x][temp_y+1].kill_him==0) { } 1592 | else if (gameSquares[temp_x][temp_y+1].is_empty==0 && gameSquares[temp_x][temp_y+1].kill_him==1) { 1593 | pinkHighlightStep(temp_x,temp_y,gameSquares[temp_x][temp_y+1].which_piece); 1594 | gameSquares[temp_x][temp_y+1].setSquare(temp_x,temp_y+1,0,1,gameSquares[temp_x][temp_y+1].which_piece,1); 1595 | set_data_highlight(temp_x,temp_y+1,gameSquares[temp_x][temp_y+1].which_piece,1); 1596 | gameSquares[temp_x][temp_y+1].printPiece(temp_x,temp_y+1,11,gameSquares[temp_x][temp_y+1].which_piece); 1597 | } 1598 | else { 1599 | pinkHighlightStep(temp_x,temp_y,BLANK); 1600 | gameSquares[temp_x][temp_y+1].setSquare(temp_x,temp_y+1,1,1,BLANK,0); 1601 | set_data_highlight(temp_x,temp_y+1,BLANK,1); 1602 | } 1603 | } 1604 | //Left-Lower Step 1605 | temp_x = cx; temp_y = cy; 1606 | if (temp_x <= 1 || temp_y <= 1) { } 1607 | else { 1608 | temp_x = cx-1; temp_y = cy-2; 1609 | if (gameSquares[temp_x][temp_y+1].is_empty==0 && gameSquares[temp_x][temp_y+1].kill_him==0) { } 1610 | else if (gameSquares[temp_x][temp_y+1].is_empty==0 && gameSquares[temp_x][temp_y+1].kill_him==1) { 1611 | pinkHighlightStep(temp_x,temp_y,gameSquares[temp_x][temp_y+1].which_piece); 1612 | gameSquares[temp_x][temp_y+1].setSquare(temp_x,temp_y+1,0,1,gameSquares[temp_x][temp_y+1].which_piece,1); 1613 | set_data_highlight(temp_x,temp_y+1,gameSquares[temp_x][temp_y+1].which_piece,1); 1614 | gameSquares[temp_x][temp_y+1].printPiece(temp_x,temp_y+1,11,gameSquares[temp_x][temp_y+1].which_piece); 1615 | } 1616 | else { 1617 | pinkHighlightStep(temp_x,temp_y,BLANK); 1618 | gameSquares[temp_x][temp_y+1].setSquare(temp_x,temp_y+1,1,1,BLANK,0); 1619 | set_data_highlight(temp_x,temp_y+1,BLANK,1); 1620 | } 1621 | } 1622 | //Right Step 1623 | temp_x = cx; temp_y = cy; 1624 | if ( temp_x >= 8 ) { } 1625 | else { 1626 | temp_x = cx+1; temp_y = cy-1; 1627 | if (gameSquares[temp_x][temp_y+1].is_empty==0 && gameSquares[temp_x][temp_y+1].kill_him==0) { } 1628 | else if (gameSquares[temp_x][temp_y+1].is_empty==0 && gameSquares[temp_x][temp_y+1].kill_him==1) { 1629 | pinkHighlightStep(temp_x,temp_y,gameSquares[temp_x][temp_y+1].which_piece); 1630 | gameSquares[temp_x][temp_y+1].setSquare(temp_x,temp_y+1,0,1,gameSquares[temp_x][temp_y+1].which_piece,1); 1631 | set_data_highlight(temp_x,temp_y+1,gameSquares[temp_x][temp_y+1].which_piece,1); 1632 | gameSquares[temp_x][temp_y+1].printPiece(temp_x,temp_y+1,11,gameSquares[temp_x][temp_y+1].which_piece); 1633 | } 1634 | else { 1635 | pinkHighlightStep(temp_x,temp_y,BLANK); 1636 | gameSquares[temp_x][temp_y+1].setSquare(temp_x,temp_y+1,1,1,BLANK,0); 1637 | set_data_highlight(temp_x,temp_y+1,BLANK,1); 1638 | } 1639 | } 1640 | //Left Step 1641 | temp_x = cx; temp_y = cy; 1642 | if ( temp_x <= 1 ) { } 1643 | else { 1644 | temp_x = cx-1; temp_y = cy-1; 1645 | if (gameSquares[temp_x][temp_y+1].is_empty==0 && gameSquares[temp_x][temp_y+1].kill_him==0) { } 1646 | else if (gameSquares[temp_x][temp_y+1].is_empty==0 && gameSquares[temp_x][temp_y+1].kill_him==1) { 1647 | pinkHighlightStep(temp_x,temp_y,gameSquares[temp_x][temp_y+1].which_piece); 1648 | gameSquares[temp_x][temp_y+1].setSquare(temp_x,temp_y+1,0,1,gameSquares[temp_x][temp_y+1].which_piece,1); 1649 | set_data_highlight(temp_x,temp_y+1,gameSquares[temp_x][temp_y+1].which_piece,1); 1650 | gameSquares[temp_x][temp_y+1].printPiece(temp_x,temp_y+1,11,gameSquares[temp_x][temp_y+1].which_piece); 1651 | } 1652 | else { 1653 | pinkHighlightStep(temp_x,temp_y,BLANK); 1654 | gameSquares[temp_x][temp_y+1].setSquare(temp_x,temp_y+1,1,1,BLANK,0); 1655 | set_data_highlight(temp_x,temp_y+1,BLANK,1); 1656 | } 1657 | } 1658 | //Up Step 1659 | temp_x = cx; temp_y = cy; 1660 | if ( temp_y >= 8 ) { } 1661 | else { 1662 | temp_x = cx; temp_y = cy; 1663 | if (gameSquares[temp_x][temp_y+1].is_empty==0 && gameSquares[temp_x][temp_y+1].kill_him==0) { } 1664 | else if (gameSquares[temp_x][temp_y+1].is_empty==0 && gameSquares[temp_x][temp_y+1].kill_him==1) { 1665 | pinkHighlightStep(temp_x,temp_y,gameSquares[temp_x][temp_y+1].which_piece); 1666 | gameSquares[temp_x][temp_y+1].setSquare(temp_x,temp_y+1,0,1,gameSquares[temp_x][temp_y+1].which_piece,1); 1667 | set_data_highlight(temp_x,temp_y+1,gameSquares[temp_x][temp_y+1].which_piece,1); 1668 | gameSquares[temp_x][temp_y+1].printPiece(temp_x,temp_y+1,11,gameSquares[temp_x][temp_y+1].which_piece); 1669 | } 1670 | else { 1671 | pinkHighlightStep(temp_x,temp_y,BLANK); 1672 | gameSquares[temp_x][temp_y+1].setSquare(temp_x,temp_y+1,1,1,BLANK,0); 1673 | set_data_highlight(temp_x,temp_y+1,BLANK,1); 1674 | } 1675 | } 1676 | //Down Step 1677 | temp_x = cx; temp_y = cy; 1678 | if ( temp_y <= 1 ) { } 1679 | else { 1680 | temp_x = cx; temp_y = cy-2; 1681 | if (gameSquares[temp_x][temp_y+1].is_empty==0 && gameSquares[temp_x][temp_y+1].kill_him==0) { } 1682 | else if (gameSquares[temp_x][temp_y+1].is_empty==0 && gameSquares[temp_x][temp_y+1].kill_him==1) { 1683 | pinkHighlightStep(temp_x,temp_y,gameSquares[temp_x][temp_y+1].which_piece); 1684 | gameSquares[temp_x][temp_y+1].setSquare(temp_x,temp_y+1,0,1,gameSquares[temp_x][temp_y+1].which_piece,1); 1685 | set_data_highlight(temp_x,temp_y+1,gameSquares[temp_x][temp_y+1].which_piece,1); 1686 | gameSquares[temp_x][temp_y+1].printPiece(temp_x,temp_y+1,11,gameSquares[temp_x][temp_y+1].which_piece); 1687 | } 1688 | else { 1689 | pinkHighlightStep(temp_x,temp_y,BLANK); 1690 | gameSquares[temp_x][temp_y+1].setSquare(temp_x,temp_y+1,1,1,BLANK,0); 1691 | set_data_highlight(temp_x,temp_y+1,BLANK,1); 1692 | } 1693 | } 1694 | } 1695 | else if (gameSquares[cx][cy].kill_him == 1) { 1696 | printPiece(cx,cy,14,KING); 1697 | int temp_x, temp_y; 1698 | //Right-Upper Step 1699 | temp_x = cx; temp_y = cy; 1700 | if (temp_x >= 8 || temp_y >= 8) { } 1701 | else { 1702 | temp_x = cx+1; temp_y = cy; 1703 | if (gameSquares[temp_x][temp_y+1].is_empty==0 && gameSquares[temp_x][temp_y+1].kill_him==1) { } 1704 | else if (gameSquares[temp_x][temp_y+1].is_empty==0 && gameSquares[temp_x][temp_y+1].kill_him==0) { 1705 | pinkHighlightStep(temp_x,temp_y,gameSquares[temp_x][temp_y+1].which_piece); 1706 | gameSquares[temp_x][temp_y+1].setSquare(temp_x,temp_y+1,0,1,gameSquares[temp_x][temp_y+1].which_piece,gameSquares[temp_x][temp_y+1].kill_him); 1707 | set_data_highlight(temp_x,temp_y+1,gameSquares[temp_x][temp_y+1].which_piece,1); 1708 | gameSquares[temp_x][temp_y+1].printPiece(temp_x,temp_y+1,11,gameSquares[temp_x][temp_y+1].which_piece); 1709 | } 1710 | else { 1711 | pinkHighlightStep(temp_x,temp_y,BLANK); 1712 | gameSquares[temp_x][temp_y+1].setSquare(temp_x,temp_y+1,1,1,BLANK,0); 1713 | set_data_highlight(temp_x,temp_y+1,BLANK,1); 1714 | } 1715 | } 1716 | //Left-Upper Step 1717 | temp_x = cx; temp_y = cy; 1718 | if (temp_x <= 1 || temp_y >= 8) { } 1719 | else { 1720 | temp_x = cx-1; temp_y = cy; 1721 | if (gameSquares[temp_x][temp_y+1].is_empty==0 && gameSquares[temp_x][temp_y+1].kill_him==1) { } 1722 | else if (gameSquares[temp_x][temp_y+1].is_empty==0 && gameSquares[temp_x][temp_y+1].kill_him==0) { 1723 | pinkHighlightStep(temp_x,temp_y,gameSquares[temp_x][temp_y+1].which_piece); 1724 | gameSquares[temp_x][temp_y+1].setSquare(temp_x,temp_y+1,0,1,gameSquares[temp_x][temp_y+1].which_piece,gameSquares[temp_x][temp_y+1].kill_him); 1725 | set_data_highlight(temp_x,temp_y+1,gameSquares[temp_x][temp_y+1].which_piece,1); 1726 | gameSquares[temp_x][temp_y+1].printPiece(temp_x,temp_y+1,11,gameSquares[temp_x][temp_y+1].which_piece); 1727 | } 1728 | else { 1729 | pinkHighlightStep(temp_x,temp_y,BLANK); 1730 | gameSquares[temp_x][temp_y+1].setSquare(temp_x,temp_y+1,1,1,BLANK,0); 1731 | set_data_highlight(temp_x,temp_y+1,BLANK,1); 1732 | } 1733 | } 1734 | //Right-Lower Step 1735 | temp_x = cx; temp_y = cy; 1736 | if (temp_x >= 8 || temp_y <= 1) { } 1737 | else { 1738 | temp_x = cx+1; temp_y = cy-2; 1739 | if (gameSquares[temp_x][temp_y+1].is_empty==0 && gameSquares[temp_x][temp_y+1].kill_him==1) { } 1740 | else if (gameSquares[temp_x][temp_y+1].is_empty==0 && gameSquares[temp_x][temp_y+1].kill_him==0) { 1741 | pinkHighlightStep(temp_x,temp_y,gameSquares[temp_x][temp_y+1].which_piece); 1742 | gameSquares[temp_x][temp_y+1].setSquare(temp_x,temp_y+1,0,1,gameSquares[temp_x][temp_y+1].which_piece,gameSquares[temp_x][temp_y+1].kill_him); 1743 | set_data_highlight(temp_x,temp_y+1,gameSquares[temp_x][temp_y+1].which_piece,1); 1744 | gameSquares[temp_x][temp_y+1].printPiece(temp_x,temp_y+1,11,gameSquares[temp_x][temp_y+1].which_piece); 1745 | } 1746 | else { 1747 | pinkHighlightStep(temp_x,temp_y,BLANK); 1748 | gameSquares[temp_x][temp_y+1].setSquare(temp_x,temp_y+1,1,1,BLANK,0); 1749 | set_data_highlight(temp_x,temp_y+1,BLANK,1); 1750 | } 1751 | } 1752 | //Left-Lower Step 1753 | temp_x = cx; temp_y = cy; 1754 | if (temp_x <= 1 || temp_y <= 1) { } 1755 | else { 1756 | temp_x = cx-1; temp_y = cy-2; 1757 | if (gameSquares[temp_x][temp_y+1].is_empty==0 && gameSquares[temp_x][temp_y+1].kill_him==1) { } 1758 | else if (gameSquares[temp_x][temp_y+1].is_empty==0 && gameSquares[temp_x][temp_y+1].kill_him==0) { 1759 | pinkHighlightStep(temp_x,temp_y,gameSquares[temp_x][temp_y+1].which_piece); 1760 | gameSquares[temp_x][temp_y+1].setSquare(temp_x,temp_y+1,0,1,gameSquares[temp_x][temp_y+1].which_piece,gameSquares[temp_x][temp_y+1].kill_him); 1761 | set_data_highlight(temp_x,temp_y+1,gameSquares[temp_x][temp_y+1].which_piece,1); 1762 | gameSquares[temp_x][temp_y+1].printPiece(temp_x,temp_y+1,11,gameSquares[temp_x][temp_y+1].which_piece); 1763 | } 1764 | else { 1765 | pinkHighlightStep(temp_x,temp_y,BLANK); 1766 | gameSquares[temp_x][temp_y+1].setSquare(temp_x,temp_y+1,1,1,BLANK,0); 1767 | set_data_highlight(temp_x,temp_y+1,BLANK,1); 1768 | } 1769 | } 1770 | //Right Step 1771 | temp_x = cx; temp_y = cy; 1772 | if ( temp_x >= 8 ) { } 1773 | else { 1774 | temp_x = cx+1; temp_y = cy-1; 1775 | if (gameSquares[temp_x][temp_y+1].is_empty==0 && gameSquares[temp_x][temp_y+1].kill_him==1) { } 1776 | else if (gameSquares[temp_x][temp_y+1].is_empty==0 && gameSquares[temp_x][temp_y+1].kill_him==0) { 1777 | pinkHighlightStep(temp_x,temp_y,gameSquares[temp_x][temp_y+1].which_piece); 1778 | gameSquares[temp_x][temp_y+1].setSquare(temp_x,temp_y+1,0,1,gameSquares[temp_x][temp_y+1].which_piece,gameSquares[temp_x][temp_y+1].kill_him); 1779 | set_data_highlight(temp_x,temp_y+1,gameSquares[temp_x][temp_y+1].which_piece,1); 1780 | gameSquares[temp_x][temp_y+1].printPiece(temp_x,temp_y+1,11,gameSquares[temp_x][temp_y+1].which_piece); 1781 | } 1782 | else { 1783 | pinkHighlightStep(temp_x,temp_y,BLANK); 1784 | gameSquares[temp_x][temp_y+1].setSquare(temp_x,temp_y+1,1,1,BLANK,0); 1785 | set_data_highlight(temp_x,temp_y+1,BLANK,1); 1786 | } 1787 | } 1788 | //Left Step 1789 | temp_x = cx; temp_y = cy; 1790 | if ( temp_x <= 1 ) { } 1791 | else { 1792 | temp_x = cx-1; temp_y = cy-1; 1793 | if (gameSquares[temp_x][temp_y+1].is_empty==0 && gameSquares[temp_x][temp_y+1].kill_him==1) { } 1794 | else if (gameSquares[temp_x][temp_y+1].is_empty==0 && gameSquares[temp_x][temp_y+1].kill_him==0) { 1795 | pinkHighlightStep(temp_x,temp_y,gameSquares[temp_x][temp_y+1].which_piece); 1796 | gameSquares[temp_x][temp_y+1].setSquare(temp_x,temp_y+1,0,1,gameSquares[temp_x][temp_y+1].which_piece,gameSquares[temp_x][temp_y+1].kill_him); 1797 | set_data_highlight(temp_x,temp_y+1,gameSquares[temp_x][temp_y+1].which_piece,1); 1798 | gameSquares[temp_x][temp_y+1].printPiece(temp_x,temp_y+1,11,gameSquares[temp_x][temp_y+1].which_piece); 1799 | } 1800 | else { 1801 | pinkHighlightStep(temp_x,temp_y,BLANK); 1802 | gameSquares[temp_x][temp_y+1].setSquare(temp_x,temp_y+1,1,1,BLANK,0); 1803 | set_data_highlight(temp_x,temp_y+1,BLANK,1); 1804 | } 1805 | } 1806 | //Up Step 1807 | temp_x = cx; temp_y = cy; 1808 | if ( temp_y >= 8 ) { } 1809 | else { 1810 | temp_x = cx; temp_y = cy; 1811 | if (gameSquares[temp_x][temp_y+1].is_empty==0 && gameSquares[temp_x][temp_y+1].kill_him==1) { } 1812 | else if (gameSquares[temp_x][temp_y+1].is_empty==0 && gameSquares[temp_x][temp_y+1].kill_him==0) { 1813 | pinkHighlightStep(temp_x,temp_y,gameSquares[temp_x][temp_y+1].which_piece); 1814 | gameSquares[temp_x][temp_y+1].setSquare(temp_x,temp_y+1,0,1,gameSquares[temp_x][temp_y+1].which_piece,gameSquares[temp_x][temp_y+1].kill_him); 1815 | set_data_highlight(temp_x,temp_y+1,gameSquares[temp_x][temp_y+1].which_piece,1); 1816 | gameSquares[temp_x][temp_y+1].printPiece(temp_x,temp_y+1,11,gameSquares[temp_x][temp_y+1].which_piece); 1817 | } 1818 | else { 1819 | pinkHighlightStep(temp_x,temp_y,BLANK); 1820 | gameSquares[temp_x][temp_y+1].setSquare(temp_x,temp_y+1,1,1,BLANK,0); 1821 | set_data_highlight(temp_x,temp_y+1,BLANK,1); 1822 | } 1823 | } 1824 | //Down Step 1825 | temp_x = cx; temp_y = cy; 1826 | if ( temp_y <= 1 ) { } 1827 | else { 1828 | temp_x = cx; temp_y = cy-2; 1829 | if (gameSquares[temp_x][temp_y+1].is_empty==0 && gameSquares[temp_x][temp_y+1].kill_him==1) { } 1830 | else if (gameSquares[temp_x][temp_y+1].is_empty==0 && gameSquares[temp_x][temp_y+1].kill_him==0) { 1831 | pinkHighlightStep(temp_x,temp_y,gameSquares[temp_x][temp_y+1].which_piece); 1832 | gameSquares[temp_x][temp_y+1].setSquare(temp_x,temp_y+1,0,1,gameSquares[temp_x][temp_y+1].which_piece,gameSquares[temp_x][temp_y+1].kill_him); 1833 | set_data_highlight(temp_x,temp_y+1,gameSquares[temp_x][temp_y+1].which_piece,1); 1834 | gameSquares[temp_x][temp_y+1].printPiece(temp_x,temp_y+1,11,gameSquares[temp_x][temp_y+1].which_piece); 1835 | } 1836 | else { 1837 | pinkHighlightStep(temp_x,temp_y,BLANK); 1838 | gameSquares[temp_x][temp_y+1].setSquare(temp_x,temp_y+1,1,1,BLANK,0); 1839 | set_data_highlight(temp_x,temp_y+1,BLANK,1); 1840 | } 1841 | } 1842 | } 1843 | } 1844 | } 1845 | //Tell About the Check of King 1846 | void tell_about_check(int cx, int cy) { 1847 | //For Pawn 1848 | if (gameSquares[cx][cy].which_piece == PAWN) { 1849 | if (gameSquares[cx][cy].kill_him == 0) { //If it is Player's PAWN 1850 | if (gameSquares[cx+1][cy+1].kill_him == 1 && gameSquares[cx+1][cy+1].which_piece == KING) { 1851 | gotoxy(5,15); 1852 | HANDLE hConsole; 1853 | hConsole = GetStdHandle(STD_OUTPUT_HANDLE); 1854 | SetConsoleTextAttribute(hConsole, 207); //RED Colour Code = 207 1855 | cout<<"Check"; 1856 | } 1857 | if (gameSquares[cx-1][cy+1].kill_him == 1 && gameSquares[cx-1][cy+1].which_piece == KING) { 1858 | gotoxy(5,15); 1859 | HANDLE hConsole; 1860 | hConsole = GetStdHandle(STD_OUTPUT_HANDLE); 1861 | SetConsoleTextAttribute(hConsole, 207); //RED Colour Code = 207 1862 | cout<<"Check"; 1863 | } 1864 | } 1865 | else { 1866 | if (gameSquares[cx+1][cy-1].kill_him == 0 && gameSquares[cx+1][cy-1].which_piece == KING) { 1867 | gotoxy(5,15); 1868 | HANDLE hConsole; 1869 | hConsole = GetStdHandle(STD_OUTPUT_HANDLE); 1870 | SetConsoleTextAttribute(hConsole, 207); //RED Colour Code = 207 1871 | cout<<"Check"; 1872 | } 1873 | if (gameSquares[cx-1][cy-1].kill_him == 0 && gameSquares[cx+1][cy-1].which_piece == KING) { 1874 | gotoxy(5,15); 1875 | HANDLE hConsole; 1876 | hConsole = GetStdHandle(STD_OUTPUT_HANDLE); 1877 | SetConsoleTextAttribute(hConsole, 207); //RED Colour Code = 207 1878 | cout<<"Check"; 1879 | } 1880 | } 1881 | } 1882 | //For Knight 1883 | if (gameSquares[cx][cy].which_piece == KNIGHT) { 1884 | if (gameSquares[cx][cy].kill_him == 0) { 1885 | //(x+1,y+2) 1886 | if (gameSquares[cx+1][cy+2].kill_him == 1 && gameSquares[cx+1][cy+2].which_piece == KING) { 1887 | gotoxy(5,15); 1888 | HANDLE hConsole; 1889 | hConsole = GetStdHandle(STD_OUTPUT_HANDLE); 1890 | SetConsoleTextAttribute(hConsole, 207); //RED Colour Code = 207 1891 | cout<<"Check"; 1892 | } 1893 | //(x+1,y-2) 1894 | else if (gameSquares[cx+1][cy-2].kill_him == 1 && gameSquares[cx+1][cy-2].which_piece == KING) { 1895 | gotoxy(5,15); 1896 | HANDLE hConsole; 1897 | hConsole = GetStdHandle(STD_OUTPUT_HANDLE); 1898 | SetConsoleTextAttribute(hConsole, 207); //RED Colour Code = 207 1899 | cout<<"Check"; 1900 | } 1901 | //(x-1,y+2) 1902 | else if (gameSquares[cx-1][cy+2].kill_him == 1 && gameSquares[cx-1][cy+2].which_piece == KING) { 1903 | gotoxy(5,15); 1904 | HANDLE hConsole; 1905 | hConsole = GetStdHandle(STD_OUTPUT_HANDLE); 1906 | SetConsoleTextAttribute(hConsole, 207); //RED Colour Code = 207 1907 | cout<<"Check"; 1908 | } 1909 | //(x-1,y-2) 1910 | else if (gameSquares[cx-1][cy-2].kill_him == 1 && gameSquares[cx-1][cy-2].which_piece == KING) { 1911 | gotoxy(5,15); 1912 | HANDLE hConsole; 1913 | hConsole = GetStdHandle(STD_OUTPUT_HANDLE); 1914 | SetConsoleTextAttribute(hConsole, 207); //RED Colour Code = 207 1915 | cout<<"Check"; 1916 | } 1917 | //(x+2,y+1) 1918 | else if (gameSquares[cx+2][cy+1].kill_him == 1 && gameSquares[cx+2][cy+1].which_piece == KING) { 1919 | gotoxy(5,15); 1920 | HANDLE hConsole; 1921 | hConsole = GetStdHandle(STD_OUTPUT_HANDLE); 1922 | SetConsoleTextAttribute(hConsole, 207); //RED Colour Code = 207 1923 | cout<<"Check"; 1924 | } 1925 | //(x+2,y-1) 1926 | else if (gameSquares[cx+2][cy-1].kill_him == 1 && gameSquares[cx+2][cy-1].which_piece == KING) { 1927 | gotoxy(5,15); 1928 | HANDLE hConsole; 1929 | hConsole = GetStdHandle(STD_OUTPUT_HANDLE); 1930 | SetConsoleTextAttribute(hConsole, 207); //RED Colour Code = 207 1931 | cout<<"Check"; 1932 | } 1933 | //(x-2,y+1) 1934 | else if (gameSquares[cx-2][cy+1].kill_him == 1 && gameSquares[cx-2][cy+1].which_piece == KING) { 1935 | gotoxy(5,15); 1936 | HANDLE hConsole; 1937 | hConsole = GetStdHandle(STD_OUTPUT_HANDLE); 1938 | SetConsoleTextAttribute(hConsole, 207); //RED Colour Code = 207 1939 | cout<<"Check"; 1940 | } 1941 | //(x-2,y-1) 1942 | else if (gameSquares[cx-2][cy-1].kill_him == 1 && gameSquares[cx-2][cy-1].which_piece == KING) { 1943 | gotoxy(5,15); 1944 | HANDLE hConsole; 1945 | hConsole = GetStdHandle(STD_OUTPUT_HANDLE); 1946 | SetConsoleTextAttribute(hConsole, 207); //RED Colour Code = 207 1947 | cout<<"Check"; 1948 | } 1949 | } 1950 | else { 1951 | //(x+1,y+2) 1952 | if (gameSquares[cx+1][cy+2].kill_him == 0 && gameSquares[cx+1][cy+2].which_piece == KING) { 1953 | gotoxy(5,15); 1954 | HANDLE hConsole; 1955 | hConsole = GetStdHandle(STD_OUTPUT_HANDLE); 1956 | SetConsoleTextAttribute(hConsole, 207); //RED Colour Code = 207 1957 | cout<<"Check"; 1958 | } 1959 | //(x+1,y-2) 1960 | else if (gameSquares[cx+1][cy-2].kill_him == 0 && gameSquares[cx+1][cy-2].which_piece == KING) { 1961 | gotoxy(5,15); 1962 | HANDLE hConsole; 1963 | hConsole = GetStdHandle(STD_OUTPUT_HANDLE); 1964 | SetConsoleTextAttribute(hConsole, 207); //RED Colour Code = 207 1965 | cout<<"Check"; 1966 | } 1967 | //(x-1,y+2) 1968 | else if (gameSquares[cx-1][cy+2].kill_him == 0 && gameSquares[cx-1][cy+2].which_piece == KING) { 1969 | gotoxy(5,15); 1970 | HANDLE hConsole; 1971 | hConsole = GetStdHandle(STD_OUTPUT_HANDLE); 1972 | SetConsoleTextAttribute(hConsole, 207); //RED Colour Code = 207 1973 | cout<<"Check"; 1974 | } 1975 | //(x-1,y-2) 1976 | else if (gameSquares[cx-1][cy-2].kill_him == 0 && gameSquares[cx-1][cy-2].which_piece == KING) { 1977 | gotoxy(5,15); 1978 | HANDLE hConsole; 1979 | hConsole = GetStdHandle(STD_OUTPUT_HANDLE); 1980 | SetConsoleTextAttribute(hConsole, 207); //RED Colour Code = 207 1981 | cout<<"Check"; 1982 | } 1983 | //(x+2,y+1) 1984 | else if (gameSquares[cx+2][cy+1].kill_him == 0 && gameSquares[cx+2][cy+1].which_piece == KING) { 1985 | gotoxy(5,15); 1986 | HANDLE hConsole; 1987 | hConsole = GetStdHandle(STD_OUTPUT_HANDLE); 1988 | SetConsoleTextAttribute(hConsole, 207); //RED Colour Code = 207 1989 | cout<<"Check"; 1990 | } 1991 | //(x+2,y-1) 1992 | else if (gameSquares[cx+2][cy-1].kill_him == 0 && gameSquares[cx+2][cy-1].which_piece == KING) { 1993 | gotoxy(5,15); 1994 | HANDLE hConsole; 1995 | hConsole = GetStdHandle(STD_OUTPUT_HANDLE); 1996 | SetConsoleTextAttribute(hConsole, 207); //RED Colour Code = 207 1997 | cout<<"Check"; 1998 | } 1999 | //(x-2,y+1) 2000 | else if (gameSquares[cx-2][cy+1].kill_him == 0 && gameSquares[cx-2][cy+1].which_piece == KING) { 2001 | gotoxy(5,15); 2002 | HANDLE hConsole; 2003 | hConsole = GetStdHandle(STD_OUTPUT_HANDLE); 2004 | SetConsoleTextAttribute(hConsole, 207); //RED Colour Code = 207 2005 | cout<<"Check"; 2006 | } 2007 | //(x-2,y-1) 2008 | else if (gameSquares[cx-2][cy-1].kill_him == 0 && gameSquares[cx-2][cy-1].which_piece == KING) { 2009 | gotoxy(5,15); 2010 | HANDLE hConsole; 2011 | hConsole = GetStdHandle(STD_OUTPUT_HANDLE); 2012 | SetConsoleTextAttribute(hConsole, 207); //RED Colour Code = 207 2013 | cout<<"Check"; 2014 | } 2015 | } 2016 | } 2017 | //For Bishop 2018 | if (gameSquares[cx][cy].which_piece == BISHOP) { 2019 | if (gameSquares[cx][cy].kill_him == 0) { 2020 | int temp_x, temp_y; 2021 | //1st Quadrant (+ve x , +ve y) 2022 | temp_x = cx; temp_y = cy; 2023 | if (temp_x >= 8 || temp_y >= 8) { } 2024 | else { 2025 | for (int i=cx+1, j=cy; /**/ ; i++, j++) { 2026 | if (i > 8 || j >= 8) { break; } 2027 | if (gameSquares[i][j+1].is_empty==0 && gameSquares[i][j+1].kill_him==0) { break; } 2028 | if (gameSquares[i][j+1].is_empty==0 && gameSquares[i][j+1].kill_him==1) { break; } 2029 | if (gameSquares[i][j+1].is_empty==KING && gameSquares[i][j+1].kill_him==1) { 2030 | gotoxy(5,15); 2031 | HANDLE hConsole; 2032 | hConsole = GetStdHandle(STD_OUTPUT_HANDLE); 2033 | SetConsoleTextAttribute(hConsole, 207); //RED Colour Code = 207 2034 | cout<<"Check"; 2035 | break; 2036 | } 2037 | } 2038 | } 2039 | //2nd Quadrant (x -ve , y +ve) 2040 | if (temp_x < 1 || temp_y >= 8) { } 2041 | else { 2042 | for (int i=cx-1, j=cy; /**/ ; i--, j++) { 2043 | if (i < 1 || j > 7) { break; } 2044 | if (gameSquares[i][j+1].is_empty==0 && gameSquares[i][j+1].kill_him==0) { break; } 2045 | if (gameSquares[i][j+1].is_empty==0 && gameSquares[i][j+1].kill_him==1) { break; } 2046 | if (gameSquares[i][j+1].is_empty==KING && gameSquares[i][j+1].kill_him==1) { 2047 | gotoxy(5,15); 2048 | HANDLE hConsole; 2049 | hConsole = GetStdHandle(STD_OUTPUT_HANDLE); 2050 | SetConsoleTextAttribute(hConsole, 207); //RED Colour Code = 207 2051 | cout<<"Check"; 2052 | break; 2053 | } 2054 | } 2055 | } 2056 | //3rd Quadrant (x -ve , y -ve) 2057 | if (temp_x < 1 || temp_y < 1) { } 2058 | else { 2059 | for (int i=cx-1, j=cy-2; /**/ ; i--, j--) { 2060 | if (i <= 0 || j < 0) { break; } 2061 | if (gameSquares[i][j+1].is_empty==0 && gameSquares[i][j+1].kill_him==0) { break; } 2062 | if (gameSquares[i][j+1].is_empty==0 && gameSquares[i][j+1].kill_him==1) { break; } 2063 | if (gameSquares[i][j+1].is_empty==KING && gameSquares[i][j+1].kill_him==1) { 2064 | gotoxy(5,15); 2065 | HANDLE hConsole; 2066 | hConsole = GetStdHandle(STD_OUTPUT_HANDLE); 2067 | SetConsoleTextAttribute(hConsole, 207); //RED Colour Code = 207 2068 | cout<<"Check"; 2069 | break; 2070 | } 2071 | } 2072 | } 2073 | //4th Quadrant (x +ve , y -ve) 2074 | if (temp_x >= 8 || temp_y < 1) { } 2075 | else { 2076 | for (int i=cx+1, j=cy-2; /**/ ; i++, j--) { 2077 | if (i > 8 || j < 0) { break; } 2078 | if (gameSquares[i][j+1].is_empty==0 && gameSquares[i][j+1].kill_him==0) { break; } 2079 | if (gameSquares[i][j+1].is_empty==0 && gameSquares[i][j+1].kill_him==1) { break; } 2080 | if (gameSquares[i][j+1].is_empty==KING && gameSquares[i][j+1].kill_him==1) { 2081 | gotoxy(5,15); 2082 | HANDLE hConsole; 2083 | hConsole = GetStdHandle(STD_OUTPUT_HANDLE); 2084 | SetConsoleTextAttribute(hConsole, 207); //RED Colour Code = 207 2085 | cout<<"Check"; 2086 | break; 2087 | } 2088 | } 2089 | } 2090 | } 2091 | } 2092 | } 2093 | 2094 | //Unhighlighted Pink Step_______________________ 2095 | void CPiece::unhighlightStep(int cx, int cy){ 2096 | HANDLE hConsole; 2097 | hConsole = GetStdHandle(STD_OUTPUT_HANDLE); 2098 | if ( cx%2==0 && cy%2==0 ) { //If x is even, y is evem 2099 | HANDLE hConsole; //Print Gray Step 2100 | hConsole = GetStdHandle(STD_OUTPUT_HANDLE); 2101 | SetConsoleTextAttribute(hConsole, 8); //Gray Colour Code = 8 2102 | int X = (cx * 5)+16-3; 2103 | int Y = 24-(cy * 3)+1; 2104 | X = X-2; 2105 | Y = Y-1; 2106 | gotoxy(X,Y); 2107 | for (int i=0; i<3; i++) { 2108 | for (int i=0; i<5; i++) { 2109 | cout<<"\xDB"; 2110 | } 2111 | Y++; 2112 | gotoxy(X,Y); 2113 | } 2114 | } 2115 | else if ( cx%2!=0 && cy%2!=0 ) { //If x is odd, y is odd 2116 | HANDLE hConsole; //Print Gray Step 2117 | hConsole = GetStdHandle(STD_OUTPUT_HANDLE); 2118 | SetConsoleTextAttribute(hConsole, 8); //Gray Colour Code = 8 2119 | int X = (cx * 5)+16-3; 2120 | int Y = 24-(cy * 3)+1; 2121 | X = X-2; 2122 | Y = Y-1; 2123 | gotoxy(X,Y); 2124 | for (int i=0; i<3; i++) { 2125 | for (int i=0; i<5; i++) { 2126 | cout<<"\xDB"; 2127 | } 2128 | Y++; 2129 | gotoxy(X,Y); 2130 | } 2131 | } 2132 | else if ( cx%2!=0 && cy%2==0 ) { //If x is odd, y is even 2133 | HANDLE hConsole; //Print Green Step 2134 | hConsole = GetStdHandle(STD_OUTPUT_HANDLE); 2135 | SetConsoleTextAttribute(hConsole, 2); //Greem Colour Code = 2 2136 | int X = (cx * 5)+16-3; 2137 | int Y = 24-(cy * 3)+1; 2138 | X = X-2; 2139 | Y = Y-1; 2140 | gotoxy(X,Y); 2141 | for (int i=0; i<3; i++) { 2142 | for (int i=0; i<5; i++) { 2143 | cout<<"\xB0"; 2144 | } 2145 | Y++; 2146 | gotoxy(X,Y); 2147 | } 2148 | } 2149 | else if ( cx%2==0 && cy%2!=0 ) { //If x is even, y is odd 2150 | HANDLE hConsole; //Print Green Step 2151 | hConsole = GetStdHandle(STD_OUTPUT_HANDLE); 2152 | SetConsoleTextAttribute(hConsole, 2); //Green Colour Code = 2 2153 | int X = (cx * 5)+16-3; 2154 | int Y = 24-(cy * 3)+1; 2155 | X = X-2; 2156 | Y = Y-1; 2157 | gotoxy(X,Y); 2158 | for (int i=0; i<3; i++) { 2159 | for (int i=0; i<5; i++) { 2160 | cout<<"\xB0"; 2161 | } 2162 | Y++; 2163 | gotoxy(X,Y); 2164 | } 2165 | } 2166 | ////////////////////////////// 2167 | 2168 | if (gameSquares[cx][cy].is_empty == 1) { 2169 | gameSquares[cx][cy].setSquare(cx,cy,1,0,0,0); 2170 | } 2171 | else { 2172 | if (gameSquares[cx][cy].kill_him == 1){ 2173 | gameSquares[cx][cy].setSquare(cx,cy,0,0,gameSquares[cx][cy].which_piece,gameSquares[cx][cy].kill_him); 2174 | gameSquares[cx][cy].printPiece(cx,cy,15,gameSquares[cx][cy].which_piece); 2175 | } 2176 | else { 2177 | gameSquares[cx][cy].setSquare(cx,cy,0,0,gameSquares[cx][cy].which_piece,gameSquares[cx][cy].kill_him); 2178 | gameSquares[cx][cy].printPiece(cx,cy,10,gameSquares[cx][cy].which_piece); 2179 | } 2180 | } 2181 | } 2182 | //Pink Highlight Step_______________________ 2183 | void CPiece::pinkHighlightStep(int cx, int cy, int pieceNum){ 2184 | HANDLE hConsole; 2185 | hConsole = GetStdHandle(STD_OUTPUT_HANDLE); 2186 | if ( cx%2==0 && cy%2==0 ) { //If x is even, y is evem 2187 | HANDLE hConsole; //Print Gray Step 2188 | hConsole = GetStdHandle(STD_OUTPUT_HANDLE); 2189 | SetConsoleTextAttribute(hConsole, 5); //Dark Pink Colour Code = 5 2190 | int X = (cx * 5)+16-3; 2191 | int Y = 24-(cy * 3)+1; 2192 | int tempX = X - 2; 2193 | int tempY = Y - 4; 2194 | gotoxy(tempX,tempY); 2195 | for (int i=0; i<3; i++) { 2196 | for (int i=0; i<5; i++) { 2197 | cout<<"\xDB"; 2198 | } 2199 | tempY++; 2200 | gotoxy(tempX,tempY); 2201 | } 2202 | } 2203 | else if ( cx%2!=0 && cy%2!=0 ) { //If x is odd, y is odd 2204 | HANDLE hConsole; //Print Gray Step 2205 | hConsole = GetStdHandle(STD_OUTPUT_HANDLE); 2206 | SetConsoleTextAttribute(hConsole, 5); //Dark Pink Colour Code = 5 2207 | int X = (cx * 5)+16-3; 2208 | int Y = 24-(cy * 3)+1; 2209 | int tempX = X - 2; 2210 | int tempY = Y - 4; 2211 | gotoxy(tempX,tempY); 2212 | for (int i=0; i<3; i++) { 2213 | for (int i=0; i<5; i++) { 2214 | cout<<"\xDB"; 2215 | } 2216 | tempY++; 2217 | gotoxy(tempX,tempY); 2218 | } 2219 | } 2220 | else if ( cx%2!=0 && cy%2==0 ) { //If x is odd, y is even 2221 | HANDLE hConsole; //Print Gray Step 2222 | hConsole = GetStdHandle(STD_OUTPUT_HANDLE); 2223 | SetConsoleTextAttribute(hConsole, 13); //Light Pink Colour Code = 13 2224 | int X = (cx * 5)+16-3; 2225 | int Y = 24-(cy * 3)+1; 2226 | int tempX = X - 2; 2227 | int tempY = Y - 4; 2228 | gotoxy(tempX,tempY); 2229 | for (int i=0; i<3; i++) { 2230 | for (int i=0; i<5; i++) { 2231 | cout<<"\xDB"; 2232 | } 2233 | tempY++; 2234 | gotoxy(tempX,tempY); 2235 | } 2236 | } 2237 | else if ( cx%2==0 && cy%2!=0 ) { //If x is even, y is odd 2238 | HANDLE hConsole; //Print Gray Step 2239 | hConsole = GetStdHandle(STD_OUTPUT_HANDLE); 2240 | SetConsoleTextAttribute(hConsole, 13); //Light Pink Colour Code = 13 2241 | int X = (cx * 5)+16-3; 2242 | int Y = 24-(cy * 3)+1; 2243 | int tempX = X - 2; 2244 | int tempY = Y - 4; 2245 | gotoxy(tempX,tempY); 2246 | for (int i=0; i<3; i++) { 2247 | for (int i=0; i<5; i++) { 2248 | cout<<"\xDB"; 2249 | } 2250 | tempY++; 2251 | gotoxy(tempX,tempY); 2252 | } 2253 | } 2254 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ChessGameCPP 2 | A chess game in C++ with multiplayer using console graphics. 3 | 4 | I created this project back in 2009 when I was a sophomore in 3rd semester in graduation as a learning project in C++. I used simple console graphics using various characters with various colors by `cout<<` identifier. 5 | 6 | ## Code 7 | You can find the code in [ChessGame.cpp](https://github.com/wajahatkarim3/ChessGameCPP/blob/master/ChessGame.cpp) file. I developed in using Dev C++ compiler at that time. 8 | 9 | 10 | ## Game Images 11 | ![](https://github.com/wajahatkarim3/ChessGameCPP/blob/master/chess1.jpg?raw=true) 12 | ![](https://github.com/wajahatkarim3/ChessGameCPP/blob/master/chess2.jpg?raw=true) 13 | 14 | ## Developed By 15 | ``` 16 | Wajahat Karim 17 | ``` 18 | - Website (http://wajahatkarim.com) 19 | - Twitter (http://twitter.com/wajahatkarim) 20 | - Medium (http://www.medium.com/@wajahatkarim3) 21 | - LinkedIn (http://www.linkedin.com/in/wajahatkarim) 22 | 23 | # License 24 | 25 | Copyright 2017 Wajahat Karim 26 | 27 | Licensed under the Apache License, Version 2.0 (the "License"); 28 | you may not use this file except in compliance with the License. 29 | You may obtain a copy of the License at 30 | 31 | http://www.apache.org/licenses/LICENSE-2.0 32 | 33 | Unless required by applicable law or agreed to in writing, software 34 | distributed under the License is distributed on an "AS IS" BASIS, 35 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 36 | See the License for the specific language governing permissions and 37 | limitations under the License. 38 | -------------------------------------------------------------------------------- /chess1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wajahatkarim3/ChessGameCPP/816434c856d1fe7c9bf246008ca03044ce8038c9/chess1.jpg -------------------------------------------------------------------------------- /chess2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wajahatkarim3/ChessGameCPP/816434c856d1fe7c9bf246008ca03044ce8038c9/chess2.jpg --------------------------------------------------------------------------------