I designed a really basic Tic Tac Toe program, but one that uses no arrays or matrixes, just a simple string system.
But if you look at it, there are about a million improvements I could make, but I dont know where to start. What do you guys suggest? I thought of using a matrix, but dont know how to use one...
Any help is welcome.
// Tic_Tac_Toe.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include "windows.h"
#include <string>
using namespace std;
string start;
string pl1;
string pl2;
string a1 = "/";
string a2 = "/";
string a3 = "/";
string b1 = "/";
string b2 = "/";
string b3 = "/";
string c1 = "/";
string c2 = "/";
string c3 = "/";
int main()
{
cout << "Welcome to 2 pl1ayer Tic Tac Toe!" << endl;
cout << "Use Num-Pad syntax! E.g. 7, 2, etc..." << endl << endl;
cout << "Type 'HELP' or 'INFO' or 'START'" << endl << endl << endl;
while(1)
{
cin >> start;
cout << endl << endl;
if(start == "HELP")
{
cout << "Use Num-Pad syntax! E.g." << endl << "789\n456\n123" << endl << endl;
}
if(start == "INFO")
{
cout << "Created by Lukeme99 using VCE2010" << endl << endl;
}
if(start == "START")
{
break;
}
}
cout << "Starting Game!" << endl << endl;
Sleep(500);
while(1)
{
cout << endl << a1 << a2 << a3 << endl << b1 << b2 << b3 << endl << c1 << c2 << c3 << endl << endl;
cin >> pl1;
if(pl1 == "7")
{
a1 = "X";
}
if(pl1 == "8")
{
a2 = "X";
}
if(pl1 == "9")
{
a3 = "X";
}
if(pl1 == "4")
{
b1 = "X";
}
if(pl1 == "5")
{
b2 = "X";
}
if(pl1 == "6")
{
b3 = "X";
}
if(pl1 == "1")
{
c1 = "X";
}
if(pl1 == "2")
{
c2 = "X";
}
if(pl1 == "3")
{
c3 = "X";
}
cout << endl << a1 << a2 << a3 << endl << b1 << b2 << b3 << endl << c1 << c2 << c3 << endl << endl;
cin >> pl2;
if(pl2 == "7")
{
a1 = "O";
}
if(pl2 == "8")
{
a2 = "O";
}
if(pl2 == "9")
{
a3 = "O";
}
if(pl2 == "4")
{
b1 = "O";
}
if(pl2 == "5")
{
b2 = "O";
}
if(pl2 == "6")
{
b3 = "O";
}
if(pl2 == "1")
{
c1 = "O";
}
if(pl2 == "2")
{
c2 = "O";
}
if(pl2 == "3")
{
c3 = "O";
}
}
return 0;
}
Thanks for any replies!

New Topic/Question
Reply



MultiQuote





|