Mail Archives: djgpp/1999/08/12/21:26:52
> guthrie wrote:
>
> > how can I , if even possible , print a string or char array out to the
> > screen using the textout or textout_centre allegro functions?
> >
Fred Backman <fredrick DOT backman AT pmail DOT net> wrote in message
news:37B14F14 DOT 4EEBF047 AT pmail DOT net...
> As always, there's many ways to do it, but try something like the
following:
>
> char foo[32]; // Max. 32 characters
>
> sprintf(foo, "Parrot ate a cracker!");
> textout(screen, font, foo, 300, 125, color1);
>
> Then it's up to you to put anything into foo, as long as length < 32.
Another
> sample:
>
> sprintf(foo, "Parrot ate %d crackers!", ncrackers);
> textout(screen, font, foo, 300, 125, color1);
>
>
> Fred Backman,
> Lead Wizard
> Binary Spells
> www.binaryspells.com
Allegro has something even simpler: textprintf().
void textprintf(BITMAP *bmp, FONT *theFont, int x, int y, int color, char
*format, ...);
Structure the format string as you would for printf(). Common call:
textprintf(screen, font, 0, 192, 15, "Score: %6d", score);
If you want to see more examples of textprintf(), download DOSArena(TM) from
my home page:
http://www.rose-hulman.edu/~yerricde
DOSArena is a trademark of Damian Yerrick.
- Raw text -