O'Reilly logo

SFML Game Development by Henrik Vogelius Hansson, Artur Moreira, Jan Haller

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required