Jump to content
  • Advertisement
Sign in to follow this  
pi_man

Printing numbers in Allegro

This topic is 3934 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i've been having a bit of trouble with printing numbers in Allegro. At the moment i am using the textout_ex() function and replacing the string with a variable holding the number of lives the player has left, problem being it says "invalid conversion from `int' to `const char*'" Any help would be great.

Share this post


Link to post
Share on other sites
Advertisement
You need to convert the number to a string. Assuming C++, you can use a std::stringstream or boost::lexical_cast. Ex:

std::stringstream sstr;
sstr << my_number;
const char * my_number_as_char_pointer = sstr.str().c_str()

Share this post


Link to post
Share on other sites
The textprintf_ex() function provides printf style formatting, so doing any of your own conversion is a wasted effort.


int player_score;

textprintf_ex(screen, font, 10, 10, makecol(255, 100, 200), -1, "Score: %d", player_score);

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!