Game Development Reference
In-Depth Information
The main change here is that a win condition has been added to the game loop. The while condition
now checks to see whether the user has chosen the quit option or if they have won. The playerWon
bool is set to true once both of the enemies in the game world have been killed, which also means
the player successfully opened the Chest .
Summary
This update to Text Adventure concludes this part of the topic. I've given you a whirlwind tour of the
most useful STL containers for game developers and you should now be able to use these in your
own projects with ease.
This chapter has shown some practical examples of how you can deploy STL containers in game
code. You've seen that STL array can be used for data that you know will remain constant, such as
the Rooms in the world or the JoiningDirections in each Room . You've also seen how a vector can be
used for more dynamic data structures. Text Adventure uses vectors to store dynamic options that
are erased after they are used and also to hold the Player class's inventory, which would allow the
inventory to grow until the memory available on the computer is exhausted. You also saw how a map
can be used to provide convenient access to objects via a key-data pair relationship.
Hopefully by now you're also comfortable with the C++ syntax for specializing templates. The next
part of this topic is going to show you how you can create your own template methods and classes
to do some really neat and powerful things in the C++ programming language.
 
Search WWH ::




Custom Search