I'm implementing simple Windows game. Here is my game loop, which I've written based on some tutorials found on the Web:

constexpr nanoseconds ms_per_update(500ms);
TimePoint current_time;
TimePoint start_time = Clock::now();
nanoseconds delta_time;
nanoseconds lag(0ms);

while (continueRunning) {   

    while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) {

        if (WM_QUIT == msg.message) {
            OutputDebugString(L"--- WM_QUIT (WndMain) ---\n");
            continueRunning = false;

    current_time = Clock::now();
    delta_time = duration_cast<std::chrono::nanoseconds>(current_time - start_time);
    start_time = current_time;
    lag += delta_time;

    while (lag >= ms_per_update) {
        lag -= ms_per_update;


Here are my questions

What really the Update and Render methods should do? Am i right that Update should for e.g. run through all game entities just updating theirs coordinates while the Render should call Render method for every game object which will just draw it on the screen having the position set by Update?

  • \$\begingroup\$ Welcome to Game Development! "Am i right that [...]" Yes. There is not much of a question in this post, you answer your question yourself. \$\endgroup\$ – Vaillancourt Jan 5 at 20:02
  • \$\begingroup\$ @Vaillancourt Ok, thx:-) \$\endgroup\$ – Daros911 Jan 5 at 20:08
  • 1
    \$\begingroup\$ Check the game-loop for more stuff on game loops, notably, this one has resurfaced lately. \$\endgroup\$ – Vaillancourt Jan 5 at 20:12
  • \$\begingroup\$ @Vaillancourt Ok, Thx again:-) \$\endgroup\$ – Daros911 Jan 5 at 20:43

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.