ok so i am trying to use a tic tac toe example to build a car program that has the useer input one for the gas and two for the brake..the gas would tell the program to shit the gears up and the brake would shift the cars gear down...i would like to also like to create a board like the tic tac toe game to show the user exactly what gear they are in. but i have no idea were to start. can any body help??
i really need help getting started i think the main would look some thing like this
int main()
cout<< "learning to drive you new car!! \n.";
car civic;
cout<<"to drive press 1 to break press 2: \n";
cout<< gas(gearBox())<<endl;//print out gas which ask the user to net 1 or 2 for gas or break but then like a car it would then ask the user like using i if or else statement were the engine would blow if the car did not shift up or down
i think this is were i should start i am trying to teach my self c++ from this tic tac toe also how tic tac toe build a board i would like to build or board or some thing to show the user what gear he or she is in..
if( res == Human ) cout << "CONGRATULATIONS HUMAN --- You won!";
else if( res == Computer ) cout << "NOT SO MUCH A SURPRISE --- I won!";
else cout << "It's a draw!";
cout << endl << endl;
string r;
cout << "Play again( Y / N )? "; cin >> r;
if( r != "Y" && r != "y" ) return;
++_p %= 2;
reset();
}
}
private:
void reset()
{
for( int x = 0; x < 9; x++ )
_field[x] = None;
}
void drawGrid()
{
system( "cls" );
COORD c = { 0, 2 };
SetConsoleCursorPosition( GetStdHandle( STD_OUTPUT_HANDLE ), c );
int f = 0;
for( int y = 0; y < 5; y += 2 )
for( int x = 1; x < 11; x += 4 )
{
if( _field[f] != None )
{
COORD c = { x, 2 + y };
SetConsoleCursorPosition( GetStdHandle( STD_OUTPUT_HANDLE ), c );
string o = _field[f] == Computer ? "X" : "O";
cout << o;
}
f++;
}
c.Y = 9;
SetConsoleCursorPosition( GetStdHandle( STD_OUTPUT_HANDLE ), c );
}
int checkVictory()
{
for( int i = 0; i < 8; i++ )
{
if( _field[iWin[i][0]] != None &&
_field[iWin[i][0]] == _field[iWin[i][1]] && _field[iWin[i][1]] == _field[iWin[i][2]] )
{
return _field[iWin[i][0]];
}
}
int i = 0;
for( int f = 0; f < 9; f++ )
{
if( _field[f] != None )
i++;
}
if( i == 9 ) return Draw;
return None;
}
void getHumanMove()
{
int m;
cout << "Enter your move ( 1 - 9 ) ";
while( true )
{
m = 0;
do
{ cin >> m; }
while( m < 1 && m > 9 );
int _p;
int _field[9];
};
//--------------------------------------------------------------------------------------------------
int main( int argc, char* argv[] )
{
srand( GetTickCount() );
i just playing around trying to teach my self but i have no idea were to start but i mean like i understand tic tac toe but i am trying to write my own program but i am struggling this is not homework, but more a side project. i looked up multiple codes but have not found any thing similar to what i am truing to accomplish please help