Jump to content
  • Advertisement
Sign in to follow this  

The problem with timer

This topic is 4332 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi i have some problem to use the settimer() function, i don't know what wrong with the code, because it didn't work. My coursework is develop a game by using the Directx, and my game have a 60 second time limit, so i used SetTimer() to do it, but not working . Wish anyone could help me. declared timer at the global
#define Timer 16
i called the settimer function at the main function
INT WINAPI WinMain( HINSTANCE, HINSTANCE, LPSTR, int) { xxxxxxx xxxx SetTimer(hwnd, Timer, 1000, NULL); xxxx xxx }
then the "Timer" appeared at the MsgProc function agains, i put a few break point like below, but the program didn't run throw these part, I think it's because the uMsg not equal to WM_COMMAND or WM_TIMER, but i refer oth people example, the example of other people can work, but don't know why i used it in the same way, but it didn't work in my code.
LRESULT CALLBACK MsgProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, bool* pbNoFurtherProcessing ) { // Give the dialogs a chance to handle the message first *pbNoFurtherProcessing = g_SampleUI.MsgProc( hWnd, uMsg, wParam, lParam ); if( *pbNoFurtherProcessing ) return 0; else { switch( uMsg) { BREAK POINT-> case WM_COMMAND: switch( LOWORD(wParam) ) { case IDC_START: InitPlayingScene(d3dDevice); break; } BREAK POINT-> case WM_TIMER: { switch (wParam) { BREAK POINT---> case Timer: if ( Scene == PlayingScene ) { TimeLeft--; if( TimeLeft == 0 ) { InitResultScene(); Scene = ResultScene; } } else if(Scene == PractiseScene ) { TimeLeft--; if( TimeLeft == 0 ) { InitIntroScene(); Scene=IntroScene; } } break; } } } } }

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!