Quantcast
Channel: CodeGuru Forums - Visual C++ Programming
Viewing all articles
Browse latest Browse all 3042

Time calculation in the main game loop.

$
0
0
There is the code in the Quake 2 main game loop implementation:

Code:

    if (!initialized)
    {        // let base retain 16 bits of effectively random data
            base = timeGetTime() & 0xffff0000;
            initialized = true;
    }
    curtime = timeGetTime() - base;

I'm wondering about the line:
Quote:

base = timeGetTime() & 0xffff0000
Why are they applying the
Quote:

0xffff0000
mask on the retrieved time?
Why not to use just:

Code:

if (!initialized)
    {        // let base retain 16 bits of effectively random data
            initialTime = timeGetTime();
            initialized = true;
    }
    curtime = timeGetTime() - initialTime;

???
What is the role of that mask?

Viewing all articles
Browse latest Browse all 3042

Trending Articles