making object move by fps

Abd4b56ff96074042dda5243e99a5d14
0
Anddos 103 Mar 21, 2012 at 14:32

for my game timer i am using TimeGetTime , i know there is other methods but i want to try this way for a chance, here is the code…

before i enter the MSG loop

MSG msg;

static float lastTime = (float)timeGetTime();

while(TRUE)
{

if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
if (msg.message == WM_QUIT)
break;

TranslateMessage(&msg);
DispatchMessage(&msg);
}

render_frame();

// check the ‘escape’ key
if(KEY_DOWN(VK_ESCAPE))
PostMessage(hWnd, WM_DESTROY, 0, 0);

float currTime = (float)timeGetTime();
float timeDelta = (currTime - lastTime)*0.001f; //0.001f;
gDelta = timeDelta;
}

and when i go to render the d3d object

static float z = 0.0f;
D3DXMATRIX matRotateY,matTrans; // a matrix to store the rotation for each triangle
D3DXMatrixTranslation(&matTrans,0.0f,0.0f,z*gDelta*1.0f);
d3ddev->SetTransform(D3DTS_WORLD, &(matTrans)); // set the world transform

3 Replies

Please log in or register to post a reply.

820ce9018b365a6aeba6e23847f17eda
0
geon 101 Mar 21, 2012 at 15:21

I think you forgot to actually ask something. Do you have a question?

Abd4b56ff96074042dda5243e99a5d14
0
Anddos 103 Mar 21, 2012 at 17:17

hehe you are right, i forgot to add how to calculate the fps now :)

Abd4b56ff96074042dda5243e99a5d14
0
Anddos 103 Mar 21, 2012 at 17:58

ive got this sorted now, so no need to help now