//Starts Singleplayer mode game void singlegame() { getword(); //Clear the screen system("cls"); printstage('s'); maingame(); }
//Starts Multiplayer mode game void multigame() { //Clear the screen system("cls"); printf("Enter the word (Don't let your friend see it) : "); //Get the input gets(guessword); //Change to lowercase strlwr(guessword); //Clear the screen system("cls"); printf("Check guess word : %s\n", guessword); generatecurrentword(); printstage('m'); maingame(); }
main() { clrscr(); textbackground(BLACK); textcolor(LIGHTCYAN); for(loading = 0; loading <= 100; loading++) { delay(9999999); clrscr(); printf("Loading TicTacToe %d%%...", loading); } delay(9999999); while(exiton != 1) { for(y = 0; y < 8; y ++) { x[y] = 32; } for(y = 1; y < 10; y ++) { ch[y] = 32; } mainscr(); gotoxy(3,18); printf("Enter Command:"); gotoxy(23,18); scanf("%d", &cmd); if(cmd == 0) { if(cheats == 0) { cheats = 1; strcpy(ce,"On "); mainscr(); gotoxy(41,5); printf("Cheats Activated!"); gotoxy(23,18); printf("Press Any Key..."); getch(); } else if(cheats == 1) { cheats = 0; strcpy(ce,"Off"); mainscr(); gotoxy(41,5); printf("Cheats Deactivated!"); gotoxy(23,18); printf("Press Any Key..."); getch(); } } if(cmd == 1) { newgame = 1; cont = 0; gameover = 0; nextplayer = 1; game = 1; for(box = 1; box < 10; box++) { ch[box] = ' '; } wins[0] = 0; wins[1] = 0; lose[0] = 0; lose[1] = 0; draw = 0; x[0] = 16; x[1] = 17; strcpy(name[0],"P1"); strcpy(name[1],"P2"); mainscr(); gotoxy(3,18); printf("Enter Name P1:"); gotoxy(23,18); scanf("%s",name[0]); mainscr(); gotoxy(3,18); printf("Enter Name P2:"); gotoxy(23,18); scanf("%s",name[1]); maingame(); } if(cmd ==2) { if(game != 0) { newgame = 0; cont = 1; gameover = 0; nextplayer = 1; game = game + 1; for(box = 1; box < 10; box++) { ch[box] = ' '; } x[2] = 16; x[3] = 17; if(((wins[0] != 3)||(wins[1] != 3))||(game < 10)) { maingame(); } if(wins[0] == 3) { mainscr(); gotoxy(41,5); printf("Game Over!"); gotoxy(41, 6); printf("Winner: %s!",name[0]); gotoxy(23,18); printf("Press Any Key..."); getch(); wins[0] = 0; wins[1] = 0; lose[0] = 0; lose[1] = 0; draw = 0; newgame = 0; cont = 0; game = 0; nextplayer = 0; strcpy(name[0],"P1"); strcpy(name[1],"P2"); } else if(wins[1] == 3) { mainscr(); gotoxy(41,5); printf("Game Over!"); gotoxy(41, 6); printf("Winner: %s!",name[1]); gotoxy(23,18); printf("Press Any Key..."); getch(); wins[0] = 0; wins[1] = 0; lose[0] = 0; lose[1] = 0; draw = 0; newgame = 0; cont = 0; game = 0; nextplayer = 0; strcpy(name[0],"P1"); strcpy(name[1],"P2"); } else if((game == 9)&&((wins[0] != 3)||(wins[1] != 3))) { mainscr(); gotoxy(41,5); printf("Game Over!"); gotoxy(41, 6); printf("It's A Draw!"); gotoxy(23,18); printf("Press Any Key..."); getch(); wins[0] = 0; wins[1] = 0; lose[0] = 0; lose[1] = 0; draw = 0; newgame = 0; cont = 0; game = 0; nextplayer = 0; strcpy(name[0],"P1"); strcpy(name[1],"P2"); } } else { mainscr(); gotoxy(23,18); printf("Input Error: Cannot continue, try a new game..."); getch(); } } if(cmd == 3) { x[4] = 16; x[5] = 17; mainscr(); gotoxy(41,5); printf("You need to match 3 "); gotoxy(41,6); printf("'x' (if player 1) or"); gotoxy(41,7); printf("3 'o' (if player 2) "); gotoxy(41,8); printf("in a line."); gotoxy(41,10); printf("You must score 3 "); gotoxy(41, 11); printf("points in 9 games "); gotoxy(41, 12); printf("to win."); gotoxy(41,14); printf("Help by: Reed"); gotoxy(23,18); printf("Press Any Key..."); getch(); } if(cmd == 4) { x[6] = 16; x[7] = 17; exiton = 1; } if((cmd > 4)||(cmd < 0)) { mainscr(); gotoxy(23,18); printf("Input Error: Enter Command (1-4)"); getch(); } } mainscr(); gotoxy(23,18); printf("Press Any Key To Exit..."); getch(); }