So I understand how a game loop works (listenInputs/updateData/redrawInterface) but what I'm struggling with is how am I supposed to equalize rendering? I initially thought I had to make the thread sleep for 16.67 ms (in order to get a 60fps output on the screen) but if a user has a low quality hardware it will slow the game down instead of the traditionnal "frame skip", so I figured out this solution was not valid. So what I thought was the way to go was (in pseudo-java but langage doesn't really matter):

long start = System.currentTimeMillis();
    int tick = Math.round((System.currentTimeMillis() - start) / (1000.0 / 60));

So now anything graphical such as displaying a looping animation can easily be done by printing the specific image of the whole animation for instance. Am I right? Or is there a better solution or a way to make this one run better? But with this technique I will have to re-synchronize it every x ticks otherwise it will shift because 1000.0 / 60 is still not an exact value.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.