[SDL] Repeating timers

Donny Viszneki donny.viszneki at gmail.com
Fri Apr 10 12:01:30 PDT 2009


On Fri, Apr 10, 2009 at 2:22 PM, Jonathan Dearborn <grimfang4 at gmail.com> wrote:
> Logically, though, the 'oldStart + newInterval' would not work for
> newInterval values less than your deltaT (processing time).  That
> leads me to guess that the new timer starts at 'oldEnd + newInterval'.
>
> Sorry for the spam,
> Jonny D
>
> On Fri, Apr 10, 2009 at 2:20 PM, Jonathan Dearborn <grimfang4 at gmail.com> wrote:
>> Oh, I see.  It does seem ambiguous, but I'm not currently in a
>> position to test whether the new timer starts at 'oldStart +
>> newInterval' or 'oldEnd + newInterval'.

Here is the relevant code from SDL:

if ( (int)(now - t->last_alarm) > (int)ms ) {
    struct _SDL_TimerID timer;

    if ( (now - t->last_alarm) < t->interval ) {
        t->last_alarm += t->interval;
    } else {
        t->last_alarm = now;
    }

-- 
http://codebad.com/



More information about the SDL mailing list