Coding the TextureHolder Class and Building a Horde of Zombies
Now we understand the basics of the Standard Template Library (STL), we will be able to use that new knowledge to manage all the textures from the game because, if we have 1,000 zombies, we don’t really want to load a copy of a zombie graphic into the GPU for each and every one.
We will also dig a little deeper into OOP and use a static function, which is a function of a class that can be called without an instance of the class. At the same time, we will see how we can design a class to ensure that only one instance can ever exist. This is ideal when we need to guarantee that different parts of our code will use the same data.
In this chapter, we will cover the following topics:
- Implementing the
TextureHolder
class - Building a horde of zombies
- Using the
TextureHolder
class for all textures