Game Development Reference
In-Depth Information
Listing 10-16. Calling InitializeRooms from Game::RunGame
void Game::RunGame()
{
InitializeRooms();
WelcomePlayer();
bool shouldEnd = false;
while (shouldEnd == false)
{
GivePlayerOptions();
string playerInput;
GetPlayerInput(playerInput);
shouldEnd = EvaluateInput(playerInput) == PlayerOptions::Quit;
}
}
Now that you have some Room objects in the game, you will need to keep track of which Room the
player is currently in. You can do this by adding a pointer to a Room to the Player object. Listing 10-17
shows how this can be achieved.
Listing 10-17. Adding a Room Pointer to Player
class Room;
class Player
: public Entity
{
private:
const Room* m_pCurrentRoom;
std::string m_name;
public:
Player()
{
}
void SetName(const std::string& name)
{
m_name = name;
}
const std::string& GetName() const
{
return m_name;
}
 
Search WWH ::




Custom Search