wait function

orel56000

Member
Joined
Jun 13, 2015
Messages
17
Reaction score
2
hey everybody,

when i doing a function its working always in loops, and i want to do something are working one a sec, how to do it?
 

Schinko

Active member
Joined
Mar 5, 2013
Messages
187
Reaction score
1
wait 1000

number is in ms, so "wait 10000" would be 10 seconds
 

orel56000

Member
Joined
Jun 13, 2015
Messages
17
Reaction score
2
Schinko link said:
wait 1000

number is in ms, so "wait 10000" would be 10 seconds

i dont have a wait function on my project, and i cant use sleep becuase its make the game stuck...
 
Joined
Feb 18, 2005
Messages
2,965
Reaction score
271
Code:
static std::uint32_t iTime = 0;
if (GetTickCount() - iTime > 1000)
{
	//1sec has passed
	iTime = GetTickCount();
}

if you want more accurate use chrono
 

orel56000

Member
Joined
Jun 13, 2015
Messages
17
Reaction score
2
springfield link said:
Code:
static std::uint32_t iTime = 0;
if (GetTickCount() - iTime > 1000)
{
	//1sec has passed
	iTime = GetTickCount();
}

if you want more accurate use chrono


working thank you
 
Top