Jump to content

Count in 0.001 second


Recommended Posts

I want to add a number by 1 every 0.01 second. but it seems that no matter how did I change the CHANGE_INTERVAL ,  the largest number I can get is around 3500 every minute, I want it to be 6000/min

the codes are as follows:

int bulletNumber;

const float CHANGE_INTERVAL = 0.01f; 
float elapsed_time = CHANGE_INTERVAL;   

 

void  fire()
{
    if (elapsed_time < 0.0f)
    {  

        bulletNumber += 1;
        elapsed_time = CHANGE_INTERVAL;    
    }    
    elapsed_time = elapsed_time - Game::get()->getIFps();
//    Log::message("%d \n", bulletNumber);
}

 

Edited by de-Roo.Lukas
Link to comment

What's the point of adding 1 a thousand times a second? Can you really show a user-visible change in reaction to that number a thousand times a second? Say you're rendering (or ticking physics) at 50 frames per second. Then there's no reason you can't add 20 all at once each frame. It'll be the same result by the time you get to the frame logic where you need to _use_ the number.

Link to comment

sorry it is 0.01 second, I want to stimulate a minigun which will shot 6000 bullets/ min and I want to show the bullets number.

 

Link to comment

Are you just trying to do this:
 

void fire()
{
	elapsed_time += Game::get()->getIFps();
	bulletNumber = int(elapsed_time*100);
}

Once a frame whenever bullets are being fired?

  • Like 1
Link to comment
×
×
  • Create New...