How do you make a basic timer?

Started by
14 comments, last by kingpinzs 20 years, 2 months ago
I already read and printed it off and every thing but I dont see how that will fit into my code you see. and if I cant see how it fits then how can I use it.

this is were it will go

void GameLoop(){ if(GamePaused){}else if(  timeGetTime() > start_time + faster )    {      PlaySound("MenuKnopka.wav ", hInstMain, SND_ASYNC | SND_FILENAME );        Move(0,1);        start_time=GetTickCount();        }    elseif (Level = 10){NewLevel();}}int NewLevel(){int faster;//int Level;if( StartTime + faster < timeGetTime()){PlaySound("MenuKnopka.wav ", hInstMain, SND_ASYNC | SND_FILENAME );        --faster;       // Level = 0;        Move(0,1);        start_time=GetTickCount();                } }


I need the timer to work like this

when timer hits 1000 then move image do that tell level = 10
then when timer hits 500 then move image do that tell level = 10

so how would WM_TIMER work very well here I cant have it in my winproc becaus buttons are being hit and when buttons are hit it stops the timer understand


[edited by - kingpinzs on February 22, 2004 11:28:46 PM]
Advertisement
ok i thought u wanted something to print to the screen every ''x'' seconds.

using the timer class I gave before
this next bit of code may not be the full thing of what you wanted but it may help u to figure this out

CTimer Timer;float TimeTrack;// InitTimer.Init();// LoopTimer.Update();TimeTrack += m_Timer.GetElapsed();// If one second has elapsedif( TimeTrack >= 1.0f ){  TimeTrack = 0.0f;  // Move the thing down  Move(0, 1);}


let me know if this is going in the right direction
How do I use this
DWORD Wait_Clock(DWORD count);

I am getting error

[Linker error] undefined reference to `Wait_Clock(unsigned long)''
what do I include for this to work?
why does this not work?

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////void GameLoop(){       if(GamePaused)       {       }else    Start_Clock();if (Level >= 1)    {      if(( Get_Clock() - start_time) > faster)    {      PlaySound("MenuKnopka.wav ", hInstMain, SND_ASYNC | SND_FILENAME );        Move(0,1);        start_time=Get_Clock();              }  }elseif (Level >= 1){NewLevel();//start_time=Get_Clock();}}//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////int NewLevel(){int Level;if (Level >= 1);++faster;     if ( (Get_Clock() - start_time) > faster * 1000)    {      PlaySound("MenuKnopka.wav ", hInstMain, SND_ASYNC | SND_FILENAME );        Move(0,1);        start_time=Get_Clock();        Level = 1;      }                                       }


[edited by - kingpinzs on February 23, 2004 12:56:31 AM]
one part i noticed is in your NewLevel() function

int Level; // non initialized integer var
if (Level >= 1); // this will not be accurate as Level has not been assigned a value
++faster; // this is done each time NewLevel() is called instead of when level is greater than 1 due to a semi-colon at the end of your if statement

did my previous post help u at all ?
eFoDay thanks for your help. I just got it to work.

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////void GameLoop(){       if(GamePaused)       {       }else    if (Level < 1)    {      if(( Get_Clock() - start_time) > faster)    {     start_clock_count = 0;        start_time=Get_Clock();      PlaySound("MenuKnopka.wav ", hInstMain, SND_ASYNC | SND_FILENAME );        Move(0,1);             }  }elseif (Level >= 1){NewLevel();//start_time=Get_Clock();}}//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


this is what I was trying to do all the time now I just need to put it into a loop and increase the speed ever so often

This topic is closed to new replies.

Advertisement