Game Development Reference
In-Depth Information
while (!HasFinished())
{
GivePlayerOptions();
stringstream playerInputStream;
GetPlayerInput(playerInputStream);
EvaluateInput(playerInputStream);
bool playerWon = true;
for (auto& enemy : m_enemies)
{
playerWon &= enemy->IsAlive() == false;
}
if (playerWon)
{
SetPlayerWon();
}
}
if (GetPlayerWon())
{
SerializationManager::GetSingleton().ClearSave();
cout << "Congratulations, you rid the dungeon of monsters!" << endl;
cout << "Type goodbye to end" << endl;
std::string input;
cin >>input;
}
}
The range-based for loop can be used in conjunction with the auto keyword to provide easy,
portable iteration over many STL collections. You can see it in action in RunGame where there is a loop
over the m_enemies vector .
A paired_task is used to execute save game loading on a separate thread of execution. The
std::thread::get_future method is used to acquire a future object that lets you know when the
task you were executing has been completed. This approach to loading can be used to allow you to
load games while updating a dynamic loading screen.
There is also an example of how to use cin and cout to read player input and write out messages to
the console. Input and output are fundamental concepts for game developers as they are essential
to providing the interactivity that players expect from games.
 
Search WWH ::




Custom Search