Game Development Reference
In-Depth Information
if (playerInput.compare("1") == 0)
{
cout << "You have chosen to Go North!" << endl << endl;
chosenOption = PlayerOptions::GoNorth;
}
else if (playerInput.compare("2") == 0)
{
cout << "You have chosen to Go East!" << endl << endl;
chosenOption = PlayerOptions::GoEast;
}
else if (playerInput.compare("3") == 0)
{
cout << "You have chosen to Go South!" << endl << endl;
chosenOption = PlayerOptions::GoSouth;
}
else if (playerInput.compare("4") == 0)
{
cout << "You have chosen to Go West!" << endl << endl;
chosenOption = PlayerOptions::GoWest;
}
else if (playerInput.compare("5") == 0)
{
cout << "You have chosen to Quit!" << endl << endl;
chosenOption = PlayerOptions::Quit;
}
else
{
cout << "I do not recognize that option, try again!" << endl << endl;
}
return chosenOption;
}
Your player will now see options 1 through 5 to choose which room to move to or whether he or she
would like to quit. The last task required is to move the m_player object to the new selected Room .
Listing 10-21 shows how you can achieve this in the new UpdateOnOption method.
Listing 10-21. Moving the Player in UpdateOnOption
void Game::UpdateOnOption(PlayerOptions selectedOption)
{
if (selectedOption == PlayerOptions::GoNorth ||
selectedOption == PlayerOptions::GoEast ||
selectedOption == PlayerOptions::GoSouth ||
selectedOption == PlayerOptions::GoWest)
{
Room::JoiningDirections directionToMove
= Room::JoiningDirections::North;
 
Search WWH ::




Custom Search