struct Animation {
int start, stop, current;
DWORD deltatime, nextUpdate;
} anim;
// In your main loop
if(dbTimer() > anim.nextUpdate) {
if(++anim.current > anim.stop)
anim.current = anim.start; // Loop animation after reaching its end
dbSetObjectFrame(objectID, anim.current);
anim.nextUpdate = dbTimer() + deltatime;
}
With some more work you can get it to play in reverse as well (using --anim.current and checking if its < anim.start for instance). A problem with this is that it won't interpolate between the frames. I think it's possible to do that using
dbSetObjectInterpolation (the function name should be something like that) which sets how fast the transition between two frames will be.
"Why do programmers get Halloween and Christmas mixed up?" Because Oct(31) = Dec(25)