- Online Community Forums » Programming Questions » scores on-screen display

This thread is locked; no one can reply to it. rss feed Print
scores on-screen display
Member #16,069
September 2015

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.

Member #12,293
October 2010

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);

Member #16,069
September 2015

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

Thanks! :D

Go to: