Could someone explain GetTickCount()

May 17, 2011 at 11:21am
First of all, here's a sapmle of code I wrote to test this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include "stdafx.h"
#include <iostream>
#include <Windows.h>
#include <conio.h>


int _tmain(int argc, _TCHAR* argv[])
{
	double start = 0;
	double current = 0;

	int update = 1000;

	do
	{
		start = GetTickCount();

		while( ( current < update ) && ( ! _kbhit() ) )
		{
			current = GetTickCount() - start;
		}

		std::cout << current << '\n';

		current = 0;

	}while( ! _kbhit() );

	return 0;
}

When changing int update 1000;, it seems the lower I go, the close to the actual update number I get.
Within a range of approx. 20, from 1000, the output is almost always 1014.

If this is ticks per second, shouldn't there be the slightest change in the output with almost any change of update?

Cheers for any help.
May 17, 2011 at 11:32am
May 17, 2011 at 1:10pm
I'm a beginner in C++, but I know this function because it's in the PAWN language for GTA San Andreas Multiplayer...

A little example:
1
2
3
4
5
6
int start;

if(GetTickCount() > start - <THE TIME YOU WANT>) //The code will start only if the time is passed
{
  //Do the things
}


I think in C++ you use like this. I don't really know, but PAWN is very similart to C++...
May 17, 2011 at 1:16pm
Thanks a lot for the replys.
Topic archived. No new replies allowed.