Archived

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

Timed action not working properly

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 on other sites
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 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.

• Forum Statistics

• Total Topics
628305
• Total Posts
2981962

• 9
• 12
• 11
• 12
• 11