Advertisement

Capping how fast an animation plays

Started by July 30, 2021 02:52 AM
1 comment, last by Shaarigan 3 years, 3 months ago

Hey,

so I am playing around with SDL and trying to make a little game with that. My current issue while getting sprite animations to play is that they play as fast as possible. How am I able to say play an animation at 30 or 60 FPS or what ever I want to set them at?

Let me know if you need any more information!

Thanks for any help,

Loomina

You have two options to achieve that, by either capping your entire game loop to a fixed update time. How to do this is frequently asked and discussed for example here:

https://www.gamedev.net/forums/topic/707282-questions-about-fixed-timestep-game-loop/

Or the other option is to either have a second update like Unity provides (aka FixedUpdate) or couple your animations to a time delta. I guess the later is more complex so you should try to add a second update loop that runs on a fixed frequency. This can not just be useful to animations but physics as well if there is need for it one day

This topic is closed to new replies.

Advertisement