Original Post
Im trying to fix my game loop so that the game speed will be constant even if I run the game on a faster (or slower) computer. I know this involves time somehow, and Im still deciding which approach I like best.
Anyway, my problem is finding a suitable timer function. Its my understanding that there are many many different ways to obtain a reading of time in a program, and I was wondering which way is the best/ what other people use. I am currently using this code:
clock_t currentTime;
currentTime = clock();
to get a reading of time. This was the only function that I found returned a reading in milliseconds, which is what I want. (Seconds are too slow). There are two major problems with this function though:
1) Apparently the ''resolution'' is not 1 millisecond like I assumed. I think I read somewhere that it was closer to 50. Am I correct in assuming that this means I won''t be able to tell the difference between 1 millisecond of time and 49 milliseconds? Because that would be a bad thing.
2) This function only returns the time since the program started. Although this is useful for a lot of things, such as finding the relative time between two events, I would also like a function that returns the current system time, in milliseconds.
If I recall my Java days correctly, there was a handy little funciton called getTimeInMillis() or something like that, which would be perfect for me (in c++)
Also, it would be great if i could accomplish all this using standard c/c++, and not have to include a 3rd party library. But if I have to, I have to.
Thanks to anyone who replies.
Its not my fault I''''m the biggest and the strongest; I don''''t even exercise.
