Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm about to start building a game and am having trouble understanding the proper course of action when it's time to refresh the screen, but the model hasn't finished its calculations. I assume this isn't a huge problem for my little 2d platformer, but with many complex games there must be some hefty calculations that don't render in 1/30th of a second - I see these games stutter, but what's going on? Is the view just skipping this cycle? Is it an observer that's waiting for the model and will hang until the model is ready? Or will it display the models current state without regard to the computations ongoing? What's the correct way to handle this situation?

share|improve this question

1 Answer 1

up vote 4 down vote accepted

The correct way is to skip that frame and wait until the model is ready. If you find that the model update is taking too long, causing frames to be skipped too often, it's a better solution to optimize that instead of overcomplicating the code trying to be smart on the view side.

A popular alternative is to use frame interpolation in the view, but it's not a good solution. When the update is fast enough, the difference isn't visible: it turns out that interpolation was not necessary after all and it comes with the development cost of having to implement it. When the update is slow enough, you start perceiving weird rendering artifacts. These artifacts come from the fact that the formulas used by the view for the interpolation step are just an approximation of what the model is doing, with big steps come big approximation errors. E.g. you won't be implementing a parallel collision detection system in the view, because that's the job of the model to start with.

So, with interpolation, you basically replaced one problem by another. Just skip the frames and optimize the update code.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.