Jump to content
  • Advertisement
Sign in to follow this  
ecr0n

Timer Question...

This topic is 5030 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

	
static int temp_lag=0;

if(GetTickCount()-temp_lag>bullet_lag) {
    if(KEYDOWN(VK_UP)) {
    //do stuff
    }
    temp_lag=GetTickCount();
}
The problem with the above code is that when i first load the game and attempt to use KEYDOWN(VK_UP) it doesn't work.. i know this is because the if statement hasn't been fulfilled. My question is if there is anyway around this?

Share this post


Link to post
Share on other sites
Advertisement
Would it be possible to assign temp_lag a negative interger so that the condition would filled? After the initial run through, the contents of temp_lag would be a valid value for your application.

Share this post


Link to post
Share on other sites
Original post by ecr0n
	
static int temp_lag=0;

if(GetTickCount()-temp_lag>bullet_lag) {
if(KEYDOWN(VK_UP)) {
//do stuff
}
temp_lag=GetTickCount();
}


isn't anything minus 0 always itself?

Share this post


Link to post
Share on other sites
How about this?

static int temp_lag=0;

if((GetTickCount()-temp_lag>bullet_lag) || temp_lag == 0) {
if(KEYDOWN(VK_UP)) {
//do stuff
}
temp_lag=GetTickCount();
}

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!