View Full Version : allegro output
Shakespeare
08-16-2002, 11:27 AM
How can i output an integer variable to the screen, textout only allows strings.
Thanks.
Dual-Catfish
08-16-2002, 11:53 AM
I'm not sure if there are any functions in allegro to output integers and whatnot, but the most logical thing to do at this step would be convert the integers to a string and print them out...
char pszFinalString[30];
char pcszText[] = "A number: ";
int iNumber = 10;
sprintf(pszFinalString, "%s%d", pcszText, iNumber);
printf("%s\n", pszFinalString);
frenchfry164
08-16-2002, 05:43 PM
I think they should've documented this in the manual
textprintf() will do it.
textprintf(screen,font,5,13,makecol(255,255,255),"%?",variable);
replace the ? with
i - integer
g - integer
f- float
c - char
s - string
and all the other ones printf uses.
TechWins
08-17-2002, 07:21 PM
or...
char prinstr[50];
sprintf(printstr, variable);
textout(buffer, font, printstr, 550, 340, makecol(100, 100, 100));
//notice i drew the text to a buffer and not the screen!
//the color of 100,100,100 is a gray...it goes R(red)G(green)B(blue)...
vBulletin® v3.7.0, Copyright ©2000-2009, Jelsoft Enterprises Ltd.