Cleaning up the house

We have a pretty complete game. Sure, it's not going to set any records or make anyone rich, but if this is your first game, then congratulations!

We have been remiss in one area: good programming dictates that any time we create an object, we delete it when we are done using it. Up to now, you may be wondering if we were ever going to do this! Well, now is the time.

We made a placeholder for all of these operations in the EndGame function. Now, we will add the necessary code to properly release our resources.

Release sprites

Let's start by clearing out our sprites. It is important to remember that when we remove any resource, we need to make sure that it is also releasing its own resources. This is the purpose of the class destructor. ...

Get OpenGL Game Development By Example 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.