Integrating the Game class

By now we already know how the Game class works, what a game loop is for, and how to take advantage of it. For this chapter, we take the previously used Game class, and plug into it our newcomer World class.

Because we obeyed a few principles, this integration is very easy and it's just a matter of having a World object inside the Game class, and then letting it update and draw itself in the appropriate times.

The run() method

Our application's main() function has a simple job. It allocates a Game object, and lets it run itself through the run() method. When the run() method exits, the program releases its resources and closes.

Therefore, it is within the run() method that the magic happens! It is responsible for managing ...

Get SFML 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.