Original Post
I create a thread yesterday saying i had timing issues for my tetris game and after looking at it longer, i realize it wasn't the timer that was not working right it was that the render only redraws if i'm doing sometihng in the window, (ie, move the mouse over the window, or hit a key or something.)
I'm not sure how to tell it to redraw each time. I tried creating a thread and putting the render in a new thread and that worked ok but my keyboard responces were very slow.
[edited by - Ryanrk on July 30, 2002 4:11:22 PM]
void Render(HWND hWnd)
{
if( dx8._pd3dDevice == NULL)
return;
dx8._pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET,
D3DCOLOR_XRGB(0,0,0), 1.0f, 0 );
dx8._pd3dDevice->BeginScene();
BltSpriteEx( NULL, texture, NULL, NULL );
DWORD timer;
int up[4] = {0,0,0,0};
timer = GetTickCount();
blocks.movedown();
while(GetTickCount() - timer < 800){
m_keyboard->GetDeviceState(sizeof(unsigned char[256]), (LPVOID)keystate);
if (KeyDown(keystate, DIK_LEFT)){
up[0] = 1;
} else if (KeyDown(keystate, DIK_RIGHT)){
up[1] = 1;
} else if (KeyDown(keystate, DIK_DOWN)){
up[2] = 1;
} else if (KeyDown(keystate, DIK_UP)){
up[3] = 1;
}
if(KeyUp(keystate, DIK_LEFT) && (up[0] == 1)){
blocks.moveleft();
up[0] = 0;
} else if(KeyUp(keystate, DIK_RIGHT) && (up[1] == 1)){
blocks.moveright();
up[1] = 0;
} else if(KeyUp(keystate, DIK_DOWN) && (up[2] == 1)){
blocks.movedown();
up[2] = 0;
} else if(KeyUp(keystate, DIK_UP) && (up[3] == 1)){
blocks.rotate();
up[3] = 0;
}
}
blocks.showpiece(); //draws the board on the screen
// End the scene
dx8._pd3dDevice->EndScene();
// Present the backbuffer contents to the display
dx8._pd3dDevice->Present( NULL, NULL, NULL, NULL );
}