textout_centre_ex(3alleg4)

✨ textout_centre_ex β€” Allegro manual, bestie edition ✨

okay so this is textout_centre_ex(3alleg4), straight out of the Allegro game programming library πŸ’– she writes a centered string on a bitmap and honestly? she's the moment.


🌸 NAME 🌸

textout_centre_ex β€” writes a centered string on a bitmap. Allegro game programming library. no cap, that's literally her whole job πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

#include <allegro.h>

void textout_centre_ex(BITMAP *bmp, const FONT *f, const char *s, int x,
y, int color, int bg);

like look at her. so simple. so iconic. πŸ¦‹


πŸ’œ DESCRIPTION πŸ’œ

So it's giving textout_ex()... but make it centered. ✨ That's it, that's the vibe.

The one thing you gotta internalize: the x coordinate here is the centre of your string, not the left edge. Not the beginning. The middle. The main character position. πŸ‘‘

fr fr, if you pass the left edge you're gonna be off by half a string and you WILL notice 😭

Example, because a girl loves a demo:

/* Important texts go in the middle. */
width = text_length("GAME OVER");
textout_centre_ex(screen, font, "GAME OVER",
                  SCREEN_W / 2, SCREEN_H / 2,
                  makecol(255, 0, 0), makecol(0, 0, 0));

SCREEN_W / 2 and SCREEN_H / 2? that's the center of the screen bestie. putting "GAME OVER" dead center in red on black. absolutely ate. πŸ“


🌈 SEE ALSO 🌈


okay that's the whole page, go center some text and be great 🫢

signing off with love from the Allegro girlies β€” this one's from version 4.4.3 of the Allegro manual. bye bestie, mwah πŸ’–βœ¨πŸ§š