I am trying to make my game run based off the delta between 2 frames, so that it will run the same speed on every computer.
I am trying to get the delta between 2 frames like this:
static DWORD lastFrameTime;
static DWORD frameDelta;
frameDelta = timeGetTime() - lastFrameTime;
d3dDevice->Clear(0, 0, D3DCLEAR_TARGET, 0x000000, 1, 0);
d3dDevice->BeginScene();
d3dSpriteMachine->Begin(D3DXSPRITE_ALPHABLEND);
Draw(sprite, frameDelta);
d3dSpriteMachine->End();
d3dDevice->EndScene();
d3dDevice->Present(NULL, NULL, NULL, NULL);
Update(mousePosition, frameDelta);
lastFrameTime = timeGetTime();
The problem is that the delta always ends up 0, or at most, 1. I tried stepping through the code and I find that when lastFrameTime is set to timeGetTime() at the end, then on the next frame the time is the same. What I mean, is that it appears to be run through one frame on say 123342342 (this is just an example) and then on the second frame, timeGetTime returns 123342342 again so the delta is set to 0. I'm obviously missing something. Any help? haha