do_line(3)
π« do_line(3) β the Allegro manual, but make it cute π«
okay bestie, welcome to the Allegro manual, page do_line(3). this is the Allegro game programming library, and we're about to learn how to make a line go brrr across your screen. no cap. π¦
β¨ NAME β¨
do_line β Calculates all the points along a line. Allegro game programming library. π
πΈ SYNOPSIS πΈ
#include <allegro.h>
void do_line(BITMAP *bmp, int x1, y1, x2, y2, int d, void (*proc)(BITMAP
*bmp, int x, int y, int d));
π DESCRIPTION π
so what this does is: it calculates all the points along a line, going from point (x1, y1) to (x2, y2), and for each one it calls the function you hand it. that's it. that's the whole vibe. π
your function gets passed:
- a copy of the
bmpparameter π - the
xandyposition β - a copy of the
dparameter β¨
which means it is suitable for use with putpixel(). it's giving "perfect little callback" energy, fr fr. π«Ά
here's an example, because obviously we're not leaving you hanging:
void draw_dust_particle(BITMAP *bmp, int x, int y, int d)
{
...
}
and then you'd call it like this:
do_line(screen, 0, 0, SCREEN_W-1, SCREEN_H-2,
dust_strength, draw_dust_particle);
look at that. dust particles. main character energy. π
π SEE ALSO π
bestie reminder: d gets passed as a copy to your callback, so don't go expecting to mutate the original through it. that's just how it is. π
okay that's the whole page, you ate it, periodt. this was Allegro version 4.4.3, do_line(3), and honestly? iconic. go draw something pretty. πππ§
π¦ 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