Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Tic Tac Toe Game (made in C++)
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
eagles358
Expert Cheater
Reputation: 0

Joined: 10 Apr 2007
Posts: 174

PostPosted: Wed Jul 04, 2007 3:21 pm    Post subject: Tic Tac Toe Game (made in C++) Reply with quote

Im still pretty new to c++, but i made this tac tac toe game. I thought id post it to see what people think of it and to get some suggestions on ways to improve it. Thanks in advanced for checking it out.

I used Dev-C++ compiler, heres a link for the exe

http://rapidshare.com/files/41093810/eagles358_s_tic_tac_toe.exe

Code:
#include <iostream>
#include <string.h>
using namespace std;

string board[9] = {"[ ]","[ ]","[ ]","[ ]","[ ]","[ ]","[ ]","[ ]","[ ]"};

void show_board();
void p1_turn();
void p2_turn();


int main() {
int i=0;
 
cout<< "***Welcome to Eagles358's 2 player Tic-Tac-Toe Game!***\n\n";
 string p1;
 string p2;
 cout<<"Player 1 enter your name: \n";
 cin>>p1;
 cout<<"Player 2 enter your name: \n";
 cin>>p2;
 
int a;
while (1) {
      for(int t=0;t<9;t++)
      board[t]="[ ]";
cout<<"Have you played this before? (1 for yes, 2 for no, 0 to exit)";
    cin>>a;
    if (a==1)
    cout<<"Enjoy the game!\n\n";
    else if (a==2){
    cout<<"\n\nHere are the instructions:\n\n";
    cout<<"Player 1 is X's and player 2 is O's.\n";
    cout<<"Player 1 goes first.\n";
    cout<<"To specify a box to mark, enter its number.\n\n";
    cout<<"These are the numbers for each box: \n";
    cout<<"[1][2][3]\n[4][5][6]\n[7][8][9]\n\n";
    cout<<"Ex: X would be at box 3 \n\n";
    cout<<"[ ][ ][X]\n[ ][ ][ ]\n[ ][ ][ ]\n\n";
    cout<<"Ex: O would be at box 5 \n\n";
    cout<<"[ ][ ][ ]\n[ ][O][ ]\n[ ][ ][ ]\n\n";
    cout<<"To win a player must mark 3 boxes that are in a row.\n";
    cout<<"Ex: O's would win in this game\n\n";
    cout<<"[O][X][X]\n[X][O][X]\n[O][X][O]\n";
    cout<<"Those are the instructions. Enjoy the game!\n\n";
}
    else
    return 0;

 
 while (1) {
 p1_turn();
 i++;
 if ( (board[0]=="[X]")&&(board[0]==board[1])&&(board[2]==board[1]) ){
     show_board();
     cout<<p1<<" OWNED "<<p2<<"!";
     break;
     }
else if ( (board[0]=="[O]")&&(board[0]==board[1])&&(board[2]==board[1]) ){
     show_board();
     cout<<p2<<" OWNED "<<p1<<"!";
     break;
     }
else if ( (board[0]=="[X]")&&(board[0]==board[3])&&(board[3]==board[6]) ){
     show_board();
     cout<<p1<<" OWNED "<<p2<<"!";
     break;
     }
else if ( (board[0]=="[O]")&&(board[0]==board[3])&&(board[3]==board[6]) ){
     show_board();
     cout<<p2<<" OWNED "<<p1<<"!";
     break;
     }
else if ( (board[3]=="[X]")&&(board[4]==board[3])&&(board[3]==board[5]) ){
     show_board();
     cout<<p1<<" OWNED "<<p2<<"!";
     break;
     }
     else if ( (board[3]=="[O]")&&(board[4]==board[3])&&(board[3]==board[5]) ){
     show_board();
     cout<<p2<<" OWNED "<<p1<<"!";
     break;
     }
     else if ( (board[6]=="[X]")&&(board[6]==board[7])&&(board[6]==board[8]) ){
     show_board();
     cout<<p1<<" OWNED "<<p2<<"!";
     break;
     }
     else if ( (board[6]=="[O]")&&(board[6]==board[7])&&(board[6]==board[8]) ){
     show_board();
     cout<<p2<<" OWNED "<<p1<<"!";
     break;
     }
else if ( (board[1]=="[X]")&&(board[1]==board[4])&&(board[4]==board[7]) ){
     show_board();
     cout<<p1<<" OWNED "<<p2<<"!";
     break;
     }
else if ( (board[1]=="[O]")&&(board[1]==board[4])&&(board[4]==board[7]) ){
     show_board();
     cout<<p2<<" OWNED "<<p1<<"!";
     break;
     }
else if ( (board[2]=="[X]")&&(board[2]==board[5])&&(board[5]==board[8]) ){
     show_board();
     cout<<p1<<" OWNED "<<p2<<"!";
     break;
     } 
     else if ( (board[2]=="[O]")&&(board[2]==board[5])&&(board[5]==board[8]) ){
     show_board();
     cout<<p2<<" OWNED "<<p1<<"!";
     break;
     } 
     else if ( (board[0]=="[X]")&&(board[0]==board[4])&&(board[4]==board[8]) ){
     show_board();
     cout<<p1<<" OWNED "<<p2<<"!";
     break;
     }   
     else if ( (board[0]=="[O]")&&(board[0]==board[4])&&(board[4]==board[8]) ){
     show_board();
     cout<<p2<<" OWNED "<<p1<<"!";
     break;
     }   
     else if ( (board[2]=="[X]")&&(board[2]==board[4])&&(board[4]==board[6]) ){
     show_board();
     cout<<p1<<" OWNED "<<p2<<"!";
     break;
     }   
     else if ( (board[2]=="[O]")&&(board[2]==board[4])&&(board[4]==board[6]) ){
     show_board();
     cout<<p2<<" OWNED "<<p1<<"!";
     break;
     }
     else if ( (board[0]!="[ ]")&&(board[1]!="[ ]")&&(board[2]!="[ ]")&&(board[3]!="[ ]")&&(board[4]!="[ ]")&&(board[5]!="[ ]")&&(board[6]!="[ ]")&&(board[7]!="[ ]")&&(board[8]!="[ ]")){
     cout<<"Its a tie!\n";
     cout<<"Eagles358 OWNED "<<p1<<" and "<<p2<<"!";
     break;
     }
    else  if (i==9)  {
     cout<<"Its a tie!\n";
     cout<<"Eagles358 OWNED "<<p1<<" and "<<p2<<"!";
     break;
     }
   
 p2_turn();
 i++;
  if ( (board[0]=="[X]")&&(board[0]==board[1])&&(board[2]==board[1]) ){
     show_board();
     cout<<p1<<" OWNED "<<p2<<"!";
     break;
     }
else if ( (board[0]=="[O]")&&(board[0]==board[1])&&(board[2]==board[1]) ){
     show_board();
     cout<<p2<<" OWNED "<<p1<<"!";
     break;
     }
else if ( (board[0]=="[X]")&&(board[0]==board[3])&&(board[3]==board[6]) ){
     show_board();
     cout<<p1<<" OWNED "<<p2<<"!";
     break;
     }
else if ( (board[0]=="[O]")&&(board[0]==board[3])&&(board[3]==board[6]) ){
     show_board();
     cout<<p2<<" OWNED "<<p1<<"!";
     break;
     }
else if ( (board[3]=="[X]")&&(board[4]==board[3])&&(board[3]==board[5]) ){
     show_board();
     cout<<p1<<" OWNED "<<p2<<"!";
     break;
     }
     else if ( (board[3]=="[O]")&&(board[4]==board[3])&&(board[3]==board[5]) ){
     show_board();
     cout<<p2<<" OWNED "<<p1<<"!";
     break;
     }
    else  if ( (board[6]=="[X]")&&(board[6]==board[7])&&(board[6]==board[8]) ){
     show_board();
     cout<<p1<<" OWNED "<<p2<<"!";
     break;
     }
    else  if ( (board[6]=="[O]")&&(board[6]==board[7])&&(board[6]==board[8]) ){
     show_board();
     cout<<p2<<" OWNED "<<p1<<"!";
     break;
     }
else if ( (board[1]=="[X]")&&(board[1]==board[4])&&(board[4]==board[7]) ){
     show_board();
     cout<<p1<<" OWNED "<<p2<<"!";
     break;
     }
else if ( (board[1]=="[O]")&&(board[1]==board[4])&&(board[4]==board[7]) ){
     show_board();
     cout<<p2<<" OWNED "<<p1<<"!";
     break;
     }
else if ( (board[2]=="[X]")&&(board[2]==board[5])&&(board[5]==board[8]) ){
     show_board();
     cout<<p1<<" OWNED "<<p2<<"!";
     break;
     } 
     else if ( (board[2]=="[O]")&&(board[2]==board[5])&&(board[5]==board[8]) ){
     show_board();
     cout<<p2<<" OWNED "<<p1<<"!";
     break;
     } 
     else if ( (board[0]=="[X]")&&(board[0]==board[4])&&(board[4]==board[8]) ){
     show_board();
     cout<<p1<<" OWNED "<<p2<<"!";
     break;
     }   
     else if ( (board[0]=="[O]")&&(board[0]==board[4])&&(board[4]==board[8]) ){
     show_board();
     cout<<p2<<" OWNED "<<p1<<"!";
     break;
     }   
     else if ( (board[2]=="[X]")&&(board[2]==board[4])&&(board[4]==board[6]) ){
     show_board();
     cout<<p1<<" OWNED "<<p2<<"!";
     break;
     }   
     else if ( (board[2]=="[O]")&&(board[2]==board[4])&&(board[4]==board[6]) ){
     show_board();
     cout<<p2<<" OWNED "<<p1<<"!";
     break;
     }
     else if ( (board[0]!="[ ]")&&(board[1]!="[ ]")&&(board[2]!="[ ]")&&(board[3]!="[ ]")&&(board[4]!="[ ]")&&(board[5]!="[ ]")&&(board[6]!="[ ]")&&(board[7]!="[ ]")&&(board[8]!="[ ]")){
     cout<<"Its a tie!\\nn";
     cout<<"Eagles358 OWNED "<<p1<<" and "<<p2<<"!";
     break;
     }
     }     
cout<<"\n\n***THANKS FOR PLAYING!***\n\n\n";
}

}
void show_board(){

for(int i=0;i<3;i++)
cout<<board[i];
cout<<endl;

for(int i=3;i<6;i++)
cout<<board[i];
cout<<endl;

for(int i=6;i<9;i++)
cout<<board[i];
cout<<endl;
}


void p1_turn() {
     int n;
     cout<<"Its player 1's turn. Please Enter a box to mark.\n";
     cout<<"The board currently looks like this: \n";
     show_board();
     cin>>n;
     if ( (n<1)||(n>9) ){
     cout<<"Please enter a valid spot (0-8)\n";
     p1_turn();
     }
     else if(board[n-1]!="[ ]") {
     cout<<"Spot taken, try again.\n";
     p1_turn();
     }
     else
     board[n-1]="[X]";
}

void p2_turn() {
     int n;
     cout<<"Its player 2's turn. Please Enter a box to mark.\n";
     cout<<"The board currently looks like this: \n";
     show_board();
     cin>>n;
     if ( (n<1)||(n>9) ){
     cout<<"Please enter a valid spot (0-8)\n";
     p2_turn();
     }
     if(board[n-1]!="[ ]") {
     cout<<"Spot taken, try again.\n";
     p2_turn();
     }
     else
     board[n-1]="[O]";
}

 


Last edited by eagles358 on Wed Jul 04, 2007 10:14 pm; edited 11 times in total
Back to top
View user's profile Send private message
Kevin
Grandmaster Cheater Supreme
Reputation: 0

Joined: 07 Mar 2007
Posts: 1139
Location: Spiderman-World

PostPosted: Wed Jul 04, 2007 4:03 pm    Post subject: Reply with quote

lets try it ? Razz
Back to top
View user's profile Send private message MSN Messenger
Simsgy
Grandmaster Cheater
Reputation: 0

Joined: 07 May 2007
Posts: 581
Location: My new avatar <3

PostPosted: Wed Jul 04, 2007 5:20 pm    Post subject: Reply with quote

Can't you attach it?
_________________

Designer, WebMaster and a Delphi programmer.
TrPlayer, my biggest Delphi project hosted on SourceForge.net
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger
eagles358
Expert Cheater
Reputation: 0

Joined: 10 Apr 2007
Posts: 174

PostPosted: Wed Jul 04, 2007 5:27 pm    Post subject: Reply with quote

Simsgy wrote:
Can't you attach it?


do you mean the exe?
if so, i added it.
Back to top
View user's profile Send private message
Reak
I post too much
Reputation: 0

Joined: 15 May 2007
Posts: 3496

PostPosted: Wed Jul 04, 2007 6:04 pm    Post subject: Reply with quote

lool nice one Very Happy
Back to top
View user's profile Send private message
eagles358
Expert Cheater
Reputation: 0

Joined: 10 Apr 2007
Posts: 174

PostPosted: Wed Jul 04, 2007 6:10 pm    Post subject: Reply with quote

thanks Very Happy
Back to top
View user's profile Send private message
appalsap
Moderator
Reputation: 0

Joined: 27 Apr 2006
Posts: 6753
Location: Pakistan

PostPosted: Wed Jul 04, 2007 7:17 pm    Post subject: Reply with quote

Here's a tip: It makes the game less confusing if the boxes start at 1.
Back to top
View user's profile Send private message
eagles358
Expert Cheater
Reputation: 0

Joined: 10 Apr 2007
Posts: 174

PostPosted: Wed Jul 04, 2007 9:57 pm    Post subject: Reply with quote

fixed it so it starts at 1 and goes to 9. was easier than i thought. put a new link.
Back to top
View user's profile Send private message
Yukitohacker
Newbie cheater
Reputation: 0

Joined: 04 Jul 2007
Posts: 10
Location: Argentina

PostPosted: Fri Jul 06, 2007 9:22 am    Post subject: Reply with quote

The game is nice
Back to top
View user's profile Send private message
DeletedUser14087
I post too much
Reputation: 2

Joined: 21 Jun 2006
Posts: 3069

PostPosted: Fri Jul 06, 2007 9:57 am    Post subject: Reply with quote

Nice try on stealing credits loser Laughing

go pick up a book fag

Token from - Here

Or just google and you'll see many results,im quit sure you didnt made it.
Back to top
View user's profile Send private message
appalsap
Moderator
Reputation: 0

Joined: 27 Apr 2006
Posts: 6753
Location: Pakistan

PostPosted: Fri Jul 06, 2007 10:11 am    Post subject: Reply with quote

Kaspersky wrote:
Nice try on stealing credits loser Laughing


Oh ok let's see what this code thief has to say about code thieving.

Kaspersky wrote:
go pick up a book fag


Sounds like someone's insecure about their sexuality.

Kaspersky wrote:
Token from - Here

Or just google and you'll see many results,im quit sure you didnt made it.


Kaspersky, did you even look at the source code on the site you posted? Completely different. Shame on you.
Back to top
View user's profile Send private message
BoRed
Grandmaster Cheater Supreme
Reputation: 0

Joined: 24 Apr 2007
Posts: 1176
Location: ╞|ous█

PostPosted: Fri Jul 06, 2007 12:22 pm    Post subject: Reply with quote

Tic tac toe. Nice. Always been a classic.
_________________
I got my old name back.......=)

Working on making website for stealth trainers (almonst done just having technical troubles)
Stealth forums will be down for 8 days or more starting august 2 saturday.
Back to top
View user's profile Send private message
eagles358
Expert Cheater
Reputation: 0

Joined: 10 Apr 2007
Posts: 174

PostPosted: Fri Jul 06, 2007 3:28 pm    Post subject: Reply with quote

Kaspersky wrote:
Nice try on stealing credits loser Laughing

go pick up a book fag

Token from - Here

Or just google and you'll see many results,im quit sure you didnt made it.


Im sure you didnt even look at the source code. Why dont you shut the hell up and dont accuse someone of somthing if you have no clue what you are talking about. I made this 100% by myself.
Back to top
View user's profile Send private message
Nicholas
Newbie cheater
Reputation: 0

Joined: 06 Jun 2006
Posts: 22

PostPosted: Sat Jul 07, 2007 1:46 pm    Post subject: Re: Tic Tac Toe Game (made in C++) Reply with quote

eagles358 wrote:
I used Dev-C++ compiler

Dev-C++ is an integrated development environment (IDE) that uses the gcc compiler by default.

I don't know why people still choose to use Dev-C++ when it was last updated on February 22, 2005 and there are better IDEs available. Code::Blocks is free and still actively developed. You should try out the nightly builds available on their forum because the 1.0rc2 release on the Downloads page is extremely old (Oct 25, 2005) and the developers say the nightly builds are much more stable and have many more features.

Another option is the free Microsoft Visual C++ Express Edition.

_________________
pirateninja wrote:
Unsatisfied with the Cheat Engine's trainer maker, I decided to use the addresses I found using CE to make my own trainer in VB.

Dark Byte wrote:
hehe, nice joke
Back to top
View user's profile Send private message
Bomiheko
Newbie cheater
Reputation: 0

Joined: 30 Jun 2007
Posts: 21
Location: Wherever

PostPosted: Sat Jul 07, 2007 2:14 pm    Post subject: Reply with quote

Can someone please scan this?
_________________
By reading what I have just wrote down you have wasted about 5 seconds of your entire life =),
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites