Chapter 19
Using the STL in Text Adventure
So far you have seen how a game can be built using classes, member variables, and C-style arrays. In this chapter you will see how you can use some of the STL classes covered in this part of the book to simplify the code you have been creating. This chapter uses polymorphism to store pointers to base classes in our STL containers. If you need a recap on polymorphism and how it is used, you should read over Chapter 11.
Some gameplay elements are also added to this chapter. Our Text Adventure game now has an end state. There are two enemies in the game world and the player must find and kill both of these enemies. Before the player will be able to attack the enemies, they must be armed with a weapon. ...
Get Learn C++ for Game Development now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.