On 31.01.2010 20:44, Yanom Mobis wrote:
How do you make things happen ingame at a constant speed
regardless of frames-per-second? For example, i want my game object to
move one square per second, even if the game is running 30, 45, 60, or
90 fps.
|
Hi
make it time dependent.
<code>
# dt is the time passed since the last frame
# use a dt = min(100, dt) to make sure the longest possible frame is
100 ms long
# this prevents 'jumps' when a frame took long (as moving the window on
windows)
def update(self, dt):
self.position += self.velocity * dt
</code>
This solution may have other side effects.
~DR0ID