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 started reading about game development design patterns and from my experience there are 2 options for update methods. The first one receive from the game loop and delta time of this update and multiple everything by it, for example position += speed * delta_time. And this will happen in the game loop without delay.

The second option is too set constant frame delay and use it. In the end of the loop function you use sleep(last_frame_time + frame_length - current_time).

Does it matter what do I use? What's more common? I know unity use the delta time technique but it's the only one I saw that use it. I would like to hear your opinions on what to use for both options.

Should I always use the first option? always the second?

Thank you for your time.

share|improve this question

closed as too broad by Josh Petrie Apr 17 at 22:31

There are either too many possible answers, or good answers would be too long for this format. Please add details to narrow the answer set or to isolate an issue that can be answered in a few paragraphs. If this question can be reworded to fit the rules in the help center, please edit the question.

    
Unity actually uses a hybrid of both: physics behaviour is updated on a fixed timestep (FixedUpdate()), while rendering as many frames as it can between physics steps. This works well for targeting a wide range of hardware (when used correctly - ie not putting framerate-sensitive gameplay code in the render Update()), ensuring gameplay will be consistent in the fixed steps while allowing rendering to scale to the capabilities of the system. A good overview of time stepping approaches can be found here: gafferongames.com/game-physics/fix-your-timestep –  DMGregory Apr 18 at 1:53