Re: [Dev-C++] Sleep / for specified time delay :( ?
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
From: Frederico M. <the...@ho...> - 2009-02-04 09:54:30
|
Hey... (* first, for those u are C++ coders, i apologize, i'll be murdering C++ below... if you have a faint heart, please look away! :P *)You can either use Sleep for windows... which works very well for most cases, or you can do something like : snippet : ---------------------------------------------------------#include <time.h>class DeltaTime { clock_t init; unsigned delta; public : DeltaTime( float sec = 1 ) { setDelta( sec ); } void setDelta( float sec ) { delta = CLK_TCK * sec; } void start() { init = clock(); } bool timeout() { return clock() - init >= delta; } void wait() { while (!timeout()) ; }} -------------------------------------------------------------------- Usage : snippet : -------------------------------------------------------------------- DeltaTime timer( 10 ) ;timer.start(); timer.wait(); -------------------------------------------------------------------- Of course u can tweak it to make it more "easy" ... and, you can introduce some linked list of function pointers, that iterate while the code is in wait/timeout. Its "limitless" ^^. Frederico Marques Date: Tue, 3 Feb 2009 22:06:55 +0200From: gx...@gm...To: dev...@li...Subject: [Dev-C++] Sleep / for specified time delay :( ?Hi,I want to make a delay/pause in C++, in Dev-C++... Does somebody know how to do that ? An example ?Thanks. _________________________________________________________________ Cansado de espaço para só 50 fotos? Conheça o Spaces, o site de relacionamentos com até 6,000 fotos! http://www.amigosdomessenger.com.br |