play_fli(3)
π play_fli π
okay bestie, gather round, because we're about to play some FLI/FLC animations straight off your disk and it's gonna be so cute. this is the Allegro game programming library manual page, and yes, the title is play_fli(3) β say it with me now, main character energy only. β¨
πΈ SYNOPSIS πΈ
#include <allegro.h>
int play_fli(const char *filename, BITMAP *bmp, int loop, int (*callback)());
no cap, that's the whole vibe. one function, four args, infinite slay. π
π¦ DESCRIPTION π¦
so basically?? play_fli plays an Autodesk Animator FLI or FLC animation file onto the BITMAP you specify, and it reads the data from disk as it needs it β like, it's not loading the whole thing upfront, it's streaming it in, lowkey efficient queen behavior. π
now here's the tea about loop:
- if
loopis not zero, the player will cycle when it reaches the end of the file β forever and ever, iconic, it never stops (unless you make it, more on that below). - otherwise it plays through the animation once and then returns. one and done, periodt.
oh and about that callback parameter?? read the beginning of the chapter "FLIC routines" for the full description of it, bestie β that's where the lore lives. iykyk. π
here's an example, and it's genuinely so good:
/* Let users skip looped animations. */
int check_escape_key(void)
{
if (key[KEY_ESC])
return 1;
else
return 0;
}
...
int ret = play_fli("animlogo.fli", screen, 1,
check_escape_key);
if (ret == FLI_ERROR)
abort_on_error("Error playing intro!");
see what she did there?? the callback checks key[KEY_ESC] and returns 1 if escape got pressed, so the user can bail out of a looped animation whenever they want. freedom!! ποΈ and then play_fli("animlogo.fli", screen, 1, check_escape_key) runs it on screen with looping on and that escape-check callback hooked up, and if it comes back as FLI_ERROR we hit it with abort_on_error("Error playing intro!"). that's the whole flow, no notes. π₯
π RETURN VALUE π
the FLI player is very honest with you about how things went, and honestly? we love that:
- it returns
FLI_OKif it reached the end of the file β mission accomplished, we ate. π - it returns
FLI_ERRORif something went wrong β π devastating, but at least you know. - and it returns the value returned by the callback function if that was what stopped it. yep, your own callback can be the thing that ends the party, and its return value is what you get handed back.
π SEE ALSO π
go read these next, bestie, they're all part of the same friend group:
and that's the page!! this was brought to you by Allegro, version 4.4.3 β mwah, love you, go play some animations ππ¦πΈπβ¨
π¦ where this page comes from
- fedora 43: allegro-devel 4.4.3.1-18.fc43 Β· Giftware
- fedora 43: allegro-devel 4.4.3.1-18.fc43 Β· Giftware
- fedora 44: allegro-devel 4.4.3.1-20.fc44 Β· Giftware
- fedora 44: allegro-devel 4.4.3.1-20.fc44 Β· Giftware
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms