scores on-screen display

Hello everyone.

I have the following problem: I need update the score in the game each time the character makes an action. My idea is to use a variable (int n for example) to increase the score. The question is whether allegro have any function as al_draw_text to print variables, I was investigated but i don't found the answer.

I really appreciate your help!
Thanks, and excuse me for my bad english.


You can use al_draw_textf with a printf-style format string (the 'f' at the end means "formatted output").

int score = 1000;
al_draw_textf(my_font, al_map_rgb_f(1.0, 1.0, 1.0), 0, 0, 0, "Score: %d", score);


Thank you very much for your quick response, it works wonders.

Thanks! :D

Thread #615809. Printed from