Giter VIP home page Giter VIP logo

Comments (4)

Bilalmirza avatar Bilalmirza commented on May 29, 2024

while (lag >= MS_PER_UPDATE) /// ensures a certain time (MS_PER_UPDATE) has passed, and sleep isn't required
{
update();
lag -= MS_PER_UPDATE;
}

from game-programming-patterns.

mikehaertl avatar mikehaertl commented on May 29, 2024

I still don't quite get it. Here's an example with some numbers:

  • MS_PER_UPDATE = 10
  • update() takes 5
  • render() takes 20

In the first cycle there's no update() (lag = 0).

In the second cycle lag = 25 (5 + 20) so I see 2 calls to update() in a row and there's no pause in between.

In the third cycle there will even be 3 calls (lag = 30) with no break in between. How is this considered fixed time steps?

from game-programming-patterns.

Bilalmirza avatar Bilalmirza commented on May 29, 2024

since render is not called when catching up. The Displayed objects will work correctly.

its covered in.

https://gameprogrammingpatterns.com/game-loop.html

and more detail in here

https://gafferongames.com/post/fix_your_timestep/

from game-programming-patterns.

mikehaertl avatar mikehaertl commented on May 29, 2024

My problem was that all the statements and the diagram relate to game time, not real time. Not sure if this could be made more clear. I still find the diagram above misleading, though, because IMO this first diagram here does not relate to game time but real time:

game-loop-simple

from game-programming-patterns.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.