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

Updating the scene

In each frame, we update our world with all the entities inside. During an update, the whole game logic is computed: entities move and interact with each other, collisions are checked, and missiles are launched. Updating changes the state of our world and makes it progress over time, while rendering can be imagined as a snapshot of a part of the world at a given time point.

We can reuse our scene graph to reach all entities with our world updates. To achieve this, we implement a public update() member function in the SceneNode class. Analogous to the way we have proceeded for the draw() function, we split up update() into two parts: an update for the current node, and one for the child nodes. We thus write two private methods ...

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