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
updateChildren(), of which the former is virtual.
All update functions take the frame time
dt as a parameter of type
sf::Time (the SFML class for time spans). This is the frame time we computed for the
Game class in Chapter 1, Making...