In Pygame, normalizing game-speed across different fps values

后端 未结 4 1192
迷失自我
迷失自我 2021-01-05 12:05

I\'m messing around with Pygame, making some simple games just to learn it. However, I\'m having a hard time implementing fps the way that I want.

From what I unders

4条回答
  •  感动是毒
    2021-01-05 12:23

    Games use a fixed-timestep for physics, while allowing the video timestep (fps) to vary. This means your update(delta) function gets called with a constant delta value. This maintains stability.

    This means in practice, update may end up being called multiple times on average per single call of draw(), depending on how much time elapses.

    For details see: Gaffer's "fix your timestep"

    A larger (python) example is at cookbook: ConstantGametime

提交回复
热议问题