Just wondering if something like this,
Code:
if (NewUser.location = &rooms[1])
{
some function
}
Would fit into this,
Code:
while (1)
{
// Display the players location and possible movements.
cout << "------------------\n" << endl;
cout << "Location: " << NewUser.location->name << endl;
cout << "\nDescription:\n\n" << NewUser.location->description << "\n" << endl;
if (NewUser.location->north)
cout << "(N)orth to: " << NewUser.location->north->name << endl;
if (NewUser.location->south)
cout << "(S)outh to: " << NewUser.location->south->name << endl;
if (NewUser.location->east)
cout << "(E)ast to: " << NewUser.location->east->name << endl;
if (NewUser.location->west)
cout << "(W)est to: " << NewUser.location->west->name << endl;
cout << "(Q)uit" << endl;
// Get input and decide where to go next.
char input;
string inputString;
getline(cin,inputString); // Grab everything in the buffer, even if it's more than one character.
input = inputString[0]; // Only use the first character, discard the rest.
if (input == 'q')
break;
cout << quizMaster.poseQuestion().c_str() << endl;
getline(cin, answer);
if (quizMaster.isCorrectAnswer(answer))
{
cout << "Thats right" << endl;
if (input == 'n' && NewUser.location->north)
NewUser.location = NewUser.location->north;
if (input == 's' && NewUser.location->south)
NewUser.location = NewUser.location->south;
if (input == 'e' && NewUser.location->east)
NewUser.location = NewUser.location->east;
if (input == 'w' && NewUser.location->west)
NewUser.location = NewUser.location->west;
}
else
{
cout << "Better luck next time !" << endl;
}
}
to add a bit of functionality into my game