/* * call-seq: * wait( time ) -> Integer * * time:: how many milliseconds to wait. * * Wait approximately the given time (the accuracy depends upon processor * scheduling, but 10ms is common). Returns the actual delay time, in * milliseconds. This method is less CPU-intensive than #delay, but is * slightly less accurate. * * The Rubygame timer system will be initialized when you call this function, * if it has not been already. * */ VALUE rbgm_time_wait(VALUE module, VALUE milliseconds) { Uint32 start, delay; if(!SDL_WasInit(SDL_INIT_TIMER)) if(SDL_InitSubSystem(SDL_INIT_TIMER)) rb_raise(eSDLError,"Could not initialize timer system: %s",\ SDL_GetError()); delay = NUM2UINT(milliseconds); start = SDL_GetTicks(); SDL_Delay(delay); return INT2NUM(SDL_GetTicks() - start); }