Best approach for game animation?

后端 未结 7 1744
独厮守ぢ
独厮守ぢ 2020-12-15 11:13

I have a course exercise in OpenGL to write a game with simple animation of a few objects

While discussing with my partner our design options we\'ve realized we have

7条回答
  •  攒了一身酷
    2020-12-15 11:48

    Render and compute as fast as you can to get the maximum frame rate (as capped by the vertical sync)

    Don't use a timer, they're not reliable < 50-100 ms on Windows. Check how much time has passed. (Usually, you need both delta t and an absolute value, depending on if your animation is physics or keyframe based.)

    Also, if you want to be stable, use an upper/lower bound on your time-step, to go into slow-motion if a frame takes a few secs to render (disc access by another process?) or skip an update if you get two of them within say 10 ms.

    Update (Since this is a rather popular answer)

    I usually prefer having a fixed time-step, as it makes everything more stable. Most physics engines are pretty robust against varying time, but other things, like particle systems or various simpler animations or even game logic, are easier to tune when having everything run in a fixed time step.

    Update2 (Since I got 10 upvotes ;)

    For further stability over long periods of running (>4 hours), you probably want to make sure you're not using floats/doubles to compute large time differences, since you lose precision doing so and your game's animations/physics will suffer. Use fixed point (or 64-bit microsecond-based) integers instead.

    For the hairy details, I recommend reading A matter of precision by Tom Forsyth.

提交回复
热议问题