I’m having a problem with evenly moving sprites; Currently I’m using a while loop to move them, the problem with this being the faster the computer, the faster the loop goes and the faster the sprites move. I have tried the timer / clock function (wait?) in pygame and it freezes the cursor while it waits, therefore maiking the cursor jumpy.
Is multi-threading the answer?
Here’s a video of my problem;
http://www.youtube.com/watch?v=cFawkUJhf30
You’re dependent of the framerate, faster the framerate is, faster your movement will be.
Usually, we are calculating the time between 2 frames/loop iteration, and we called it the “delta time”. Then we multiply that delta time to the movement vector.
Here is a loop sample:
Then the movement are following the framerate: if your loop is faster, then the delta is lower, and then the movement are slower per frame => the result will have the same speed whatever the framerate is.
You’re now framerate independent.