10.2. The game’s timestep cycle

Probably the most important method in cGame is step(Real dt). This is the method that controls the animation of the critters. First we’ll outline the order in which step does things, then we’ll explain why we use this order, and then we’ll go over the outline again.

Updating a simulation of multiple objects is a delicate thing. You need to do things in the right order, and you need to try and have the objects being updated in parallel, but all at the same time. For this reason, step is not a virtual method of cGame ; you are not supposed to override it. (All rules have exceptions, though. If you really want to override it, change it to a virtual!)

Here’s what step does in brief.

  • Adjust. Adjust game parameters. ...

Get Software Engineering and Computer Games 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.