Timer Question...

Started by
3 comments, last by grekster 19 years, 6 months ago
	
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?
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.
what is the point of ur code?
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?

Learn to make games with my SDL 2 Tutorials

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();}
Quote:Original post by BosskIn Soviet Russia, you STFU WITH THOSE LAME JOKES!

This topic is closed to new replies.

Advertisement