I've done a lot of research to find nothing, so I'm posting here. Here goes nothing.
I have two images: a red circle and a blue circle. I have some controls set up. I want the sprite to swap between the red circle and the blue circle every half second and I want it to move across the screen at the same speed of forty pixels per second, both independent from the frame rate. Can anyone give me a minimal example of this being done in C (not C++ or C#... C)? Thank you.
Frame Independent Motion/Animation in SDL
use the SDL timer class to get the elapsed seconds since last frame
then
x_pos += delta_time * 40.0f;
then
x_pos += delta_time * 40.0f;
I found something about that while I was Googling, but it has to do with C++. The timer class likely isn't present in C itself because C++ is C with Classes. There has to be some other alternative in C to what is available in C++. Or maybe I could program my own time calculator and integrate that in there...
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement