This is a timer class that I wrote a while ago (cleaned up a bit for the snippet) for adding delays in some of the games I have written over the years.
Note: I normally have the class functions in a .cpp file but since it looks like I can only post in one "file" I merged them together in what would be a .h file.
The timer basically counts up in miliseconds and can be paused/resumed while maintaining the amount of miliseconds elapsed while the timer was active.
Here is a basic example of counting from 1 to 10 (FIRE!) with a 1 second delay between each increment.
#include <iostream>
#include "timer.h"
int main()
{
timer aTimer;
aTimer.Start();
for( int i = 1; i < 10; i++ )
{
std::cout << i << std::endl;
while( aTimer.GetTicks() < 1000 );
aTimer.Reset();
}
std::cout << "FIRE!" << std::endl;
return 0;
}