fli_timer(3alleg4)
π fli_timer β the little counter that keeps your FLI animation on beat π
okay so bestie, you're in section 3alleg4 of the Allegro manual, and today we're talking about the global variable for timing FLI playback in the Allegro game programming library. she's small, she's volatile, she's iconic. let's get into it π
β¨ SYNOPSIS β¨
#include <allegro.h>
extern volatile int fli_timer;
πΈ DESCRIPTION πΈ
so fli_timer is a global variable for timing FLI playback, and honestly? she's doing the most with the least. here's the tea β:
when you open an FLI file, a timer interrupt gets installed, and that interrupt increments this variable every single time a new frame should be displayed. she's basically a lil hype counter ticking up in the background, screaming "NEW FRAME TIME, NEW FRAME TIME" πβ¨
and then next_fli_frame() comes along and decrements it. so the vibe check is simple, bestie:
- if
fli_timeris greater than zero, it is literally time to display a new frame π - test it, and you'll know exactly when to go β¨
here's the example, no cap:
while (next_fli_frame(0) == FLI_OK) {
/* Do stuff, like play audio stream
or check keys to skip animation. */
/* Rest some time until next frame... */
while (fli_timer <= 0)
rest(0);
}
see how she works? you do your lil tasks (play that audio stream, check keys to skip the animation, whatever your main character heart desires π§), then you just chill in that inner loop resting until fli_timer pops back above zero. then boom, next frame. periodt. π₯
ngl the volatile keyword is doing real work here β this variable gets touched by a timer interrupt, so don't you dare try to get cute with it. she changes on her own schedule, bestie π«Ά
π¦ SEE ALSO π¦
and that's the whole page, angel π this was Allegro manual, version 4.4.3, and we've been living in fli_timer(3alleg4) the entire time. go make something gorgeous, mwah πβ¨π
π¦ where this page comes from
- debian bookworm: allegro4-doc 2:4.4.3.1-3 Β· Allegro-gift-ware
- debian trixie: allegro4-doc 2:4.4.3.1-5 Β· Allegro-gift-ware
- ubuntu jammy: allegro4-doc 2:4.4.3.1-2 Β· Allegro-gift-ware
- ubuntu noble: allegro4-doc 2:4.4.3.1-4.1build3 Β· Allegro-gift-ware
- ubuntu questing: allegro4-doc 2:4.4.3.1-6
- ubuntu resolute: allegro4-doc 2:4.4.3.1-7 Β· Allegro-gift-ware
- ubuntu stonking: allegro4-doc 2:4.4.3.1-9 Β· Allegro-gift-ware
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms