From the course: C++ Design Patterns: Structural

Unlock the full course today

Join today to access over 24,800 courses taught by industry experts.

Introducing sprites

Introducing sprites

- [Instructor] I've gone ahead and created a sample application called Sprite. A Sprite is a two-dimensional graphical object, used in computer graphics and games. It usually has a texture, an image, stretched over its surface, which adds detail and realism to the object. Let's start with the Texture class. We're not building an actual graphic engine, so I kept it simple. Instead of loading the image and creating a texture, the constructor of this class just stores the name of the image file and assigns a random integer value to its MID data member. The description method returns the combined value of these properties as a string. We'll use this method to differentiate between texture objects, and it will help us reveal a severe flaw in the design of our application. Next, let's move on to the Sprite class. The Sprite class has five data members, width, height, X and Y coordinates, and the name of the image file used…

Contents