Pausing the application?
Is there an easy way to pause the application for ½sec?
Abnormally large and solar energy charged!
depends on what language your using and librarys.
Most have there own Pause command you can use, and if yours doesn''t then just get the systems time and assign it to BeginTime then use a while loop assigning system time to CurrentTime until CurrentTime > BeginTime + 1/2 second (500 milliseconds).
Most have there own Pause command you can use, and if yours doesn''t then just get the systems time and assign it to BeginTime then use a while loop assigning system time to CurrentTime until CurrentTime > BeginTime + 1/2 second (500 milliseconds).
If you have
So, to pause for half of a second, you can call it like:
... and to pause it for 5 seconds you can call it like:
and so on.
[ Google || Start Here || ACCU || MSDN || STL || GameCoding || BarrysWorld || E-Mail Me ]
[edited by - Lektrix on February 24, 2003 9:11:12 AM]
ctime
(or time.h
) you could make a function like this: #include <ctime> void Pause(int pauseTime){ clock_t pauseDelay = pauseTime * CLOCKS_PER_SEC; clock_t startTime = clock(); while (clock() - startTime < pauseDelay) continue;}
So, to pause for half of a second, you can call it like:
Pause(0.5);
... and to pause it for 5 seconds you can call it like:
Pause(5);
and so on.
[ Google || Start Here || ACCU || MSDN || STL || GameCoding || BarrysWorld || E-Mail Me ]
[edited by - Lektrix on February 24, 2003 9:11:12 AM]
[ Google || Start Here || ACCU || STL || Boost || MSDN || GotW || CUJ || MSVC++ Library Fixes || BarrysWorld || [email=lektrix@barrysworld.com]E-Mail Me[/email] ]
February 24, 2003 08:37 AM
If you''re on windows you can call the win32 Sleep(m) function which puts the current thread to sleep for m milliseconds. This has the advantage of using 0% cpu (when it''s asleep) unlike using busy while loops to continually check how much time has passed - which is bad practice in a multitasking OS.
eg
#include <Windows.h>
int main(0)
{
Sleep(1000); //sleep for 1 sec
}
I''m sure there are equivalent funtions on other multitasking OS.
eg
#include <Windows.h>
int main(0)
{
Sleep(1000); //sleep for 1 sec
}
I''m sure there are equivalent funtions on other multitasking OS.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement