Sign in to follow this  

Timer Question...

This topic is 4817 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
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
[quote]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

This topic is 4817 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this