6.2. Processor-independent simulation speed
What value should we use for an animation’s dt ? We’d like to make it somewhat independent of the speed at which our program is running. The run speed can be influenced not only by your processor speed, but also by the size of your game window, and whether or not you have multiple views or documents open in your game. As far as possible, we’d like the apparent speed of our moving creatures to stay the same.
What exactly does this mean? As we discuss in Chapter 7: Simulating Physics, we give each simulation object a vector _position and a vector _velocity. For each update cycle, we compute an appropriate time step dt, we update our _velocity, and then we use the standard rule:
_position = _position ...
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.