Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Sfpiano

Timed action not working properly

This topic is 5442 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 FLOAT fLastTime = 0.0f;
    FLOAT fTime = DXUtil_Timer(TIMER_GETABSOLUTETIME);

	if(iResrcAmt>12)
		iResrcAmt=0;

	if(iResrcAmt<12){
		if(fTime - fLastTime > 1.0f){
			iResrcAmt++;
			fLastTime=fTime;
			fTime = DXUtil_Timer(TIMER_GETABSOLUTETIME);
		}
	}

//other code
 
Here''s the source for the DXUtil timer: http://if.dynsite.net/t-pot/program/72_HLSL/dxutil_cpp.html The problem is that the above function only increments the value once, and then it stops. I tried using a while(iResrcAmt<12), but that just froze my program.

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
from just looking at the if statements in your loop, you deal with iResrcAmt<12 and iResrcAmt>12, but what about when iResrcAmt==12? it isn''t resetting iResrcAmt to 0 once it reaches 12. try doing:

if(iResrcAmt>=12)

Share this post


Link to post
Share on other sites
That didn''t really seem to do anything. I had that first line in there because it was saying the value of that int was 13447780 even though I already initialised it to zero and didn''t touch it until this function.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!